public void DeleteDayWithSystemEntry() { TrainingDay day = new TrainingDay(DateTime.Now); day.Profile = profiles[0]; SizeEntry entry = new SizeEntry(); entry.Wymiary = new Wymiary(); entry.Wymiary.Height = 100; entry.Status = Model.EntryObjectStatus.System; day.AddEntry(entry); insertToDatabase(day); var profile = (ProfileDTO)profiles[0].Tag; SessionData data = CreateNewSession(profile, ClientInformation); RunServiceMethod(delegate(InternalBodyArchitectService Service) { var param = new DeleteTrainingDayParam(); param.TrainingDayId = day.GlobalId; Service.DeleteTrainingDay(data.Token, param); }); }
public void DeleteTrainingDay_EntryWithReminder() { var profile = (ProfileDTO)profiles[0].Tag; SessionData data = CreateNewSession(profile, ClientInformation); DateTime date = DateTime.Now.AddDays(-2); TrainingDayDTO day = new TrainingDayDTO(date); day.ProfileId = profile.GlobalId; SizeEntryDTO sizeEntry = new SizeEntryDTO(); sizeEntry.Wymiary = new WymiaryDTO(); sizeEntry.RemindBefore = TimeSpan.FromMinutes(10); sizeEntry.Wymiary.Height = 100; day.AddEntry(sizeEntry); SaveTrainingDayResult result = null; RunServiceMethod(delegate(InternalBodyArchitectService Service) { result = Service.SaveTrainingDay(data.Token, day); day = result.TrainingDay; }); RunServiceMethod(delegate(InternalBodyArchitectService Service) { var param = new DeleteTrainingDayParam(); param.TrainingDayId = day.GlobalId; Service.DeleteTrainingDay(data.Token, param); }); var count = Session.QueryOver <ReminderItem>().RowCount(); Assert.AreEqual(0, count); }
public void TestDeleteTrainingDay_Mode_OnlyWithoutMyTraining_TrainingDayShouldBeDeleted() { var profile = (ProfileDTO)profiles[0].Tag; SessionData data = CreateNewSession(profile, ClientInformation); DateTime date = DateTime.Now.AddDays(-2); TrainingDayDTO day = new TrainingDayDTO(date); day.ProfileId = profile.GlobalId; SizeEntryDTO sizeEntry = new SizeEntryDTO(); sizeEntry.Wymiary = new WymiaryDTO(); sizeEntry.Wymiary.Height = 100; day.AddEntry(sizeEntry); SaveTrainingDayResult result = null; RunServiceMethod(delegate(InternalBodyArchitectService Service) { result = Service.SaveTrainingDay(data.Token, day); day = result.TrainingDay; }); RunServiceMethod(delegate(InternalBodyArchitectService Service) { var param = new DeleteTrainingDayParam(); param.TrainingDayId = day.GlobalId; param.Mode = DeleteTrainingDayMode.OnlyWithoutMyTraining; Service.DeleteTrainingDay(data.Token, param); }); Assert.AreEqual(0, Session.QueryOver <TrainingDay>().RowCount()); Assert.AreEqual(0, Session.QueryOver <SizeEntry>().RowCount()); }
public void TestDeleteTrainingDay_Mode_OnlyWithoutMyTraining_TrainingDayShouldNotChanged() { var profile = (ProfileDTO)profiles[0].Tag; SessionData data = CreateNewSession(profile, ClientInformation); DateTime date = DateTime.Now.AddDays(-2); var day = new TrainingDay(date); day.Profile = profiles[0]; SizeEntry size = new SizeEntry(); size.Wymiary = new Wymiary(); MyTraining training = new A6WTraining(); training.Name = "test"; training.Profile = day.Profile; size.MyTraining = training; day.AddEntry(size); insertToDatabase(day); RunServiceMethod(delegate(InternalBodyArchitectService Service) { var param = new DeleteTrainingDayParam(); param.TrainingDayId = day.GlobalId; param.Mode = DeleteTrainingDayMode.OnlyWithoutMyTraining; Service.DeleteTrainingDay(data.Token, param); }); Assert.AreEqual(1, Session.QueryOver <TrainingDay>().RowCount()); Assert.AreEqual(1, Session.QueryOver <SizeEntry>().RowCount()); }
public void DeleteTrainingDay_AnotherProfile() { var profile = (ProfileDTO)profiles[0].Tag; SessionData data = CreateNewSession(profile, ClientInformation); DateTime date = DateTime.Now.AddDays(-2); TrainingDayDTO day = new TrainingDayDTO(date); day.ProfileId = profile.GlobalId; SizeEntryDTO sizeEntry = new SizeEntryDTO(); sizeEntry.Wymiary = new WymiaryDTO(); sizeEntry.Wymiary.Height = 100; day.AddEntry(sizeEntry); SaveTrainingDayResult result = null; RunServiceMethod(delegate(InternalBodyArchitectService Service) { result = Service.SaveTrainingDay(data.Token, day); day = result.TrainingDay; }); data = CreateNewSession((ProfileDTO)profiles[1].Tag, ClientInformation); RunServiceMethod(delegate(InternalBodyArchitectService Service) { var param = new DeleteTrainingDayParam(); param.TrainingDayId = day.GlobalId; Service.DeleteTrainingDay(data.Token, param); }); }
//public TrainingPlan GetWorkoutPlan(Token token, Guid planId, RetrievingInfo retrievingInfo) //{ // var securityInfo = SecurityManager.EnsureAuthentication(token); // WorkoutPlanService service = new WorkoutPlanService(Session,securityInfo,Configuration); // return service.GetWorkoutPlan(planId, retrievingInfo); //} public void DeleteTrainingDay(Token token, DeleteTrainingDayParam param) { var securityInfo = SecurityManager.EnsureAuthentication(token); TrainingDayService service = new TrainingDayService(Session, securityInfo, Configuration, PushNotificationService, EMailService); service.DeleteTrainingDay(param); }
public void TestDeleteTrainingDay_LatestNotChanged() { var profile = (ProfileDTO)profiles[0].Tag; SessionData data = CreateNewSession(profile, ClientInformation); DateTime date = DateTime.Now.AddDays(-2); TrainingDayDTO day = new TrainingDayDTO(date); day.ProfileId = profile.GlobalId; SizeEntryDTO sizeEntry = new SizeEntryDTO(); sizeEntry.Wymiary = new WymiaryDTO(); sizeEntry.Wymiary.Height = 100; day.AddEntry(sizeEntry); SaveTrainingDayResult result = null; RunServiceMethod(delegate(InternalBodyArchitectService Service) { result = Service.SaveTrainingDay(data.Token, day); day = result.TrainingDay; }); date = DateTime.Now; var day1 = new TrainingDayDTO(DateTime.Now); day1.ProfileId = profile.GlobalId; sizeEntry = new SizeEntryDTO(); sizeEntry.Wymiary = new WymiaryDTO(); sizeEntry.Wymiary.Height = 100; day1.AddEntry(sizeEntry); RunServiceMethod(delegate(InternalBodyArchitectService Service) { result = Service.SaveTrainingDay(data.Token, day1); day1 = result.TrainingDay; }); var dbProfile = Session.Get <Profile>(profile.GlobalId); Assert.AreEqual(2, dbProfile.Statistics.TrainingDaysCount); Assert.AreEqual(date.Date, dbProfile.Statistics.LastEntryDate.Value); RunServiceMethod(delegate(InternalBodyArchitectService Service) { var param = new DeleteTrainingDayParam(); param.TrainingDayId = day.GlobalId; Service.DeleteTrainingDay(data.Token, param);; }); dbProfile = Session.Get <Profile>(profile.GlobalId); Assert.AreEqual(1, dbProfile.Statistics.TrainingDaysCount); Assert.AreEqual(date.Date, dbProfile.Statistics.LastEntryDate.Value); }
public void ExerciseProfileData_RemoveMaxWeightDay_LastEntryForExercise() { var profile = (ProfileDTO)profiles[0].Tag; SessionData data = CreateNewSession(profile, ClientInformation); var day = new TrainingDay(DateTime.Now.Date); day.Profile = profiles[0]; var exercise = CreateExercise(Session, null, "test", "t", ExerciseType.Nogi, MechanicsType.Isolation, ExerciseForceType.Pull); var entry = new StrengthTrainingEntry(); entry.MyPlace = GetDefaultMyPlace(profiles[0]); day.AddEntry(entry); var item = new StrengthTrainingItem(); item.Exercise = exercise; entry.AddEntry(item); var serie1 = new Serie("10x10"); item.AddSerie(serie1); var serie2 = new Serie("2x40"); item.AddSerie(serie2); var serie3 = new Serie("4x20"); item.AddSerie(serie3); insertToDatabase(day); ExerciseProfileData exData = new ExerciseProfileData(); exData.Exercise = exercise; exData.Profile = profiles[0]; exData.Serie = serie2; exData.MaxWeight = 40; exData.Repetitions = 2; exData.TrainingDate = day.TrainingDate; insertToDatabase(exData); RunServiceMethod(delegate(InternalBodyArchitectService Service) { DeleteTrainingDayParam param = new DeleteTrainingDayParam(); param.TrainingDayId = day.GlobalId; Service.DeleteTrainingDay(data.Token, param); }); exData = Session.QueryOver <ExerciseProfileData>().SingleOrDefault(); Assert.IsNull(exData); }
public static bool DeleteTrainingDay(TrainingDayDTO day, TrainingDayInfo dayInfo = null) { bool res = false; if (day != null && UIHelper.EnsurePremiumLicence()) { if (BAMessageBox.AskYesNo(Strings.QRemoveTrainingDay, day.TrainingDate.ToShortDateString()) == MessageBoxResult.Yes) { if (dayInfo != null) { dayInfo.IsProcessing = true; } PleaseWait.Run(delegate(MethodParameters par) { try { var param = new DeleteTrainingDayParam(); param.TrainingDayId = day.GlobalId; ServiceManager.DeleteTrainingDay(param); Guid?customerId = day.CustomerId; Guid?userId = day.ProfileId; var cache = TrainingDaysReposidory.GetCache(customerId, userId); cache.Remove(day.TrainingDate); res = true; } catch (TrainingIntegrationException te) { res = false; par.CloseProgressWindow(); ExceptionHandler.Default.Process(te, Strings.ErrorCannotDeleteTrainingDayPartOfTraining, ErrorWindow.MessageBox); } catch (Exception te) { res = false; par.CloseProgressWindow(); ExceptionHandler.Default.Process(te, Strings.ErrorRemoveTrainingDay, ErrorWindow.MessageBox); } finally { if (dayInfo != null) { dayInfo.IsProcessing = false; } } }); } } return(res); }
public void ForCustomer_DeleteTrainingDay_UpdateSize() { var profile = (ProfileDTO)profiles[0].Tag; SessionData data = CreateNewSession(profile, ClientInformation); TrainingDayDTO day = new TrainingDayDTO(DateTime.Now.AddDays(-2)); day.ProfileId = profile.GlobalId; day.CustomerId = customers[0].GlobalId; SizeEntryDTO entry = new SizeEntryDTO(); entry.Wymiary = new WymiaryDTO(); entry.Wymiary.Height = 100; day.AddEntry(entry); RunServiceMethod(delegate(InternalBodyArchitectService service) { service.SaveTrainingDay(data.Token, day); }); day = new TrainingDayDTO(DateTime.Now.AddDays(-1)); day.ProfileId = profile.GlobalId; day.CustomerId = customers[0].GlobalId; entry = new SizeEntryDTO(); entry.Wymiary = new WymiaryDTO(); entry.Wymiary.Height = 50; day.AddEntry(entry); RunServiceMethod(delegate(InternalBodyArchitectService service) { day = service.SaveTrainingDay(data.Token, day).TrainingDay; }); RunServiceMethod(delegate(InternalBodyArchitectService service) { var param = new DeleteTrainingDayParam(); param.TrainingDayId = day.GlobalId; service.DeleteTrainingDay(data.Token, param); }); var dbCustomer = Session.Get <Customer>(customers[0].GlobalId); Assert.AreEqual(100, dbCustomer.Wymiary.Height); }
public void DeleteTrainingDayWithTrainingEntry() { DateTime date = new DateTime(2012, 03, 26);//monday var cycle = new A6WTrainingDTO(); cycle.Name = "My A6W"; cycle.StartDate = date; var profile1 = (ProfileDTO)profiles[0].Tag; SessionData data = CreateNewSession(profile1, ClientInformation); MyTrainingDTO result = null; RunServiceMethod(delegate(InternalBodyArchitectService service) { var param = new MyTrainingOperationParam(); param.Operation = MyTrainingOperationType.Start; param.MyTraining = cycle; result = service.MyTrainingOperation(data.Token, param); }); var dbTrainingDay = Session.QueryOver <TrainingDay>().Fetch(x => x.Objects).Eager.Fetch(x => x.Objects.First().MyTraining).Eager.List(); for (int i = 0; i < 41; i++) { dbTrainingDay[i].Objects.ElementAt(0).Status = Model.EntryObjectStatus.Done; insertToDatabase(dbTrainingDay[i].Objects.ElementAt(0)); } var dtoTrainingDay = dbTrainingDay[40].Map <TrainingDayDTO>(); dtoTrainingDay.Objects.RemoveAt(0); RunServiceMethod(delegate(InternalBodyArchitectService service) { DeleteTrainingDayParam param = new DeleteTrainingDayParam(); param.TrainingDayId = dtoTrainingDay.GlobalId; param.Mode = DeleteTrainingDayMode.All; TimerService.UtcNow = DateTime.UtcNow.AddDays(3).Date; service.DeleteTrainingDay(data.Token, param); }); }
public void TestDeleteTrainingDay_DataInfo_Refresh() { var profile = (ProfileDTO)profiles[0].Tag; SessionData data = CreateNewSession(profile, ClientInformation); DateTime date = DateTime.Now.AddDays(-2); TrainingDayDTO day = new TrainingDayDTO(date); day.ProfileId = profile.GlobalId; SizeEntryDTO sizeEntry = new SizeEntryDTO(); sizeEntry.Wymiary = new WymiaryDTO(); sizeEntry.Wymiary.Height = 100; day.AddEntry(sizeEntry); SaveTrainingDayResult result = null; RunServiceMethod(delegate(InternalBodyArchitectService Service) { result = Service.SaveTrainingDay(data.Token, day); day = result.TrainingDay; }); var dbProfile = Session.Get <Profile>(profile.GlobalId); var oldHash = dbProfile.DataInfo.TrainingDayHash; RunServiceMethod(delegate(InternalBodyArchitectService Service) { TimerService.UtcNow = DateTime.UtcNow.AddHours(1); var param = new DeleteTrainingDayParam(); param.TrainingDayId = day.GlobalId; Service.DeleteTrainingDay(data.Token, param); }); dbProfile = Session.Get <Profile>(profile.GlobalId); Assert.AreNotEqual(oldHash, dbProfile.DataInfo.TrainingDayHash); }
//public TrainingPlan GetWorkoutPlan(Token token, Guid planId, RetrievingInfo retrievingInfo) //{ // return exceptionHandling(token, () => InternalService.GetWorkoutPlan(token, planId, retrievingInfo)); //} public void DeleteTrainingDay(Token token, DeleteTrainingDayParam dayDto) { exceptionHandling(token, () => InternalService.DeleteTrainingDay(token, dayDto)); }