public bool Delete(int id) { var business = new TaskListBusiness(); var entity = business.GetByID(id); if (entity == null) { throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.NotFound, $"Tarefa Id={id} não encontrada.")); } entity.DataExclusao = DateTime.Now; entity.IdStatus = (int)TaskListEnumModel.StatusTaskList.Cancelada; business.Update(entity); return(true); }
public TaskListModel Put(int id, [FromBody] TaskListModel taskListModel) { var business = new TaskListBusiness(); var entity = business.GetByID(id); if (entity == null) { throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.NotFound, $"Tarefa Id={id} não encontrada.")); } var taskList = mapper.Map <Entity.TaskList>(taskListModel); taskList.DataAlteracao = DateTime.Now; var result = business.Update(entity, taskList); if (!result) { throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.NotFound, $"Erro ao incluir tarefa.")); } return(mapper.Map <TaskListModel>(taskList)); }