public int CreateTask([FromBody] TaskInputModel model) { var existingTasksInCurrentQ = _db.Tasks.Where(t => t.QueueId == model.QueueId).ToList(); foreach (var existingTask in existingTasksInCurrentQ) { if (existingTask.Title == model.TaskTitle) { return(-1); } } var task = new Task { QueueId = model.QueueId, Title = model.TaskTitle, CreatorId = model.CreatorId, Status = model.Status }; _db.Tasks.Add(task); _db.SaveChanges(); return(task.Id); }
public void QueueAddOrSaveTask(TaskInputModel input) { Command command; var isNewTask = (input.TaskId == Guid.Empty); if (isNewTask) { command = new AddNewTaskCommand( input.Title, input.Description, input.DueDate, input.Priority, input.SignalrConnectionId); } else { command = new UpdateTaskCommand( input.TaskId, input.Title, input.Description, input.DueDate, input.Priority, input.Status, input.SignalrConnectionId); } Bus.Send(command); }
public void UpdateTask(UserTasksViewModel model, TaskInputModel inputModel) { var index = inputModel.Index; model.Tasks[index] = inputModel; if (index == model.EditTaskIndex) model.EditTaskIndex = -1; if (index == model.AddedTaskIndex) model.AddedTaskIndex = -1; }
public async Task <IActionResult> AddTask(int projectId, TaskInputModel inputModel) { if (!IsCurrentUserInProject(projectId)) { return(Unauthorized()); } if (!ModelState.IsValid) { inputModel.UserStoryDropDown = await this.userStoryService.GetUserStoryDropDownsAsync(projectId); return(View(inputModel)); } try { var inputDto = this.mapper.Map <TaskInputModelDto>(inputModel); inputDto.Description = inputModel.SanitizedDescription; inputDto.AcceptanceCriteria = inputModel.SanitizedDescription; await this.tasksService.CreateAsync(inputDto, projectId); return(RedirectToAction(nameof(GetAll), new { projectId = projectId })); } catch (Exception) { return(RedirectToAction("Error", "Error")); } }
public async Task <IActionResult> AddTask(int projectId, int userStoryId) { var inputModel = new TaskInputModel() { UserStoryId = userStoryId, UserStoryDropDown = await this.userStoryService.GetUserStoryDropDownsAsync(projectId), }; return(View(inputModel)); }
public IHttpActionResult CreateTask(int id, TaskInputModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _ticketsService.CreateNewTask(id, model); return(Ok()); }
public void QueueAddOrSaveTask(TaskInputModel input) { var command = new AddNewTaskCommand( input.Title, input.Description, input.DueDate, input.Priority, input.SignalrConnectionId); Bus.Send(command); }
public ActionResult AddTask([FromBody] TaskInputModel input) { try { _taskRepo.AddNewTask(input.Title, input.Username, input.CategoryName); return(StatusCode(200, Ok())); } catch (Exception e) { return(StatusCode(400, e.Message)); } }
private Task ToDomainModel(TaskInputModel taskGetReturn) { return(new Task { Id = taskGetReturn.Id, TaskName = taskGetReturn.TaskName, AssignedTo = taskGetReturn.AssignedTo, Assignedby = taskGetReturn.Assignedby, ProjectMembers = taskGetReturn.ProjectMembers, TaskDetails = taskGetReturn.TaskDetails }); }
public async Task AddTask(TaskInputModel task) { var newTask = new TodoTask { Title = task.Title, UserId = task.UserId, }; await this.dbContext.TodoTasks.AddAsync(newTask); await this.dbContext.SaveChangesAsync(); }
public ActionResult AddTask(TaskInputModel model, int id) { model.Requirements = HttpUtility.HtmlDecode(model.Requirements); if (!this.ModelState.IsValid) { return this.View(model); } var databaseCourseTask = this.Mapper.Map<CourseTask>(model); this.courseService.AddTask(databaseCourseTask, id); return this.RedirectToAction("Details", "Courses", new { id = id, area = "Public" }); }
/// <summary> /// Creates a new <see cref="Task"/> with the given information. /// </summary> /// <param name="model"></param> public void CreateNewTask(TaskInputModel model) { if (model == null) return; var task = new Task { Description = model.Description, Name = model.Name, Created = DateTime.Now }; TaskRepository.Add(task); }
public ActionResult Create(TaskInputModel model) { if (model != null && this.ModelState.IsValid) { var task = Mapper.Map<Task>(model); this.Data.Tasks.Add(task); this.Data.SaveChanges(); return this.RedirectToRoute("Default"); } this.LoadUsers(); return this.View(model); }
/// <summary> /// Creates a new <see cref="Task"/> with the given information. /// </summary> /// <param name="model"></param> public void CreateNewTask(TaskInputModel model) { if (model == null) { return; } var task = new Task { Description = model.Description, Name = model.Name, Created = DateTime.Now }; TaskRepository.Add(task); }
public ActionResult Save(TaskInputModel input) { // If it doesn't crash a serious bus has the message // in store and will eventually deliver it. // To update the UI, you should actually wait for // the operation to complete. It's only started here. try { _service.QueueAddOrSaveTask(input); } catch (Exception exception) { return(HandleException(exception)); } // Message delivered var response = new CommandResponse(true).SetPartial().AddMessage("Delivered"); return(Json(response)); }
public IActionResult Create([FromBody] TaskInputModel taskGetReturn) { if (taskGetReturn == null) { return(BadRequest()); } if (!ModelState.IsValid) { return(Unprocessable(ModelState)); } var taskset = ToDomainModel(taskGetReturn); service.AddTask(taskset); var taskSetReturn = ToOutputModel(taskset); return(CreatedAtRoute("GetTask", new { id = taskSetReturn.Id }, taskSetReturn)); }
public void QueueAddOrSaveTask(TaskInputModel input) { Command command; var isNewTask = (input.TaskId == Guid.Empty); int r = new Random().Next(10); if (r % 2 == 0) { SendCommand(new ErrorNotifyCommand(input.TaskId, "Ooopss!!", input.SignalrConnectionId)); return; } if (isNewTask) { command = new AddNewTaskCommand(input.Title, input.Description, input.DueDate, input.Priority, input.SignalrConnectionId); } else { command = new UpdateTaskCommand(input.TaskId, input.Title, input.Description, input.DueDate, input.Priority, input.Status, input.SignalrConnectionId); } SendCommand(command); }
public IActionResult Update(int id, [FromBody] TaskInputModel taskGetReturn) { if (taskGetReturn == null || id != taskGetReturn.Id) { return(BadRequest()); } if (!service.TaskExists(id)) { return(NotFound()); } if (!ModelState.IsValid) { return(new UnprocessableObjectResult(ModelState)); } var taskset = ToDomainModel(taskGetReturn); service.UpdateTask(taskset); return(NoContent()); }
public ActionResult New(TaskInputModel model) { TaskService.CreateNewTask(model); return(RedirectToAction("Index")); }
public UserTasksViewModel get_SaveTask(TaskInputModel inputModel) { return GetUserTasksViewModel(); }
public void CreateNewTask(int id, TaskInputModel model) { var command = new CreateTaskCommand(model.Title, model.Description, model.Status, model.AssignedTo, id); _bus.Send(command); }
public FubuContinuation post_SaveTask(TaskInputModel inputModel) { WithViewModel(x => _userTasksService.UpdateTask(x, inputModel)); return FubuContinuation.RedirectTo<TaskInputModel>("GET"); }
public ActionResult New(TaskInputModel model) { TaskService.CreateNewTask(model); return RedirectToAction("Index"); }
public IActionResult AddTask(TaskInputModel model) { this.taskService.AddTask(model); return(Ok()); }