/** * @description -- insert a product * @param _request: Promotion -- entity object */ public bool insert(KH_HANGHOA _request) { if (!hasProcuct(_request)) { db.KH_HANGHOA.Add(_request); db.SaveChanges(); return(true); } return(false); }
public ActionResult Create(KH_HANGHOA model) { if (ModelState.IsValid) { if (HanghoaDao.Instance.insert(model)) { return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Thêm nhóm hàng hóa thất bại!"); } } return(View()); }
public ActionResult Edit(KH_HANGHOA model) { if (ModelState.IsValid) { if (HanghoaDao.Instance.Update(model)) { return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Sửa hàng hóa thất bại!"); } } SetCategoryViewBagDVT(model.ID_DVT); SetCategoryViewBagNHOMHH(model.ID_NHOMHH); SetCategoryViewBagNCC(model.ID_NCC); return(View(model)); }
/** * @description -- update info product has image * @param _request: PromotionRequestDto -- is the data transmitted down from the display screen */ public bool Update(KH_HANGHOA _request) { var hanghoa = getByID(_request.MA_HANGHOA); hanghoa.TEN_HANGHOA = _request.TEN_HANGHOA; hanghoa.DON_GIA = _request.DON_GIA; hanghoa.MO_TA = _request.MO_TA; hanghoa.ID_DVT = _request.ID_DVT; hanghoa.GHI_CHU = _request.GHI_CHU; hanghoa.HINH_ANH = _request.HINH_ANH; hanghoa.ID_NCC = _request.ID_NCC; hanghoa.THU_TU = _request.THU_TU; hanghoa.ID_NHOMHH = _request.ID_NHOMHH; hanghoa.MA_VACH = _request.MA_VACH; hanghoa.MOTA_CHITIET = _request.MOTA_CHITIET; db.SaveChanges(); return(true); }
/** * @description -- check exits product in table Promotion * @param _prod: Promotion -- is a transion object */ public bool hasProcuct(KH_HANGHOA _pro) { var product = db.KH_HANGHOA.SingleOrDefault(obj => obj.MA_HANGHOA == _pro.MA_HANGHOA); return(product != default(KH_HANGHOA) ? true : false); }