public ActionResult Create(TaskViewModel task) { if (!ModelState.IsValid) { return(View(task)); } _service.Add(_mapper.ToDomain(task)); return(RedirectToAction("Index")); }
public async Task <IActionResult> Create([Bind("Id,Title,Description,CreateDate,UpdateDate,DeletedDate,isActive,CustomerId")] TaskVM task) { if (ModelState.IsValid) { task.Id = Guid.NewGuid(); var newTask = _mapper.Map <TaskVM, Model.Task>(task); _taskAppService.Add(newTask); return(RedirectToAction(nameof(Index))); } //ViewData["CustomerId"] = new SelectList(_context.Customers, "Id", "Name", task.CustomerId); return(View(task)); }
public async Task <ResponseMessage> Add(Domain.Entities.TaskEntity task) { try { var storedBoard = await _taskService.Add(task); return(new ResponseMessage(true, storedBoard, "Task created with success!", HttpStatusCode.OK)); } catch (Exception err) { return(new ResponseMessage(false, null, err.Message, HttpStatusCode.BadRequest)); } }