Exemplo n.º 1
0
 public Response <ReceivedDocumentModel> Update(int Id, ReceivedDocumentUpdateModel updateModel)
 {
     try
     {
         using (var unitOfWork = new UnitOfWork())
         {
             var entity = unitOfWork.GetRepository <ReceivedDocument>().GetById(Id);
             if (entity != null)
             {
                 Ultis.TransferValues(entity, updateModel);
                 entity.LastModifiedOnDate = DateTime.Now;
                 unitOfWork.GetRepository <ReceivedDocument>().Update(entity);
                 if (unitOfWork.Save() >= 1)
                 {
                     return(GetById(entity.ReceivedDocumentId));
                 }
                 return(new Response <ReceivedDocumentModel>(0, "Lưu thông tin không thành công", null));
             }
             return(new Response <ReceivedDocumentModel>(0, "Tài liệu không tồn tại", null));
         }
     }
     catch (Exception ex)
     {
         return(new Response <ReceivedDocumentModel>(-1, ex.ToString(), null));
     }
 }
Exemplo n.º 2
0
        public IHttpActionResult Update(int Id, ReceivedDocumentUpdateModel updateModel)
        {
            string UserId = Request.Headers.GetValues("UserId").FirstOrDefault();

            updateModel.LastModifiedByUserId = Convert.ToInt32(UserId);
            var result = handler.Update(Id, updateModel);

            return(Ok(result));
        }