/** * @description -- update info product has image * @param _request: PromotionRequestDto -- is the data transmitted down from the display screen */ public bool Update(APP_GIOITHIEU _request) { var gioithieu = getByID(_request.ID_GIOITHIEU); gioithieu.MOTA_VANTAT = _request.MOTA_VANTAT; gioithieu.NOIDUNG_CHITIET = _request.NOIDUNG_CHITIET; gioithieu.TRANG_THAI = _request.TRANG_THAI; db.SaveChanges(); return(true); }
/** * @description -- insert a product * @param _request: Promotion -- entity object */ public bool insert(APP_GIOITHIEU _request) { if (!hasProcuct(_request)) { db.APP_GIOITHIEU.Add(_request); _request.MODIFIED = DateTime.Now; db.SaveChanges(); return(true); } return(false); }
public ActionResult Edit(APP_GIOITHIEU model) { if (ModelState.IsValid) { if (GioithieuDao.Instance.Update(model)) { return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Sửa sản phẩm thất bại!"); } } return(View(model)); }
public ActionResult Create(APP_GIOITHIEU model) { if (ModelState.IsValid) { if (GioithieuDao.Instance.insert(model)) { return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Thêm khuyến mãi thất bại!"); } } return(View()); }
/** * @description -- check exits product in table Promotion * @param _prod: Promotion -- is a transion object */ public bool hasProcuct(APP_GIOITHIEU _pro) { var product = db.APP_GIOITHIEU.SingleOrDefault(obj => obj.ID_GIOITHIEU == _pro.ID_GIOITHIEU); return(product != default(APP_GIOITHIEU) ? true : false); }