public ReminderItemDTO ReminderOperation(Token token, ReminderOperationParam remindersParam) { var securityInfo = SecurityManager.EnsureAuthentication(token); var service = new ReminderService(Session, securityInfo, Configuration); return(service.ReminderOperation(remindersParam)); }
public void Delete_ReminderAttachedTOEntryObject() { var reminder = CreateReminder("test", profiles[0], DateTime.UtcNow, type: ReminderType.EntryObject); TrainingDay day = new TrainingDay(DateTime.Now.Date); day.Profile = profiles[0]; SizeEntry sizeEntry = new SizeEntry(); sizeEntry.Wymiary = new Wymiary(); sizeEntry.Reminder = reminder; sizeEntry.Wymiary.Height = 100; day.AddEntry(sizeEntry); insertToDatabase(day); reminder.ConnectedObject = "EntryObjectDTO:" + sizeEntry.GlobalId; insertToDatabase(reminder); var profile = (ProfileDTO)profiles[0].Tag; SessionData data = CreateNewSession(profile, ClientInformation); RunServiceMethod(delegate(InternalBodyArchitectService service) { ReminderOperationParam param = new ReminderOperationParam(); param.Operation = ReminderOperationType.Delete; param.ReminderItemId = reminder.GlobalId; var result = service.ReminderOperation(data.Token, param); Assert.IsNull(result); }); Assert.AreEqual(0, Session.QueryOver <ReminderItem>().RowCount()); }
public void Delete_OneTimeReminder_AnotherProfile() { var reminder = CreateReminder("test", profiles[1], DateTime.UtcNow, null); var profile = (ProfileDTO)profiles[0].Tag; SessionData data = CreateNewSession(profile, ClientInformation); RunServiceMethod(delegate(InternalBodyArchitectService service) { ReminderOperationParam param = new ReminderOperationParam(); param.Operation = ReminderOperationType.Delete; param.ReminderItemId = reminder.GlobalId; service.ReminderOperation(data.Token, param); }); }
public void Delete_OneTimeReminder() { var reminder = CreateReminder("test", profiles[0], DateTime.UtcNow, null); var profile = (ProfileDTO)profiles[0].Tag; SessionData data = CreateNewSession(profile, ClientInformation); RunServiceMethod(delegate(InternalBodyArchitectService service) { ReminderOperationParam param = new ReminderOperationParam(); param.Operation = ReminderOperationType.Delete; param.ReminderItemId = reminder.GlobalId; var result = service.ReminderOperation(data.Token, param); Assert.IsNull(result); }); Assert.AreEqual(0, Session.QueryOver <ReminderItem>().RowCount()); }
public void Delete_DataInfo() { var reminder = CreateReminder("test", profiles[0], DateTime.UtcNow, null); var oldHash = profiles[0].DataInfo.ReminderHash; var profile = (ProfileDTO)profiles[0].Tag; SessionData data = CreateNewSession(profile, ClientInformation); RunServiceMethod(delegate(InternalBodyArchitectService service) { ReminderOperationParam param = new ReminderOperationParam(); param.Operation = ReminderOperationType.Delete; param.ReminderItemId = reminder.GlobalId; service.ReminderOperation(data.Token, param); }); var dbItem = Session.Get <Profile>(profile.GlobalId); Assert.AreNotEqual(oldHash, dbItem.DataInfo.ReminderHash); }
public void CloseAfterShow_PatternReminder_DataInfo() { var reminder = CreateReminder("test", profiles[0], DateTime.UtcNow, null, ReminderRepetitions.EveryYear); var oldHash = profiles[0].DataInfo.ReminderHash; var profile = (ProfileDTO)profiles[0].Tag; SessionData data = CreateNewSession(profile, ClientInformation); RunServiceMethod(delegate(InternalBodyArchitectService service) { TimerService.UtcNow = DateTime.UtcNow.AddDays(1).Date; ReminderOperationParam param = new ReminderOperationParam(); param.Operation = ReminderOperationType.CloseAfterShow; param.ReminderItemId = reminder.GlobalId; service.ReminderOperation(data.Token, param); }); var dbItem = Session.Get <Profile>(profile.GlobalId); Assert.AreEqual(oldHash, dbItem.DataInfo.ReminderHash); }
public void CloseAfterShow_PatternReminder() { var reminder = CreateReminder("test", profiles[0], DateTime.UtcNow, null, ReminderRepetitions.EveryYear); var profile = (ProfileDTO)profiles[0].Tag; SessionData data = CreateNewSession(profile, ClientInformation); RunServiceMethod(delegate(InternalBodyArchitectService service) { TimerService.UtcNow = DateTime.UtcNow.AddDays(1).Date; ReminderOperationParam param = new ReminderOperationParam(); param.Operation = ReminderOperationType.CloseAfterShow; param.ReminderItemId = reminder.GlobalId; var result = service.ReminderOperation(data.Token, param); Assert.IsNotNull(result); Assert.AreEqual(reminder.GlobalId, result.GlobalId); Assert.AreEqual(DateTime.UtcNow.AddDays(1).Date, result.LastShown.Value.Date); }); var db = Session.QueryOver <ReminderItem>().SingleOrDefault(); Assert.AreEqual(DateTime.UtcNow.AddDays(1).Date, db.LastShown.Value); }
public void Delete() { if (SelectedReminder != null && SelectedReminder.Type == ReminderType.Custom && BAMessageBox.AskYesNo("RemindersViewModel_Delete_DeleteReminder".TranslateInstructor(), SelectedReminder.Name) == MessageBoxResult.Yes) { PleaseWait.Run(delegate { try { var param = new ReminderOperationParam(); param.ReminderItemId = SelectedReminder.GlobalId; param.Operation = ReminderOperationType.Delete; ServiceManager.ReminderOperation(param); ReminderItemsReposidory.Instance.Remove(SelectedReminder.GlobalId); parentView.SynchronizationContext.Send((x) => NotifyOfPropertyChange(() => Reminders), null); } catch (Exception ex) { parentView.SynchronizationContext.Send((x) => ExceptionHandler.Default.Process(ex, "RemindersViewModel_Delete_CannotRemoveReminder".TranslateInstructor(), ErrorWindow.EMailReport), null); } }); } }
public void Execute() { try { ReminderOperationParam param = new ReminderOperationParam(); param.Operation = operation; param.ReminderItemId = reminder.GlobalId; var temp = ServiceManager.ReminderOperation(param); if (temp == null) { ReminderItemsReposidory.Instance.Remove(reminder.GlobalId); } else { //ReminderItemsReposidory.Instance.Update(temp); } } catch (Exception ex) { ExceptionHandler.Default.Process(ex); } }
public ReminderItemDTO ReminderOperation(ReminderOperationParam remindersParam) { ReminderItemDTO res = null; using (var tx = Session.BeginSaveTransaction()) { //DateTime now = Configuration.TimerService.UtcNow; Profile dbProfile = Session.Load <Profile>(SecurityInfo.SessionData.Profile.GlobalId); var dbReminder = Session.Get <ReminderItem>(remindersParam.ReminderItemId); if (dbReminder.Profile != dbProfile) { throw new CrossProfileOperationException("Cannot change reminder from another user"); } if (remindersParam.Operation == ReminderOperationType.Delete) { deleteReminder(dbReminder, true); } else if (remindersParam.Operation == ReminderOperationType.CloseAfterShow) { if (dbReminder.Repetitions == ReminderRepetitions.Once) { deleteReminder(dbReminder, true); } else { dbReminder.LastShown = Configuration.TimerService.UtcNow; Session.Update(dbReminder); res = dbReminder.Map <ReminderItemDTO>(); } } tx.Commit(); return(res); } }
public ReminderItemDTO ReminderOperation(Token token, ReminderOperationParam remindersParam) { return(exceptionHandling(token, () => InternalService.ReminderOperation(token, remindersParam))); }