public ActionResult Create(int managerId)
        {
            var humanTask = new HumanTask();
            humanTask.AssigneeId = (managerId != -1) ? managerId : (int?) null;
            humanTask.CreatorId = humanTask.AssigneeId;
            //TODO: creator pull from logon screen                

            humanTask.Created = DateTime.Now;
            return this.View(humanTask);
        }
        public ActionResult Create(HumanTask humanTask)
        {

            humanTask.Assigned = humanTask.AssigneeId == (int?) null ? humanTask.Created : (DateTime?) null;
            if (this.ModelState.IsValid)
            {
                this.taskProcessor.CreateTask(humanTask);
                return this.RedirectToAction("AllManagersWithTasks");
            }

            //TODO: refactor this "PossibleCreators" and "PossibleAssignees"
            this.ViewBag.PossibleCreators = new List<Employee>();
            this.ViewBag.PossibleAssignees = new List<Employee>();
            
            return this.View(humanTask);
        }
 /// <summary>
 /// The create task without reminder.
 /// </summary>
 /// <param name="task">The current task.</param>
 public void CreateTask(HumanTask task)
 {
     string date = task.Finished.HasValue ? task.Finished.Value.ToShortDateString() : "";
     this.humanTaskRepository.Add(task);
     if (task.Finished.HasValue && task.AssigneeId.HasValue)
     {
         Reminder reminder = new Reminder
         {
             ReminderDate = task.Finished.Value.AddDays(-1),
             Content = "You need to do '" + task.Name + "' task for " + date ,
             Task = task,
             TaskId = task.Id,
             UserId = task.AssigneeId.Value,
             WasDelivered = false,
             IsSend = true,
             User = userRepository.GetById(task.AssigneeId.Value)
         };
         reminderProcessor.AddReminder(reminder);
     }
 }
        /// <summary>
        /// The create task with reminder.
        /// </summary>
        /// <param name="task">The current task.</param>
        /// <param name="reminder">The reminder.</param>
        public void CreateTask(HumanTask task, Reminder reminder)
        {
            this.humanTaskRepository.Add(task);

            // task.Id got its value from database insert
            var newTaskId = task.Id;

            reminder.TaskId = newTaskId;

            this.reminderProcessor.AddReminder(reminder);
        }
        /// <summary>
        /// The update task with reminder.
        /// </summary>
        /// <param name="task">The current task.</param>
        /// <param name="reminder">The reminder.</param>
        public void UpdateTask(HumanTask task, Reminder reminder)
        {
            this.humanTaskRepository.Update(task);

            this.reminderProcessor.UpdateReminder(reminder);
        }
 /// <summary>
 /// The update task.
 /// </summary>
 /// <param name="task">The current task.</param>
 public void UpdateTask(HumanTask task)
 {
     this.humanTaskRepository.Update(task);
 }
        public ActionResult Edit(HumanTask humanTask)
        {
            if (this.ModelState.IsValid)
            {
                this.taskProcessor.UpdateTask(humanTask);
                return this.RedirectToAction("Index");
            }

            this.ViewBag.PossibleCreators = new List<Employee>();
            this.ViewBag.PossibleAssignees = new List<Employee>();
            return this.View(humanTask);
        }
        public void Should_UpdateTask_WhenTaskIsTheOnlyArgumentOfUpdate()
        {
            var testTask = new HumanTask { Id = 4, Name = "Fourth Task" };

            this.processorUnderTest.UpdateTask(testTask);

            this.mockHumanTaskRepository.Verify(it => it.Update(testTask), Times.Once());
        }
        public void CreateTask(LandingCreateTaskModel model)
        {
            var creatorId = this.userRepository.GetByName(User.Identity.Name).Id;

            var task = new HumanTask
            {
                Created = DateTime.Now,
                CreatorId = creatorId,
                Description = "",
                Name = model.Name,
                Priority = model.Priority,
                ProjectId = model.ProjectId,
                AssigneeId = model.AssigneeId,
                Finished = model.FinishDate,
                Assigned = model.AssigneeId != null ? DateTime.Now : (DateTime?)null 
            };
            this.taskProcessor.CreateTask(task);

            var taskHistory = new HumanTaskHistory
            {
                NewDescription = task.Description,
                ChangeDateTime = DateTime.Now,
                NewAssigneeId = task.AssigneeId,
                NewName = task.Name,
                Task = task,
                NewPriority = task.Priority,
                Action = ChangeHistoryTypes.Create,
                UserId = this.userRepository.GetByName(User.Identity.Name).Id
            };
            this.taskProcessor.AddHistory(taskHistory);
            this.notifier.CreateTask(task.Id);
            this.newsProcessor.CreateNewsForUsersInProject(taskHistory, task.ProjectId);
        }
 /// <summary>
 /// The quick task creation.
 /// </summary>
 /// <param name="humanTask">
 /// The human Task.
 /// </param>
 /// <returns>
 /// The System.Web.Mvc.ActionResult.
 /// </returns>
 public ActionResult QuickTaskCreation(HumanTask humanTask)
 {
     return this.PartialView("QuickTaskCreation", humanTask);
 }
        public ActionResult QuickTaskCreation(int projectId, string description)
        {
            var creatorId = this.userProcessor.GetUserByName(User.Identity.Name).Id;

            var task = new HumanTask
            {
                Created = DateTime.Now,
                CreatorId = creatorId,
                Description = description,
                Name = this.stringExtensions.Truncate(description, 15),
                Priority = 0,
                ProjectId = projectId,
            };
            this.taskProcessor.CreateTask(task);

            var taskHistory = new HumanTaskHistory
            {
                NewDescription = task.Description,
                ChangeDateTime = DateTime.Now,
                NewAssigneeId = task.AssigneeId,
                NewName = task.Name,
                Task = task,
                NewPriority = task.Priority,
                Action = ChangeHistoryTypes.Create,
                UserId = this.userProcessor.GetUserByName(User.Identity.Name).Id
            };
            this.taskProcessor.AddHistory(taskHistory);
            this.newsProcessor.CreateNewsForUsersInProject(taskHistory, task.ProjectId);

            this.notifier.CreateTask(task.Id);

            return this.RedirectToAction("Project", "Project", new { id = task.ProjectId });
        }
        public ActionResult CreateTask(CreateTaskViewModel createModel)
        {
            createModel.Assigned = createModel.AssigneeId == (int?)null ? createModel.Created : (DateTime?)null;
            if (this.ModelState.IsValid)
            {
                var task = new HumanTask
                {
                    Assigned = createModel.Assigned,
                    AssigneeId = createModel.AssigneeId,
                    Closed = createModel.Closed,
                    Finished = createModel.Finished,
                    Created = createModel.Created,
                    CreatorId = createModel.CreatorId,
                    Description = createModel.Description,
                    Id = createModel.Id,
                    Name = createModel.Name,
                    Priority = createModel.Priority,
                    ProjectId = createModel.ProjectId,
                    BlockingTaskId = createModel.BlockingTask
                };

                if (task.Priority == 3)
                {
                    task.AssigneeId = this.userProcessor.GetUserByTaskId(task.BlockingTaskId);
                    task.Assigned = task.AssigneeId == (int?)null ? task.Created : (DateTime?)null;
                }

                this.taskProcessor.CreateTask(task);

                var taskHistory = new HumanTaskHistory
                                      {
                                          NewDescription = task.Description,
                                          ChangeDateTime = DateTime.Now,
                                          NewAssigneeId = task.AssigneeId,
                                          NewName = task.Name,
                                          Task = task,
                                          NewPriority = task.Priority,
                                          Action = ChangeHistoryTypes.Create,
                                          UserId = this.userProcessor.GetUserByName(User.Identity.Name).Id
                                      };
                this.taskProcessor.AddHistory(taskHistory);
                this.notifier.CreateTask(task.Id);
                this.newsProcessor.CreateNewsForUsersInProject(taskHistory, task.ProjectId);

                if (true == createModel.ViewStyle)
                {
                    return this.RedirectToAction("MultiuserView", new { projectId = createModel.ProjectId, userId = createModel.AssigneeId });
                }

                return this.RedirectToAction("Project", new { id = createModel.ProjectId, userId = createModel.AssigneeId });
            }

            createModel.Priorities = taskProcessor.GetPrioritiesList();
            // TODO: refactor this "PossibleCreators" and "PossibleAssignees"
            this.ViewBag.PossibleCreators = new List<User>();
            this.ViewBag.PossibleAssignees = new List<User>();

            return this.View(createModel);
        }
        public ActionResult Create(CreateTaskViewModel createModel)
        {
            createModel.Assigned = createModel.AssigneeId == (int?)null ? createModel.Created : (DateTime?)null;
            if (this.ModelState.IsValid)
            {
                var task = new HumanTask
                               {
                                   Assigned = createModel.Assigned,
                                   AssigneeId = createModel.AssigneeId,
                                   Closed = createModel.Closed,
                                   Finished = createModel.Finished,
                                   Created = createModel.Created,
                                   CreatorId = createModel.CreatorId,
                                   Description = createModel.Description,
                                   Id = createModel.Id,
                                   Name = createModel.Name,
                                   Priority = createModel.Priority,
                                   ProjectId = 1,
                               };
                this.taskProcessor.CreateTask(task);
                this.taskProcessor.AddHistory(new HumanTaskHistory
                {
                    NewDescription = task.Description,
                    ChangeDateTime = DateTime.Now,
                    NewAssigneeId = task.AssigneeId,
                    NewName = task.Name,
                    Task = task,
                    NewPriority = task.Priority,
                });
                return this.RedirectToAction("AllManagersWithTasks");
            }
            createModel.Priorities = taskProcessor.GetPrioritiesList();
            // TODO: refactor this "PossibleCreators" and "PossibleAssignees"
            this.ViewBag.PossibleCreators = new List<User>();
            this.ViewBag.PossibleAssignees = new List<User>();

            return this.View(createModel);
        }
        public void Should_UpdateTaskAndReminder_WhenUpdateArgumentsAreTaskAndReminder()
        {
            var testTask = new HumanTask { Id = 4, Name = "Fourth Task" };
            var testReminder = new Reminder { Id = 2, TaskId = 4 };

            this.processorUnderTest.UpdateTask(testTask, testReminder);

            this.mockHumanTaskRepository.Verify(it => it.Update(testTask), Times.Once());
            this.mockReminderProcessor.Verify(it => it.UpdateReminder(testReminder), Times.Once());
        }
        /// <summary>
        /// The update.
        /// </summary>
        /// <param name="humanTask">
        /// The human task.
        /// </param>
        public void Update(HumanTask humanTask)
        {
            var task = dataBaseContext.Entry(humanTask).State = EntityState.Modified;

            //this.dataBaseContext.Entry(humanTask).State = EntityState.Modified;
            this.dataBaseContext.SaveChanges();
        }
 /// <summary>
 /// The add new human task.
 /// </summary>
 /// <param name="humanTask">
 /// The human task.
 /// </param>
 /// <returns>
 /// The BinaryStudio.TaskManager.Logic.Domain.HumanTask.
 /// </returns>
 public void Add(HumanTask humanTask)
 {
     this.dataBaseContext.Entry(humanTask).State = EntityState.Added;
     this.dataBaseContext.SaveChanges();
 }
        public void Should_AddTask()
        {
            var testTask = new HumanTask { Id = 4, Name = "Fourth Task" };

            this.processorUnderTest.CreateTask(testTask);
            this.mockHumanTaskRepository.Verify(it => it.Add(testTask), Times.Once());
        }