public ProfileDTO UpdateProfile(Token token, ProfileUpdateData data) { var securityInfo = SecurityManager.EnsureAuthentication(token); ProfileService service = new ProfileService(Session, securityInfo, Configuration, SecurityManager, PushNotificationService, EMailService); return(service.UpdateProfile(data)); }
public void Test_Bug_TwoInstancesUpdateProfile() { var profile = (ProfileDTO)profiles[0].Tag; profile.AboutInformation = "ver1"; SessionData data1 = CreateNewSession(profile, ClientInformation); RunServiceMethod(delegate(InternalBodyArchitectService Service) { ProfileUpdateData d = new ProfileUpdateData(); d.Profile = profile; Service.UpdateProfile(data1.Token, d); }); SessionData data2 = CreateNewSession(profile, ClientInformation); profile.AboutInformation = "ver2"; RunServiceMethod(delegate(InternalBodyArchitectService Service) { ProfileUpdateData d = new ProfileUpdateData(); d.Profile = profile; Service.UpdateProfile(data2.Token, d); }); }
public static ProfileDTO UpdateProfile(ProfileUpdateData data) { return(exceptionHandling(delegate { return Instance.UpdateProfile(Token, data); })); }
public ProfileDTO SaveProfile() { bool valid = true; this.ParentWindow.SynchronizationContext.Send(delegate { usrProfileNotifications1.Save(profile); usrProfilePrivacy1.Save(profile); if (!usrCreateProfile1.SaveProfile(profile)) { valid = false; return; } var picture = usrProfilePersonalInfo1.Save(profile); profileInfo.Wymiary = usrWymiaryEditor1.SaveWymiary(profileInfo.Wymiary); 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()); } profile.Settings.AutomaticUpdateMeasurements = chkAutomaticUpdateMeasurements.Checked; }, null); if (valid) { ProfileUpdateData data = new ProfileUpdateData(); data.Profile = profile; data.Wymiary = profileInfo.Wymiary; var res = ServiceManager.UpdateProfile(data); return(res); } return(null); }
public void TestUpdateProfile_ExceptionDuringRemoveImage() { //PictureService tmp = new PictureService(Session, null); //string folder = tmp.ImagesFolder; Guid pictureId = Guid.NewGuid(); var file = File.CreateText(Path.Combine(ImagesFolder, pictureId.ToString())); profiles[0].Picture = new Picture(pictureId, "dfgdfgdfg"); insertToDatabase(profiles[0]); UnitTestHelper.SetProperty(profiles[0].Tag, "Version", profiles[0].Version); var profile = (ProfileDTO)profiles[0].Tag; SessionData data = CreateNewSession(profile, ClientInformation); RunServiceMethod(delegate(InternalBodyArchitectService service) { ProfileUpdateData d = new ProfileUpdateData(); d.Profile = profile; d.Profile.Picture = null; d.Profile.Gender = Gender.Male; service.UpdateProfile(data.Token, d); }); Assert.IsTrue(File.Exists(Path.Combine(ImagesFolder, pictureId.ToString()))); var dbProfile = Session.Get <Profile>(profile.GlobalId); Assert.AreEqual(Model.Gender.Male, dbProfile.Gender); file.Close(); }
private void usrProgressIndicatorButtons1_OkClick(object sender, ProgressIndicator.CancellationSourceEventArgs e) { var copyProfile = UserContext.CurrentProfile.Clone(); var picture = baPictureEdit1.Save(copyProfile); if (picture != null && (copyProfile.Picture == null || picture.Hash != copyProfile.Picture.Hash)) { var info = ServiceManager.UploadImage(picture); copyProfile.Picture = info; PicturesCache.Instance.AddToCache(picture.ToPictureCacheItem()); } ProfileUpdateData data = new ProfileUpdateData(); data.Profile = copyProfile; if (chkBlogger.Checked || chkPublic.Checked) { data.Profile.Privacy.CalendarView = Privacy.Public; data.Profile.Privacy.Sizes = Privacy.Public; } else { data.Profile.Privacy.CalendarView = Privacy.Private; data.Profile.Privacy.Sizes = Privacy.Private; } data.Profile.Settings.AutomaticUpdateMeasurements = chkAutoUpdateMeasurements.Checked; data.Wymiary = UserContext.ProfileInformation.Wymiary; var res = ServiceManager.UpdateProfile(data); UserContext.SessionData.FillProfileData(res); UserContext.RefreshUserData(); if (UserContext.Settings.GuiState.CalendarOptions == null) { UserContext.Settings.GuiState.CalendarOptions = new CalendarOptions(); } UserContext.Settings.GuiState.CalendarOptions.DefaultEntries.Clear(); if (chkBlogger.Checked) { UserContext.Settings.GuiState.CalendarOptions.CalendarTextType = BlogCalendarDayContent.ID; UserContext.Settings.GuiState.CalendarOptions.DefaultEntries[BlogModule.ModuleId] = true; UserContext.Settings.GuiState.CalendarOptions.DefaultEntries[StrengthTrainingModule.ModuleId] = true; UserContext.Settings.GuiState.CalendarOptions.DefaultEntries[SizeModule.ModuleId] = true; } else { UserContext.Settings.GuiState.CalendarOptions.CalendarTextType = StrengthTrainingCalendarDayContent.ID; UserContext.Settings.GuiState.CalendarOptions.DefaultEntries[StrengthTrainingModule.ModuleId] = true; UserContext.Settings.GuiState.CalendarOptions.DefaultEntries[SizeModule.ModuleId] = true; } UserContext.Settings.GuiState.CalendarOptions.DefaultEntries[SuplementsModule.ModuleId] = chkSupplementsEntry.Checked; //mark current profile to not show this wizard again UserContext.Settings.SetProfileConfigurationWizardShowed(UserContext.CurrentProfile.Id, true); UserContext.Settings.Save(); ThreadSafeClose(); }
public void Test_ChangeRole_Exception() { var profile = (ProfileDTO)profiles[0].Tag; SessionData data = SecurityManager.CreateNewSession(profile, ClientInformation); RunServiceMethod(delegate(InternalBodyArchitectService service) { ProfileUpdateData d = new ProfileUpdateData(); d.Profile = profile.Clone(); UnitTestHelper.SetProperty(d.Profile, "Role", Role.Administrator); service.UpdateProfile(data.Token, d); }); }
public void Test_ChangeUserName_Exception() { var profile = (ProfileDTO)profiles[0].Tag; SessionData data = CreateNewSession(profile, ClientInformation); RunServiceMethod(delegate(InternalBodyArchitectService service) { ProfileUpdateData d = new ProfileUpdateData(); d.Profile = profile.Clone(); d.Profile.UserName = "******"; service.UpdateProfile(data.Token, d); }); }
public void Test_ChangeEMail_Exception() { var profile = (ProfileDTO)profiles[0].Tag; SessionData data = SecurityManager.CreateNewSession(profile, ClientInformation); RunServiceMethod(delegate(InternalBodyArchitectService service) { ProfileUpdateData d = new ProfileUpdateData(); d.Profile = profile.Clone(); d.Profile.Email = "*****@*****.**"; service.UpdateProfile(data.Token, d); }); }
public void Test_ChangeProfileData_UpdateCreatedProfileDate() { var profile = (ProfileDTO)profiles[0].Tag; UnitTestHelper.SetProperty(profile, "CreationDate", DateTime.Now.AddDays(1)); SessionData data = CreateNewSession(profile, ClientInformation); RunServiceMethod(delegate(InternalBodyArchitectService Service) { ProfileUpdateData d = new ProfileUpdateData(); d.Profile = profile; Service.UpdateProfile(data.Token, d); }); var dbProfile = Session.Get <Profile>(profile.GlobalId); Assert.IsFalse(UnitTestHelper.CompareDateTime(profiles[0].CreationDate, dbProfile.CreationDate)); }
public void Test_SkipBAPoints() { profiles[0].Licence.BAPoints = 10; insertToDatabase(profiles[0]); var profile = profiles[0].Map <ProfileDTO>(); SessionData data = CreateNewSession(profile, ClientInformation); RunServiceMethod(delegate(InternalBodyArchitectService Service) { ProfileUpdateData d = new ProfileUpdateData(); d.Profile = profile; Service.UpdateProfile(data.Token, d); }); var dbProfile = Session.Get <Profile>(profile.GlobalId); Assert.AreEqual(10, dbProfile.Licence.BAPoints); }
public void Test_Bug_LoosingAllCollections() { var profile = (ProfileDTO)profiles[0].Tag; DateTime time = DateTime.Now; profile.Birthday = time; SessionData data = CreateNewSession(profile, ClientInformation); RunServiceMethod(delegate(InternalBodyArchitectService Service) { ProfileUpdateData d = new ProfileUpdateData(); d.Profile = profile; Service.UpdateProfile(data.Token, d); }); var dbProfile = Session.Get <Profile>(profile.GlobalId); Assert.AreEqual(1, dbProfile.Friends.Count); Assert.AreEqual(time, profile.Birthday); }
public void Test_ChangeWymiary_ExistingObject() { var profile = profiles[0].Map <ProfileDTO>(); SessionData data = CreateNewSession(profile, ClientInformation); RunServiceMethod(delegate(InternalBodyArchitectService Service) { ProfileUpdateData d = new ProfileUpdateData(); d.Profile = profile; d.Wymiary = profiles[0].Wymiary.Map <WymiaryDTO>(); d.Wymiary.Klatka = 101; Service.UpdateProfile(data.Token, d); }); var dbProfile = Session.Get <Profile>(profile.GlobalId); Assert.IsNotNull(dbProfile.Wymiary); Assert.AreEqual(101, dbProfile.Wymiary.Klatka); Assert.AreEqual(1, Session.QueryOver <Wymiary>().RowCount()); }
//[ExpectedException(typeof(HibernateException))] public void Test_ChangeWymiary_WithNewInstance() { var profile = (ProfileDTO)profiles[0].Tag; SessionData data = SecurityManager.CreateNewSession(profile, ClientInformation); RunServiceMethod(delegate(InternalBodyArchitectService Service) { ProfileUpdateData d = new ProfileUpdateData(); d.Profile = profile; d.Wymiary = new WymiaryDTO(); d.Wymiary.Klatka = 11; Service.UpdateProfile(data.Token, d); }); var dbProfile = Session.Get <Profile>(profile.Id); Assert.IsNotNull(dbProfile.Wymiary); Assert.AreEqual(11, dbProfile.Wymiary.Klatka); Assert.AreEqual(1, Session.QueryOver <Wymiary>().RowCount()); }
public void Test_ShouldntRemoveImage() { Guid pictureId = Guid.NewGuid(); File.CreateText(Path.Combine(ImagesFolder, pictureId.ToString())).Close(); profiles[0].Picture = new Picture(pictureId, "dfgdfgdfg"); insertToDatabase(profiles[0]); UnitTestHelper.SetProperty(profiles[0].Tag, "Version", profiles[0].Version); var profile = (ProfileDTO)profiles[0].Tag; SessionData data = CreateNewSession(profile, ClientInformation); RunServiceMethod(delegate(InternalBodyArchitectService service) { ProfileUpdateData d = new ProfileUpdateData(); d.Profile = profile; d.Profile.Picture = new PictureInfoDTO(pictureId, "fdgdf"); service.UpdateProfile(data.Token, d); }); Assert.IsTrue(File.Exists(Path.Combine(ImagesFolder, pictureId.ToString()))); }
public void Test_ChangeProfileData() { var profile = (ProfileDTO)profiles[0].Tag; DateTime time = DateTime.UtcNow; profile.Birthday = time; profile.Gender = Gender.Male; profile.AboutInformation = "testInfo"; profile.Privacy.CalendarView = Privacy.FriendsOnly; profile.Privacy.Sizes = Privacy.Public; profile.Privacy.Friends = Privacy.Public; profile.Picture = new PictureInfoDTO(); profile.Picture.Hash = "testHash"; Guid testPictureId = Guid.NewGuid(); profile.Picture.PictureId = testPictureId; profile.CountryId = 6; SessionData data = CreateNewSession(profile, ClientInformation); RunServiceMethod(delegate(InternalBodyArchitectService Service) { ProfileUpdateData d = new ProfileUpdateData(); d.Profile = profile; Service.UpdateProfile(data.Token, d); }); var dbProfile = Session.Get <Profile>(profile.GlobalId); Assert.AreEqual(time.Date, dbProfile.Birthday.Date); Assert.AreEqual(Model.Gender.Male, dbProfile.Gender); Assert.AreEqual("testInfo", dbProfile.AboutInformation); Assert.AreEqual(Model.Privacy.FriendsOnly, dbProfile.Privacy.CalendarView); Assert.AreEqual(Model.Privacy.Public, dbProfile.Privacy.Sizes); Assert.AreEqual(Model.Privacy.Public, dbProfile.Privacy.Friends); Assert.AreEqual("testHash", profile.Picture.Hash); Assert.AreEqual(testPictureId, profile.Picture.PictureId); Assert.AreEqual(6, profile.CountryId); Assert.IsTrue(UnitTestHelper.CompareDateTime(profiles[0].CreationDate, dbProfile.CreationDate)); }
public void Test_ChangeWymiary_AutomaticUpdateMeasurements() { var profile = (ProfileDTO)profiles[0].Tag; SessionData data = CreateNewSession(profile, ClientInformation); RunServiceMethod(delegate(InternalBodyArchitectService Service) { ProfileUpdateData d = new ProfileUpdateData(); d.Profile = profile; d.Wymiary = new WymiaryDTO(); d.Wymiary.GlobalId = profiles[0].Wymiary.GlobalId; d.Wymiary.Klatka = 101; profile = Service.UpdateProfile(data.Token, d); }); profile.Settings.AutomaticUpdateMeasurements = true; RunServiceMethod(delegate(InternalBodyArchitectService Service) { ProfileUpdateData d = new ProfileUpdateData(); d.Profile = profile; profile = Service.UpdateProfile(data.Token, d); }); //this operation shouldn't change the measurements because of automatic update enabled RunServiceMethod(delegate(InternalBodyArchitectService Service) { ProfileUpdateData d = new ProfileUpdateData(); d.Profile = profile; d.Wymiary = new WymiaryDTO(); d.Wymiary.GlobalId = profiles[0].Wymiary.GlobalId; d.Wymiary.Klatka = 200; Service.UpdateProfile(data.Token, d); }); var dbProfile = Session.Get <Profile>(profile.GlobalId); Assert.IsNotNull(dbProfile.Wymiary); Assert.AreEqual(101, dbProfile.Wymiary.Klatka); Assert.AreEqual(1, Session.QueryOver <Wymiary>().RowCount()); }
private void saveProfile(string hash, WriteableBitmap _bitmap) { var m = new ServiceManager <UpdateProfileCompletedEventArgs>(delegate(BodyArchitectAccessServiceClient client1, EventHandler <UpdateProfileCompletedEventArgs> operationCompleted) { ProfileUpdateData data = new ProfileUpdateData(); var copyProfile = ApplicationState.Current.SessionData.Profile.Copy(); copyProfile.AboutInformation = viewModel.Profile.AboutInformation; copyProfile.Birthday = viewModel.Profile.Birthday.Value; copyProfile.Gender = viewModel.Profile.User.Gender; copyProfile.CountryId = viewModel.Profile.User.CountryId; copyProfile.Settings = viewModel.Profile.Settings; if (!string.IsNullOrEmpty(viewModel.Password1)) { copyProfile.Password = viewModel.Password1.ToSHA1Hash(); } copyProfile.Privacy = viewModel.Profile.User.Privacy; copyProfile.Picture = viewModel.Profile.User.Picture; data.Profile = copyProfile; data.Wymiary = viewModel.Profile.Wymiary; if (picture != null) { if (copyProfile.Picture == null) { copyProfile.Picture = new PictureInfoDTO(); } copyProfile.Picture.PictureIdk__BackingField = PictureId; copyProfile.Picture.Hashk__BackingField = hash; copyProfile.Picture.SessionIdk__BackingField = ApplicationState.Current.SessionData.Token.SessionId; } ApplicationState.Current.EditProfileInfo.User.Picture = copyProfile.Picture; data.Profile = copyProfile; data.Wymiary = ApplicationState.Current.ProfileInfo.Wymiary; client1.UpdateProfileAsync(ApplicationState.Current.SessionData.Token, data); client1.UpdateProfileCompleted -= operationCompleted; client1.UpdateProfileCompleted += operationCompleted; }); m.OperationCompleted += (s, a) => { if (a.Error != null) { BugSenseHandler.Instance.SendExceptionAsync(a.Error); progressBar.ShowProgress(false); ApplicationBar.EnableApplicationBar(true); BAMessageBox.ShowError(ApplicationStrings.ErrSaveProfile); return; } else { if (_bitmap != null) { PicturesCache.Instance.Remove(PictureId); PictureCacheItem item = new PictureCacheItem(_bitmap, PictureId, hash); PicturesCache.Instance.AddToCache(item); PicturesCache.Instance.Notify(a.Result.Result.Picture); } ApplicationState.Current.ProfileInfo = ApplicationState.Current.EditProfileInfo; ApplicationState.Current.SessionData.Profile = a.Result.Result; if (!string.IsNullOrEmpty(viewModel.Password1)) {//store new password Settings.Password = viewModel.Password1; } Dispatcher.BeginInvoke(delegate { if (NavigationService.CanGoBack) { NavigationService.GoBack(); } }); } }; progressBar.ShowProgress(true, ApplicationStrings.ProfilePage_ProgressSave); if (!m.Run()) { progressBar.ShowProgress(false); if (ApplicationState.Current.IsOffline) { BAMessageBox.ShowError(ApplicationStrings.ErrOfflineMode); } else { BAMessageBox.ShowError(ApplicationStrings.ErrNoNetwork); } } }
public ProfileDTO UpdateProfile(Token token, ProfileUpdateData data) { return(exceptionHandling(token, () => InternalService.UpdateProfile(token, data))); }
public ProfileDTO UpdateProfile(Token token, ProfileUpdateData data) { throw new NotImplementedException(); }