public async Task <IActionResult> PostAsync([FromBody] TaskModel task) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (await _service.ExistsAsync(task.Id)) { await _service.UpdateAsync(task); _logger.LogDebug($"UpdateAsync with Name:'{task.Name}' successful."); await _service.SaveAsync(); return(Ok(task)); } else { Guid createdTaskId = _service.Add(task); task.Id = createdTaskId; _logger.LogDebug($"Add with Name:'{task.Name}' successful."); await _service.SaveAsync(); return(CreatedAtAction(nameof(GetByIdAsync), new { id = createdTaskId }, task)); } } catch (Exception ex) { _logger.LogError(ex, ex.Message); return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public IActionResult Task(Task task) { var userId = User.GetUserId(); task.UserId = userId; if (!ModelState.IsValid) { var vm = new TaskViewModel() { Task = task, Categories = _categoryService.GetCategories(userId), Heading = task.Id == 0 ? "nowe zadanie" : "edycja zadania" }; return(View("Task", vm)); } if (task.Id == 0) { _taskService.Add(task); } else { _taskService.Update(task); } return(RedirectToAction("Tasks", "Task")); }
private void OnConfirmKryptonButtonClickedEventRaised(object sender, EventArgs e) { try { string eventCalendar = _addEventView.EventCalendar; Event myEvent = new Event { Summary = _addEventView.EventDescription, Location = _addEventView.EventLocation, Start = _addEventView.EventStartTime, End = _addEventView.EventEndTime, }; _taskService.Add(eventCalendar, myEvent); _addEventView.CloseWindow(); } catch (InvalidEventDataException ex) { _errorMessageView.ShowErrorMessageView("Error", ex.Message); } catch (Exception ex) { _errorMessageView.ShowErrorMessageView("Error", ex.Message); } }
public IActionResult Create(Entities.Concrete.Task task) { CreateEditTaskViewModel model = null; try { model = new CreateEditTaskViewModel { Task = task, TaskTypes = _taskTypeManager.GetAll(), UserId = User.Identity.UserId(), }; _taskManager.Add(task); return(RedirectToAction(nameof(Index))); } catch (ValidationException ex) { ModelState.AddModelError("Error", ex.Message); return(View(model)); } catch (Exception ex) { _logger.LogError(ex.Message); return(Error()); } }
public TaskEntity Add([FromBody] TaskDto taskDto, int idProject, int idJalon) { TaskEntity task = new TaskEntity() { AssigneeId = taskDto.AssigneeId, Label = taskDto.Label, PlannedStartDate = taskDto.PlannedStartDate, PlannedEndDate = taskDto.PlannedStartDate.AddDays(taskDto.Cost), RealStartDate = taskDto.RealStartDate, RealEndDate = taskDto.RealEndDate, Cost = taskDto.Cost, Description = taskDto.Description, Exigences = taskDto.Exigences, JalonId = idJalon, RequiredTask = taskDto.RequiredTaskId, }; UrlConfig config = new UrlConfig() { IdProject = idProject, IdJalon = idJalon }; return(_TaskService.Add(task, config)); }
public async Task <IActionResult> Create(TaskCreateViewModel vm) { try { if (ModelState.IsValid) { UserTask task = new UserTask() { Id = vm.Id, Name = vm.Name }; await _taskService.Add(task); return(RedirectToAction("Index")); } } catch (DbUpdateException /* ex */) { //Log the error (uncomment ex variable name and write a log. ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists " + "see your system administrator."); } return(View(vm)); }
// POST: api/Task public int Post(TaskModel value) { if (value == null) { return(0); } try { var task = taskService.Add(new TaskDO() { EndDate = value.EndDate, IsParentTask = value.IsParentTask, ParentTask = value.ParentTask, Priority = value.Priority, ProjectID = value.ProjectID, StartDate = value.StartDate, Status = value.Status, Task = value.TaskName, TaskId = value.TaskId, TaskOwner = value.TaskOwner }); return(task); } catch { return(0); } }
public TaskDTO Add(TaskDTO taskDTO) { var task = _taskMapper.MapperToEntity(taskDTO); task.SetTodoList(_todoListService.Get(taskDTO.TodoList.Id)); task.SetUser(_userService.Get(taskDTO.User.Id)); return(_taskMapper.MapperToDTO(_taskService.Add(task))); }
public void Should_Add_Task() { var task = new Task() { Title = "unit_test_task_titl5", Description = "test test test", IsCompleted = false, StartingDate = DateTime.Now, TypeId = 1, UserId = 8 }; _taskManager.Add(task); bool result = _taskManager.GetAll(task.UserId) .Any(t => t.Title == task.Title && t.TypeId == task.TypeId && t.Description == task.Description &&t.StartingDate.Date == task.StartingDate.Date); Assert.True(result); }
public IActionResult Post([FromBody] Tasked task) { if (_taskService.Add(task) > 0) { return(Ok(new { status = true, Data = task, Message = "Save Success!" })); } return(Ok(new { status = false, Data = (string)null, Message = "Error Success!" })); }
public IActionResult Create([Bind("Title,Description")] ApplicationCore.Entity.Task task) { if (ModelState.IsValid) { _taskService.Add(task); return(RedirectToAction(nameof(Index))); } return(View(task)); }
public ActionResult CreateTask([FromBody] AddProjectTaskDto task) { if (task == null) { return(BadRequest()); } var addedTask = _taskService.Add(task); return(CreatedAtAction("CreateTask", new { id = addedTask.Id }, addedTask)); }
public IActionResult Create([FromForm] TaskDTO item) { if (ModelState.IsValid) { _TaskService.Add(item); return(RedirectToAction(nameof(Index))); } ConfigureViewData(); return(View(item)); }
public IActionResult Post([FromBody] TaskDTO taskDTO) { if (TaskExists(taskDTO.Id)) { return(BadRequest()); } _TaskService.Add(taskDTO); return(Ok(taskDTO)); }
public ActionResult PostTask(eSektorEntities.Task tsk) { var user = User.Identity.Name; var member = _ms.GetMemberByUsername(user); tsk.TaskId = Guid.NewGuid(); tsk.MemberId = member.Data.MemberId;//olmzssa bu atamayı view de yap var result = _ts.Add(tsk); ViewBag.Sonuc = result.Message; ViewBag.SonucDurumu = result.State; return(View(tsk)); }
public IHttpActionResult Post([FromBody] NewTaskDTO dto) { if (dto == null) { return(BadRequest()); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _service.Add(dto); return(Ok("")); }
public async Task <IActionResult> New([FromBody] string description) { try { var id = await _service.Add(description); return(Ok(id)); } catch (Exception error) { return(BadRequest(error.Message)); } }
public ActionResult Create(TaskViewModel task) { if (!User.IsInRole("Master")) { task.UserID = GetUserIdentityID(); } try { if (ModelState.IsValid) { //valida se usuário possui outras tarefas em produção. bool userTasksInProduction = this.validateUserTasksInProduction(task.UserID, (Enums.EnumTaskStatus)task.StatusID); if (userTasksInProduction) { ModelState.AddModelError("", "Cada usuário só pode ter uma tarefa [Em produção] por vez."); } //validação para UserID não consta na ViewModel. else if (!task.UserID.HasValue) { ModelState.AddModelError("UserID", "Preencha o campo usuário."); } else { var newTask = Mapper.Map <TaskViewModel, TB_Task>(task); _taskService.Add(newTask); return(RedirectToAction("Index")); } } } catch (Exception ex) { ModelState.AddModelError("", "Erro ao criar tarefa. ERRO: " + ex.Message); } if (User.IsInRole("Master")) { ViewBag.UserID = new SelectList(_userService.GetAll(), "ID", "Name", task.UserID); } else { ViewBag.UserID = GetUserIdentityID().ToString(); } ViewBag.StatusID = new SelectList(_taskStatusService.GetAll(), "ID", "Status", task.StatusID); return(View(task)); }
public ActionResult Create([Bind(Exclude = "User")] TaskMetadata task) { var identity = User.Identity.Name; User user = userService.FindByEmail(identity); task.User = user; task.UserID = user.UserID; taskService.Add(task); return(RedirectToAction("Index")); }
public IActionResult AddTask(TaskAddDto model) { if (ModelState.IsValid) { var entity = _mapper.Map <TaskEntity>(model); _taskService.Add(entity); return(RedirectToAction("Index")); } else { ViewBag.Urgencies = new SelectList(_urgencyService.GetAll(), "Id", "Description"); } return(View(model)); }
private void AddClicked(object sender, RoutedEventArgs e) { if (isValidValues()) { if (tasksList.SelectedItem.ToString().Equals("Cleaning")) { roomService.UpdateStatus("Unclean", roomService.Find((int)roomsList.SelectedItem)); } var task = taskService.CreateTask(tasksList.SelectedItem.ToString(), (int)roomsList.SelectedItem, description.Text); taskService.Add(task); this.Close(); } }
public IActionResult Create(TaskModel model) { if (ModelState.IsValid) { var entity = mapper.Map <Tasks>(model); entity.UserID = GetUserID(); service.Add(entity); return(View("Index")); } else { return(View(model)); } }
public void Add() { Task task = new Task { Details = "Test details", EstimatedDate = DateTime.Now, Notes = "Test notes", ProjectId = 1, TaskStateId = 4 }; var result = _taskService.Add(task); Assert.AreEqual(true, result.IsSuccessful); }
public ActionResult Index(TaskModel model) { var result = _taskService.Add(model); if (result != 0) { TempData["recordStatus"] = true; } else { TempData["recordStatus"] = false; } return(RedirectToAction("index")); }
public IActionResult AddTask(TaskAddViewModel model) { TempData["active"] = "task"; if (ModelState.IsValid) { _taskService.Add(new Task_Entity { Description = model.Description, Name = model.Name, UrgencyId = model.UrgencyId }); return(RedirectToAction("index")); } return(View(model)); }
public ActionResult Save([FromBody] TaskModel item) { try { var task = _mapper.Map <TaskItem>(item); var result = _service.Add(task); return(Ok(result)); } catch (Exception e) { Console.WriteLine(e); } return(BadRequest()); }
public IActionResult Post([FromBody] TaskModel task) { var addedTask = _service.Add(new Business.Service.DTOs.Task.TaskDto { Title = task.Title, StateId = task.StateId }); if (addedTask == null) { return(UnprocessableEntity()); } return(Created(new Uri($"{Request.Scheme}://{Request.Host}{Request.Path}/{addedTask.Id}"), addedTask)); }
public void TaskServiceShouldAddNewTask() { var _newTask = new Task() { Title = "Test Task 12", CreateDate = DateTime.Parse("2019-09-25"), Description = "description of test task 12", StaffNo = 1001 }; int maxTaskNo = _tasks.Max(t => t.TaskNo); _newTask.TaskNo = maxTaskNo + 1; _taskService.Add(_newTask); Assert.That(_newTask, Is.EqualTo(_tasks.Last())); }
public async Task <IActionResult> Add(TaskDto dto) { var terminal = await terminalService.Find(x => x.Sim == dto.SimNumber); dto.Terminals = new List <TerminalDto> { new TerminalDto { Id = terminal.Id } }; var result = await currentservice.Add(dto) > 0; return(Ok(new JsonResultDto <bool> { Data = result, Message = result ? null : "操作失败" })); }
public async Task <IHttpActionResult> PostTaskItem(TaskItem taskItem) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { await _taskService.Add(taskItem); } catch (Exception e) { InternalServerError(e); } return(CreatedAtRoute("DefaultApi", new { id = taskItem.Id }, taskItem)); }