public async Task <HttpResponseMessage> Post([FromBody] TaskWorkInsertVO vo) { try { var id = await service.InsertAsync(vo); return(Request.CreateResponse(HttpStatusCode.OK, id)); } catch (Exception) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Ocorreu um erro ao salvar a tarefa.")); } }
/// <summary> /// This method creates a new task work. /// </summary> /// <param name="vo">New task work object.</param> public async Task <int> InsertAsync(TaskWorkInsertVO vo) { using (var db = new PoWDbContext()) { TaskWork entity = new TaskWork(); entity.Title = vo.Title; entity.Description = vo.Description; entity.CreateDate = DateTime.Now; entity.Status = TaskWorkStatus.TODO; db.TaskWorks.Add(entity); await db.SaveChangesAsync(); return(entity.Id); } }