Ejemplo n.º 1
0
        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; }

            });
        }
Ejemplo n.º 2
0
        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;
            });
        }
Ejemplo n.º 3
0
        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);
        }