public JsonResponse<bool> Put(int folderId, int activityId) { return new JsonResponse<bool>(Request, () => { Activity activity = new Activity(); activity = _activityUnitOfWork.ActivityRepository.GetByID(activityId); if (activity != null) { _activityUnitOfWork.ActivityRepository.Update(activity); _activityUnitOfWork.Save(); return true; } else { return false; } }); }
public JsonResponse<bool> UpdateCompleted(int folderId, int activityId, bool complete) { return new JsonResponse<bool>(Request, () => { var folder = _activityUnitOfWork.ActivityRepository.Get(a => a.FolderId == folderId); if (folder != null) { Activity activity = new Activity(); activity = _activityUnitOfWork.ActivityRepository.GetByID(activityId); if (activity != null) { _activityUnitOfWork.ActivityRepository.Update(activity); _activityUnitOfWork.Save(); return true; } else { return false; } } return false; }); }
public void StartToEndFlow() { var unitOfWork = new ActivityUnitOfWork(); var repo = unitOfWork.ActivityRepository; var at = new ActivityTime(); var act = new Activity() { Name = "test", DueDate = DateTimeOffset.Now.AddHours(2), CompletedAt = DateTime.Now, //act.ActivityTimes.StartDate = DateTimeOffset.Now.AddHours(10), }; at.EndDate = DateTimeOffset.Now; repo.Insert(act); unitOfWork.Save(); var startedActivityTime = unitOfWork.StartActivity(act.Id); Assert.IsNotNull(startedActivityTime); Assert.IsTrue(DateTimeOffset.Now > startedActivityTime.StartDate); //var endedActivityTime = repo.EndActivity(act.Id); //repo.SaveChanges(); // Assert.IsNotNull(endedActivityTime); //Assert.IsNull(endedActivityTime); // Assert.IsNotNull(endedActivityTime.EndDate); // Assert.IsTrue(DateTimeOffset.Now > startedActivityTime.EndDate); // Assert.AreEqual(startedActivityTime.StartDate, endedActivityTime.StartDate); }