Exemple #1
0
 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;
 }
Exemple #2
0
 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;
 }
Exemple #3
0
 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, "");
     }
 }
Exemple #4
0
 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, "");
     }
 }
Exemple #5
0
        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);
            }
        }
Exemple #6
0
        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);
            }
        }
Exemple #7
0
 public T_Slide AddNewSlideAndReturn(T_Slide iSlide)
 {
     _dataContext.T_Slide.Add(iSlide);
     _dataContext.SaveChanges();
     return iSlide;
 }
Exemple #8
0
 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, "");
     }
 }
Exemple #9
0
 public bool IsExist(T_Slide iSlide)
 {
     return false;
 }