public SlideViewModel(T_Slide iSlide, IEnumerable<T_SlideGroup> iSlideGroupList) { ID = iSlide.ID; Title = iSlide.Title; Link = iSlide.Link; ImagePath = iSlide.ImagePath; Enable = iSlide.Enable; GroupID = iSlide.GroupID; SlideGroupList = iSlideGroupList; }
public T_Slide GetSlide() { T_Slide RetSlide = new T_Slide(); RetSlide.ID = ID; RetSlide.Title = Title; RetSlide.Link = Link; RetSlide.ImagePath = ImagePath; RetSlide.Enable = Enable; RetSlide.GroupID = GroupID; return RetSlide; }
public ReturnValue<bool> DeleteSlide(T_Slide iSlide) { try { //Delete this slide _dataContext.T_Slide.Remove(iSlide); _dataContext.SaveChanges(); return new ReturnValue<bool>(true, ""); } catch (Exception) { return new ReturnValue<bool>(false, ""); } }
public ReturnValue<bool> AddNewSlide(T_Slide iSlide) { if (IsExist(iSlide)) return new ReturnValue<bool>(false, "Mục đã tồn tại"); try { _dataContext.T_Slide.Add(iSlide); _dataContext.SaveChanges(); return new ReturnValue<bool>(true, ""); } catch (Exception) { return new ReturnValue<bool>(false, ""); } }
public ActionResult AddNew(T_Slide iSlide) { // Upload the image HttpPostedFileBase file = Request.Files["ImageData"]; string PathReturn = UploadSlideImage(file); iSlide.ImagePath = PathReturn; ReturnValue<bool> result = new ReturnValue<bool>(false, ""); if (ModelState.IsValid) { result = _SlideServices.AddNewSlide(iSlide); } if (result.RetValue) { return RedirectToAction("List", "Slide"); } else { SlideViewModel Model = new SlideViewModel(iSlide, _slideGroupServices.GetAll()); // Get Slide_List again ModelState.AddModelError("Error", result.Msg); return View(Model); } }
public ActionResult Edit(T_Slide iSlide) { // Upload image if it have HttpPostedFileBase file = Request.Files["ImageData"]; string PathReturn = UploadSlideImage(file); if (!string.IsNullOrEmpty(PathReturn)) iSlide.ImagePath = PathReturn; ReturnValue<bool> result = _SlideServices.UpdateSlide(iSlide); if (result.RetValue) { return RedirectToAction("List", "Slide"); } else { // Get Slide_List again ModelState.AddModelError("Error", result.Msg); return View(iSlide); } }
public T_Slide AddNewSlideAndReturn(T_Slide iSlide) { _dataContext.T_Slide.Add(iSlide); _dataContext.SaveChanges(); return iSlide; }
public ReturnValue<bool> UpdateSlide(T_Slide iSlide) { //if (IsExist(iSlide)) return new ReturnValue<bool>(false, "Mục đã tồn tại"); try { _dataContext.Entry(iSlide).State = EntityState.Modified; return new ReturnValue<bool>(_dataContext.SaveChanges() > 0, ""); } catch (Exception) { return new ReturnValue<bool>(false, ""); } }
public bool IsExist(T_Slide iSlide) { return false; }