コード例 #1
0
        public JsonResult CreateOrUpDate(DonThuocEntities Option)
        {
            var result = new HttpResponseMessage {
                StatusCode = HttpStatusCode.OK
            };

            try
            {
                if (Option.ID_donthuoc > 0)
                {
                    Option.Date_Edited = DateTime.Now;
                    _donthuocService.Update(Option);
                }
                else
                {
                    Option.Date_Created = DateTime.Now;
                    Option.ngayCapThuoc = DateTime.Now;
                    _donthuocService.Create(Option);
                }
            }
            catch (Exception ex)
            {
                result.StatusCode   = HttpStatusCode.InternalServerError;
                result.ReasonPhrase = ex.Message;
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
ファイル: DonThuocService.cs プロジェクト: Redfield1947/PM03
        public bool Update(DonThuocEntities Option)
        {
            var success = false;

            if (Option != null)
            {
                using (var scope = new TransactionScope())
                {
                    var o = _unitOfWork.DonThuocRepository.Get(x => x.ID_donthuoc == Option.ID_donthuoc);
                    if (o != null)
                    {
                        //o.ID_donDonThuoc = Option.ID_donDonThuoc;
                        //o.tenDonThuoc = Option.tenDonThuoc;
                        //o.loaiDonThuoc = Option.loaiDonThuoc;
                        //o.soLuongTon = Option.soLuongTon;
                        //o.GhiChu = Option.GhiChu;
                        o.ID_donthuoc  = Option.ID_donthuoc;
                        o.ngayCapThuoc = Option.ngayCapThuoc;
                        o.Date_Edited  = DateTime.Now;;
                        o.IsDelete     = Option.IsDelete;
                    }
                    _unitOfWork.DonThuocRepository.Update(o);
                    _unitOfWork.Save();
                    scope.Complete();
                }
            }
            return(success);
        }
コード例 #3
0
ファイル: DonThuocService.cs プロジェクト: Redfield1947/PM03
 public int Create(DonThuocEntities Option)
 {
     using (var scope = new TransactionScope())
     {
         Mapper.CreateMap <DonThuocEntities, DonThuoc>();
         var o = Mapper.Map <DonThuocEntities, DonThuoc>(Option);
         o.IsDelete     = false;
         o.Date_Created = DateTime.Now;
         _unitOfWork.DonThuocRepository.Insert(o);
         _unitOfWork.Save();
         scope.Complete();
         return(o.ID_donthuoc);
     }
 }