private bool Validate(CreateTaskView view) { return(view.Title != null || view.DueDate != null || view.Description != null || view.Participants().Count != 0 || view.Sectors().Count != 0); }
public IHttpResponse Create(CreateTaskView view) { var task = this.taskService.AddTask(view); if (task == null) { return(BadRequestErrorWithView("Incorect task data!")); } return(this.Redirect($"/Tasks/Details?id={task.Id}")); }
public Task AddTask(CreateTaskView view) { if (!Validate(view)) { return(null); } var participants = this.cotnext.Users .Where(u => view.Participants().Contains(u.Username)) .ToList(); if (participants.Count != view.Participants().Count) { return(null); } var taskUsers = new List <TaskUsers>(); foreach (var user in participants) { taskUsers.Add(new TaskUsers { UserId = user.Id }); } var sectors = view.Sectors().Select(s => Enum.Parse <Sector>(s)); var taskSectors = new List <TaskSectors>(); foreach (var sector in sectors) { taskSectors.Add(new TaskSectors { Sector = sector }); } var task = new Task { Title = view.Title, DueDate = view.DueDate, Description = view.Description, Participants = taskUsers, AffectedSectors = taskSectors }; this.cotnext.Tasks.Add(task); this.cotnext.SaveChanges(); return(task); }
public void Get_Binding_When_Both_Binding_Mechansims_Used() { // Arrange var strategy = new ConventionBasedPresenterDiscoveryStrategy(); IView<CreateTaskModel> createTaskView = new CreateTaskView(); //Act var actualBinding = strategy.GetBinding(createTaskView); // Assert Assert.IsTrue(actualBinding.Bindings.Any()); Assert.IsTrue(actualBinding.Bindings.First().PresenterType == typeof(CreateTaskPresenter)); }
public void Get_Binding_When_Both_Binding_Mechansims_Used() { // Arrange var strategy = new ConventionBasedPresenterDiscoveryStrategy(); IView <CreateTaskModel> createTaskView = new CreateTaskView(); //Act var actualBinding = strategy.GetBinding(createTaskView); // Assert Assert.IsTrue(actualBinding.Bindings.Any()); Assert.IsTrue(actualBinding.Bindings.First().PresenterType == typeof(CreateTaskPresenter)); }
public string CreateTask(CreateTaskView newTask) { string author = User.Identity.Name; if (newTask.TemplateId.HasValue) { try { templateSubtasksService.AddSubtasksFromTemplate(newTask.ParentId.Value, newTask.TemplateId.Value, author); } catch (Exception e) { return("Error. Task wasn't created" + e.Message); } return("Task was created"); } var task = new TaskView { ParentId = newTask.ParentId, Name = newTask.Name, Comment = newTask.Comment }; try { if (!newTask.ParentId.HasValue) { taskService.CreateTask(mapper.Map <TaskView, TaskBLL>(task), author, newTask.Assignee); } else { subtaskService.AddSubtask(mapper.Map <TaskView, TaskBLL>(task), task.ParentId.Value); } } catch (Exception e) { return("Task wasn't created. Error: " + e.Message); } return("Task was created"); }
public void EditTask(Task task) { CreateTaskView createTaskView = new CreateTaskView(task); createTaskView.ShowDialog(); }
public void CreateNewTask() { CreateTaskView createTaskView = new CreateTaskView(); createTaskView.ShowDialog(); }
public CreateTaskPage(CreateTaskView view) { InitializeComponent(); this.BindingContext = view; }