Beispiel #1
0
        public ActionResult Edit(DM_DICHVU model, HttpPostedFileBase fileUpLoad)
        {
            if (fileUpLoad != null && fileUpLoad.ContentLength > 0)
            {
                //tên file
                string fileName = Path.GetFileName(fileUpLoad.FileName);
                // đương dẫn
                string path = Path.Combine(Server.MapPath("~/Assets/Data/Images"), fileName);
                fileUpLoad.SaveAs(path);
                model.HINH_ANH = "/Assets/Data/Images/" + fileName;
            }

            //bool hasErrors = ViewData.ModelState.Values.Any(x => x.Errors.Count > 1);
            //ModelState.IsValid
            if (!(ViewData.ModelState.Values.Any(x => x.Errors.Count > 1)))
            {
                if (DichvuDao.Instance.Update(model))
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ModelState.AddModelError("", "Sửa sản phẩm thất bại!");
                }
            }
            return(View(model));
        }
Beispiel #2
0
        /**
         * @description -- update info product has image
         * @param _request: PromotionRequestDto -- is the data transmitted down from the display screen
         */

        public bool Update(DM_DICHVU _request)
        {
            var dichvu = getByID(_request.MA_DICHVU);

            dichvu.MOTA_CHITIET = _request.MOTA_CHITIET;
            dichvu.HINH_ANH     = _request.HINH_ANH;
            db.SaveChanges();
            return(true);
        }
Beispiel #3
0
        /**
         * @description -- insert a product
         * @param _request: Promotion -- entity object
         */

        public bool insert(DM_DICHVU _request)
        {
            if (!hasProcuct(_request))
            {
                db.DM_DICHVU.Add(_request);
                _request.MODIFIED = DateTime.Now;
                db.SaveChanges();
                return(true);
            }
            return(false);
        }
Beispiel #4
0
        public JsonResult Add(int ma, string ten, int loai, float gia, float km, string tg, int thutu, bool kd, DateTime mod, DM_DICHVU model, HttpPostedFileBase fileUpLoad)
        {
            if (fileUpLoad != null && fileUpLoad.ContentLength > 0)
            {
                //tên file
                string fileName = Path.GetFileName(fileUpLoad.FileName);
                // đương dẫn
                string path = Path.Combine(Server.MapPath("~/Assets/Data/Images"), fileName);
                fileUpLoad.SaveAs(path);
                model.HINH_ANH = "/Assets/Data/Images/" + fileName;
            }
            model.MA_DICHVU        = ma;
            model.TEN_DICHVU       = ten;
            model.MA_LOAIDV        = loai;
            model.GIA_DICHVU       = gia;
            model.GIA_KHUYENMAI    = km;
            model.THOIGIAN_LAMVIEC = tg;
            model.THU_TU           = thutu;
            model.NGUNG_KINHDOANH  = kd;
            model.MODIFIED         = mod;
            var result = DichvuDao.Instance.insert(model);

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Beispiel #5
0
        /**
         * @description -- check exits product in table Promotion
         * @param _prod: Promotion -- is a transion object
         */

        public bool hasProcuct(DM_DICHVU _pro)
        {
            var product = db.DM_DICHVU.SingleOrDefault(obj => obj.MA_DICHVU == _pro.MA_DICHVU);

            return(product != default(DM_DICHVU) ? true : false);
        }