コード例 #1
0
 public Response <ContactPersonModel> Update(int Id, ContactPersonUpdateModel updateModel)
 {
     try
     {
         using (var unitOfWork = new UnitOfWork())
         {
             var dir = unitOfWork.GetRepository <ContactPerson>().GetById(Id);
             if (dir != null)
             {
                 Ultis.TransferValues(dir, updateModel);
                 unitOfWork.GetRepository <ContactPerson>().Update(dir);
                 if (unitOfWork.Save() >= 1)
                 {
                     return(GetById(dir.ContactPersonId));
                 }
                 return(new Response <ContactPersonModel>(0, "Lưu thông tin không thành công!", null));
             }
             else
             {
                 return(new Response <ContactPersonModel>(0, "Không tìm thấy phòng ban", null));
             }
         }
     }
     catch (Exception ex)
     {
         return(new Response <ContactPersonModel>(-1, ex.ToString(), null));
     }
 }
コード例 #2
0
        public IHttpActionResult Update(int Id, ContactPersonUpdateModel updateModel)
        {
            var result = handler.Update(Id, updateModel);

            return(Ok(result));
        }