public ActionResult EditTime(int?taskId, int?id)
        {
            if (AuthenticationManager.LoggedUser == null)
            {
                return(RedirectToAction("Login", "Home"));
            }

            TimesRepository timesRepository = new TimesRepository(new TaskManagerDb());

            Time time = null;

            if (id == null)
            {
                time           = new Time();
                time.DateTaken = DateTime.Now;
                time.TaskId    = taskId.Value;
                time.UserId    = AuthenticationManager.LoggedUser.Id;
            }
            else
            {
                time = timesRepository.GetById(id.Value);
            }

            ViewData["times"] = time;

            return(View());
        }
        public ActionResult DeleteTime(int id)
        {
            if (AuthenticationManager.LoggedUser == null)
            {
                return(RedirectToAction("Login", "Home"));
            }

            TimesRepository timesRepository = new TimesRepository(new TaskManagerDb());
            Time            time            = timesRepository.GetById(id);

            timesRepository.Delete(time);

            return(RedirectToAction("TaskDetails", "TasksManager", new { id = time.TaskId }));
        }
        public ActionResult EditTime(Time time)
        {
            if (AuthenticationManager.LoggedUser == null)
            {
                return(RedirectToAction("Login", "Home"));
            }

            time.DateTaken = DateTime.Now;

            TimesRepository timesRepository = new TimesRepository(new TaskManagerDb());

            timesRepository.Save(time);

            return(RedirectToAction("TaskDetails", "TasksManager", new { id = time.TaskId }));
        }
        public ActionResult TaskDetails(int id)
        {
            if (AuthenticationManager.LoggedUser == null)
            {
                return(RedirectToAction("Login", "Home"));
            }

            TasksRepository    tasksRepository    = new TasksRepository(new TaskManagerDb());
            TimesRepository    timesRepository    = new TimesRepository(new TaskManagerDb());
            CommentsRepository commentsRepository = new CommentsRepository(new TaskManagerDb());

            var times = timesRepository.GetAll();

            if (times != null)
            {
                ViewData["times"] = times.Where(i => i.TaskId == id).ToList();
            }
            else
            {
                ViewData["times"] = times;
            }

            var comments = commentsRepository.GetAll();

            if (comments != null)
            {
                ViewData["comments"] = comments.Where(c => c.TaskId == id).ToList();
            }
            else
            {
                ViewData["comments"] = comments;
            }

            ViewData["task"] = tasksRepository.GetById(id);

            return(View());
        }
 public TimesController(TimesRepository timesRepository)
 {
     this.timesRepository = timesRepository;
 }