public async Task<HttpResponseMessage> Update(int id, EmployeeModel model) { try { int result = await service.UpdateAsync(Mapper.Map<IEmployee>(model)); if (result >= 1) { return Request.CreateResponse(HttpStatusCode.OK, model); } else { return Request.CreateResponse(HttpStatusCode.BadRequest, "Error while trying to edit task."); } } catch (Exception ex) { return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message); } }
public async Task<HttpResponseMessage> Insert(EmployeeModel emp) { try { int result = await service.AddAsync(Mapper.Map<IEmployee>(emp)); if (result == 0) { return Request.CreateResponse(HttpStatusCode.BadRequest, "Add operation error."); } else { return Request.CreateResponse(HttpStatusCode.OK, result); } } catch (Exception ex) { return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message); } }