public ReturnValue<bool> DeleteAdver(T_Adver iAdver) { try { _dataContext.T_Adver.Remove(iAdver); _dataContext.SaveChanges(); return new ReturnValue<bool>(true, ""); } catch (Exception) { return new ReturnValue<bool>(false, ""); } }
public ReturnValue<bool> AddNewAdver(T_Adver iAdver) { if (IsExist(iAdver)) return new ReturnValue<bool>(false, "Mục đã tồn tại"); try { _dataContext.T_Adver.Add(iAdver); _dataContext.SaveChanges(); return new ReturnValue<bool>(true, ""); } catch (Exception) { return new ReturnValue<bool>(false, ""); } }
public ActionResult AddNew(T_Adver iAdver) { // Upload the image HttpPostedFileBase file = Request.Files["ImageData"]; string PathReturn = UploadAdverImage(file); iAdver.ImagePath = PathReturn; ReturnValue<bool> result = new ReturnValue<bool>(false, ""); if (ModelState.IsValid) { result = _AdverServices.AddNewAdver(iAdver); } if (result.RetValue) { return RedirectToAction("List", "Adver"); } else { // Get Adver_List again ModelState.AddModelError("Error", result.Msg); return View(iAdver); } }
public T_Adver AddNewAdverAndReturn(T_Adver iAdver) { _dataContext.T_Adver.Add(iAdver); _dataContext.SaveChanges(); return iAdver; }
public ReturnValue<bool> UpdateAdver(T_Adver iAdver) { //if (IsExist(iAdver)) return new ReturnValue<bool>(false, "Mục đã tồn tại"); try { _dataContext.Entry(iAdver).State = EntityState.Modified; return new ReturnValue<bool>(_dataContext.SaveChanges() > 0, ""); } catch (Exception) { return new ReturnValue<bool>(false, ""); } }
public bool IsExist(T_Adver iAdver) { return false; }
public ActionResult Edit(T_Adver iAdver) { // Upload image if it have HttpPostedFileBase file = Request.Files["ImageData"]; string PathReturn = UploadAdverImage(file); if (!string.IsNullOrEmpty(PathReturn)) iAdver.ImagePath = PathReturn; iAdver.ModifiedDate = DateTime.Now; iAdver.ModifiedBy = "admin"; ReturnValue<bool> result = _AdverServices.UpdateAdver(iAdver); if (result.RetValue) { return RedirectToAction("List", "Adver"); } else { // Get Adver_List again ModelState.AddModelError("Error", result.Msg); return View(iAdver); } }