public Response <DocumentPerformModel> Update(int Id, DocumentPerformUpdateModel updateModel) { try { using (var unitOfWork = new UnitOfWork()) { var entity = unitOfWork.GetRepository <DocumentPerform>().GetById(Id); if (entity != null) { Ultis.TransferValues(entity, updateModel); entity.UpdatedOnDate = DateTime.Now; unitOfWork.GetRepository <DocumentPerform>().Update(entity); if (unitOfWork.Save() >= 1) { return(GetById(entity.PerformId)); } return(new Response <DocumentPerformModel>(0, "Saving data not successful!", null)); } return(new Response <DocumentPerformModel>(0, "Id is not valid", null)); } } catch (Exception ex) { return(new Response <DocumentPerformModel>(-1, ex.ToString(), null)); } }
public IHttpActionResult Update(int Id, DocumentPerformUpdateModel updateModel) { string UserId = Request.Headers.GetValues("UserId").FirstOrDefault(); updateModel.UpdatedByUserId = Convert.ToInt32(UserId); var result = handler.Update(Id, updateModel); return(Ok(result)); }