Example #1
0
        public JsonResult CreateOrUpDate(BenhAnEntities Option)
        {
            var result = new HttpResponseMessage {
                StatusCode = HttpStatusCode.OK
            };

            try
            {
                if (Option.ID_BenhAn > 0)
                {
                    Option.Date_Edited = DateTime.Now;
                    _benhanService.Update(Option);
                }

                else
                {
                    Option.Date_Created = DateTime.Now;
                    _donthuocService.CreateTemp();
                    _benhanService.Create(Option);
                }
            }
            catch (Exception ex)
            {
                result.StatusCode   = HttpStatusCode.InternalServerError;
                result.ReasonPhrase = ex.Message;
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Example #2
0
 public int Create(BenhAnEntities Option)
 {
     using (var scope = new TransactionScope())
     {
         Mapper.CreateMap <BenhAnEntities, BenhAn>();
         var o  = Mapper.Map <BenhAnEntities, BenhAn>(Option);
         var bn = _unitOfWork.BenhNhanRepository.GetByID(o.ID_BenhNhan);
         bn.ID_LoaiKhachHang = 2;
         _unitOfWork.BenhNhanRepository.Update(bn);
         o.IsDelete     = false;
         o.Date_Created = DateTime.Now;
         _unitOfWork.BenhAnRepository.Insert(o);
         _unitOfWork.Save();
         scope.Complete();
         return(o.ID_BenhAn);
     }
 }
Example #3
0
        public bool Update(BenhAnEntities Option)
        {
            var success = false;

            if (Option != null)
            {
                using (var scope = new TransactionScope())
                {
                    var o = _unitOfWork.BenhAnRepository.Get(x => x.ID_BenhAn == Option.ID_BenhAn && x.IsDelete == false);
                    if (o != null)
                    {
                        Mapper.CreateMap <BenhAnEntities, BenhAn>();
                        o = Mapper.Map <BenhAnEntities, BenhAn>(Option);
                    }
                    _unitOfWork.BenhAnRepository.Update(o);
                    _unitOfWork.Save();
                    scope.Complete();
                }
            }
            return(success);
        }