Nextrek
Diff Revisions
798
vs
799
for /Android/SmartCharging/SmartCharging_WP/SmartCharging/ModifySitePage.xaml.cs
|
@@ -41,6 +41,8 @@ |
41 |
41 |
|
private SmartChargeAPI SMA; |
42 |
42 |
|
private ResourceLoader resourceLoader; |
43 |
43 |
|
private Site currentSite; |
|
44 |
+ |
private ErrorHandler errorHandler; |
|
45 |
+ |
|
44 |
46 |
|
|
45 |
47 |
|
public ModifySitePage() |
46 |
48 |
|
{ |
|
@@ -50,7 +52,7 @@ |
50 |
52 |
|
this.navigationHelper.LoadState += this.NavigationHelper_LoadState; |
51 |
53 |
|
this.navigationHelper.SaveState += this.NavigationHelper_SaveState; |
52 |
54 |
|
this.SMA = SmartChargeAPI.Instance; |
53 |
|
- |
|
|
55 |
+ |
this.errorHandler = new ErrorHandler(); |
54 |
56 |
|
this.resourceLoader = ResourceLoader.GetForCurrentView("Resources"); |
55 |
57 |
|
} |
56 |
58 |
|
|
|
@@ -88,12 +90,7 @@ |
88 |
90 |
|
List<SiteType> types = await this.SMA.getSiteTypesList(); |
89 |
91 |
|
this.SiteTypeList.ItemsSource = types; |
90 |
92 |
|
List<Site> userSites = await this.SMA.GetUserSites(); |
91 |
|
- |
string avatarUrl = await this.SMA.GetUserAvatar(this.SMA.user.Id); |
92 |
93 |
|
|
93 |
|
- |
if (avatarUrl != "") |
94 |
|
- |
{ |
95 |
|
- |
this.AvatarPicker.setImageSource(new Uri(avatarUrl)); |
96 |
|
- |
} |
97 |
94 |
|
|
98 |
95 |
|
|
99 |
96 |
|
if (userSites != null && userSites.Count > 0) |
|
@@ -187,8 +184,8 @@ |
187 |
184 |
|
{ |
188 |
185 |
|
bool isValid = ValidateFields(); |
189 |
186 |
|
if (isValid) |
190 |
|
- |
{ |
191 |
|
- |
|
|
187 |
+ |
{ |
|
188 |
+ |
showLoading(); |
192 |
189 |
|
Site newSite = new Site() |
193 |
190 |
|
{ Id = this.currentSite.Id, |
194 |
191 |
|
Name = this.SiteNameInput.Text, |
|
@@ -199,21 +196,30 @@ |
199 |
196 |
|
PhoneNumber = this.PhoneNumberInput.Text, |
200 |
197 |
|
Email = this.EmailInput.Text, |
201 |
198 |
|
WebSite = this.SiteWebsiteTextBox.Text, |
202 |
|
- |
Chargers = System.Text.RegularExpressions.Regex.IsMatch(this.NumberOfChargersTextBox.Text, "[^0-9]") ? int.Parse(this.NumberOfChargersTextBox.Text) : 0 |
|
199 |
+ |
Chargers = System.Text.RegularExpressions.Regex.IsMatch(this.NumberOfChargersTextBox.Text, "[0-9]+") ? int.Parse(this.NumberOfChargersTextBox.Text) : 0 |
203 |
200 |
|
|
204 |
201 |
|
}; |
205 |
202 |
|
|
206 |
|
- |
bool siteAdditionResult = await this.SMA.AddSite(newSite, this.SiteImagePicker.images.ToList()); |
|
203 |
+ |
List<string> removedImages = new List<string>(); |
|
204 |
+ |
foreach(Uri uri in this.SiteImagePicker.initialRemovedImaged){ |
|
205 |
+ |
removedImages.Add(uri.ToString()); |
|
206 |
+ |
} |
|
207 |
+ |
|
|
208 |
+ |
bool siteAdditionResult = await this.SMA.EditSite(newSite, this.SiteImagePicker.pickedImages.ToList(), removedImages); |
207 |
209 |
|
if (siteAdditionResult) |
208 |
210 |
|
{ |
|
211 |
+ |
await this.errorHandler.ShowInfo(resourceLoader.GetString("SiteEditSuccessMessage")); |
209 |
212 |
|
this.goToUserPage(); |
210 |
213 |
|
} |
|
214 |
+ |
this.hideLoading(); |
211 |
215 |
|
|
212 |
216 |
|
} |
213 |
217 |
|
|
214 |
|
- |
this.hideLoading(); |
|
218 |
+ |
|
215 |
219 |
|
} |
216 |
220 |
|
catch (Exception ex){ |
|
221 |
+ |
|
|
222 |
+ |
Debug.WriteLine("Exception in ModifySitePage | SubmitButton_Tapped"); |
217 |
223 |
|
Debug.WriteLine(ex.Message); |
218 |
224 |
|
this.hideLoading(); |
219 |
225 |
|
string s = ex.Message; |