public object Save() { PictureDTO picture = null; Dispatcher.Invoke(new Action(delegate { picture = baPictureEdit1.Save(customer); customer.Settings.AutomaticUpdateMeasurements = chkAutomaticUpdateMeasurements.IsChecked.Value; customer.Wymiary = usrWymiaryEditor1.SaveWymiary(customer.Wymiary); })); if (picture != null && (customer.Picture == null || ForceUploadImage || picture.Hash != customer.Picture.Hash)) { var info = ServiceManager.UploadImage(picture); picture.PictureId = info.PictureId; customer.Picture = info; PicturesCache.Instance.AddToCache(picture.ToPictureCacheItem()); } var newCustomer = ServiceManager.SaveCustomer(customer); //TODO:Add optimalization not to invoke clear cache if reminder hasn't changed ReminderItemsReposidory.Instance.ClearCache(); return(newCustomer); }
public ProfileDTO SaveProfile() { bool valid = true; PictureDTO picture = null; Dispatcher.Invoke(new Action(delegate { usrProfileNotifications1.Save(profile); usrProfilePrivacy1.Save(profile); if (!usrCreateProfile1.SaveProfile(profile)) { valid = false; return; } picture = usrProfilePersonalInfo1.Save(profile); profileInfo.Wymiary = usrWymiaryEditor1.SaveWymiary(profileInfo.Wymiary); profile.Settings.AutomaticUpdateMeasurements = chkAutomaticUpdateMeasurements.IsChecked.Value; })); if (picture != null && (profile.Picture == null || usrProfilePersonalInfo1.ForceUploadImage || picture.Hash != profile.Picture.Hash)) { var info = ServiceManager.UploadImage(picture); picture.PictureId = info.PictureId; profile.Picture = info; PicturesCache.Instance.AddToCache(picture.ToPictureCacheItem()); } if (valid) { ProfileUpdateData data = new ProfileUpdateData(); data.Profile = profile; data.Wymiary = profileInfo.Wymiary; var res = ServiceManager.UpdateProfile(data); return(res); } return(null); }