public void Should_AddCorrectNews_WithHumanTaskHistoryAsParametr() { // arrange User user = new User { UserName = "******", Id = 2 }; HumanTaskHistory taskHistory = new HumanTaskHistory { Id = 1, Action = "Create", }; News news = new News { HumanTaskHistory = taskHistory, HumanTaskHistoryId = taskHistory.Id, Id = 1, IsRead = false, User = user, UserId = user.Id }; // act this.newsProcessor.AddNews(taskHistory, user); // assert this.newsRepositoryMock.Verify(mock => mock.AddNews(It.Is<News>(x => x.HumanTaskHistoryId == taskHistory.Id && x.UserId == user.Id && x.User == user && x.HumanTaskHistory == taskHistory)), Times.Once()); }
public void CreateNewsForUsersInProject(HumanTaskHistory taskHistory, int projectId) { var projectUsers = new List<User>(this.projectProcessor.GetUsersAndCreatorInProject(projectId)); foreach (var projectUser in projectUsers) { this.AddNews(taskHistory, projectUser); } if (taskHistory.NewAssigneeId.HasValue) { this.notifier.BroadcastNewsToDesktopClient(taskHistory); } }
public void AddNews(HumanTaskHistory taskHistory, User user) { var news = new News { HumanTaskHistory = taskHistory, IsRead = false, User = user, UserId = user.Id, HumanTaskHistoryId = taskHistory.Id, }; this.AddNews(news); }
public void AddHistory(HumanTaskHistory humanTaskHistory) { this.dataBaseContext.Entry(humanTaskHistory).State = EntityState.Added; this.dataBaseContext.SaveChanges(); }
/// <summary> /// Adds the history. /// </summary> /// <param name="newHumanTask">The new human task.</param> public void AddHistory(HumanTaskHistory newHumanTask) { this.humanTaskRepository.AddHistory(newHumanTask); }
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); }
public void Should_CreateNewsForUsers() { // arrange User creator = new User{UserName = "******", Id = 1}; User collaborator = new User { UserName = "******", Id = 2 }; this.projectProcessorMock.Setup(it => it.GetUsersAndCreatorInProject(1)).Returns(value: new List<User> {creator, collaborator}); HumanTaskHistory taskHistory = new HumanTaskHistory { Id = 1, Action = "Create" }; // act this.newsProcessor.CreateNewsForUsersInProject(taskHistory,1); // assert this.newsRepositoryMock.Verify(it => it.AddNews(It.IsAny<News>()), Times.Exactly(2)); }
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 }); }
/// <summary> /// The make task close. /// </summary> /// <param name="taskId"> /// The task id. /// </param> /// <param name="projectId"> /// The project id. /// </param> public void MakeTaskClose(int taskId, int projectId) { this.taskProcessor.CloseTask(taskId); HumanTask humanTask = this.taskProcessor.GetTaskById(taskId); HumanTaskHistory humanTaskHistory = new HumanTaskHistory { Action = ChangeHistoryTypes.Close, ChangeDateTime = DateTime.Now, NewAssigneeId = humanTask.AssigneeId, UserId = this.userProcessor.GetUserByName(User.Identity.Name).Id, NewDescription = humanTask.Description, NewPriority = humanTask.Priority, NewName = humanTask.Name, Task = humanTask, TaskId = taskId }; taskProcessor.AddHistory(humanTaskHistory); this.newsProcessor.CreateNewsForUsersInProject(humanTaskHistory, humanTask.ProjectId); }
public ActionResult Edit(CreateTaskViewModel createModel) { if (this.ModelState.IsValid) { var humanTask = this.taskProcessor.GetTaskById(createModel.Id); humanTask.Name = createModel.Name; humanTask.Priority = createModel.Priority; humanTask.Finished = createModel.Finished; humanTask.Description = createModel.Description; this.taskProcessor.UpdateTask(humanTask); var taskHistory = new HumanTaskHistory { NewDescription = createModel.Description, ChangeDateTime = DateTime.Now, NewAssigneeId = createModel.AssigneeId, NewName = createModel.Name, Task = humanTask, TaskId = humanTask.Id, NewPriority = createModel.Priority, Action = ChangeHistoryTypes.Change, UserId = this.userProcessor.GetUserByName(User.Identity.Name).Id }; this.taskProcessor.AddHistory(taskHistory); this.newsProcessor.CreateNewsForUsersInProject(taskHistory, humanTask.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 }); } return this.View(createModel); }
public void MoveTask(int taskId, int senderId, int receiverId, int projectId) { HumanTask humanTask = taskProcessor.GetTaskById(taskId); HumanTaskHistory humanTaskHistory = new HumanTaskHistory { Action = ChangeHistoryTypes.Move, ChangeDateTime = DateTime.Now, NewAssigneeId = receiverId == -1 ? (int?)null : receiverId, //??????????????????? UserId = this.userProcessor.GetUserByName(User.Identity.Name).Id, NewDescription = humanTask.Description, NewPriority = humanTask.Priority, NewName = humanTask.Name, Task = humanTask, TaskId = taskId }; taskProcessor.AddHistory(humanTaskHistory); this.newsProcessor.CreateNewsForUsersInProject(humanTaskHistory,humanTask.ProjectId); if (receiverId != -1) { this.taskProcessor.MoveTask(taskId, receiverId); } else { this.taskProcessor.MoveTaskToUnassigned(taskId); } var taskReminders = this.reminderProcessor.GetRemindersForTask(taskId).ToList(); if (taskReminders != null) { foreach (var taskReminder in taskReminders) { taskReminder.UserId = receiverId > 0 ? receiverId : -1; this.reminderProcessor.UpdateReminder(taskReminder); } } this.notifier.MoveTask(humanTask, receiverId); }
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); }