예제 #1
0
        public ActionResult Edit([Bind(Include = "VideoId,Title,TitleId,Intro,Keyword,Context,Link,IsDisable,ImgUrl,IdText")] Video Videos)
        {
            if (ModelState.IsValid)
            {
                if (Videos.TitleId == null)
                {
                    Videos.TitleId = DreamCMS.FuncHelp.DHelp.SEOurl(Videos.Title);
                }
                if (db.Videos.Where(x => x.TitleId == Videos.TitleId && x.VideoId != Videos.VideoId).FirstOrDefault() != null)
                {
                    ViewBag.IsValidName = "Tên bài viết đã được sử dụng!!!";
                    return(View(Videos));
                }
                if (!string.IsNullOrEmpty(Videos.Link))
                {
                    Videos.IdText = Videos.Link.Substring(Videos.Link.IndexOf("?v=") + 3, Videos.Link.Length - Videos.Link.IndexOf("?v=") - 3);
                }
                if (string.IsNullOrEmpty(Videos.ImgUrl))
                {
                    Videos.ImgUrl = "https://img.youtube.com/vi/" + Videos.IdText + "/mqdefault.jpg";
                }

                db.Entry(Videos).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(Videos));
        }
 public ActionResult Edit([Bind(Include = "SliderLeftId,TitleImg,Order,ImgUrl,Link")] SliderLeft sliderLeft)
 {
     if (ModelState.IsValid)
     {
         db.Entry(sliderLeft).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(sliderLeft));
 }
예제 #3
0
 public ActionResult Edit([Bind(Include = "OrderId,Name,SDT,Email,Adress,Date,Des")] Order order)
 {
     if (ModelState.IsValid)
     {
         db.Entry(order).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(order));
 }
예제 #4
0
        public ActionResult Edit([Bind(Include = "SliderImgId,TitleImg,Order,ImgUrl,Link")] SliderImg sliderImg)
        {
            if (ModelState.IsValid)
            {
                if (db.SliderImgs.Where(x => x.TitleImg == sliderImg.TitleImg && x.SliderImgId != sliderImg.SliderImgId).FirstOrDefault() != null)
                {
                    ViewBag.IsValidName = "Tiêu đề hình ảnh đã được sử dụng!!!";
                    return(View(sliderImg));
                }

                db.Entry(sliderImg).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(sliderImg));
        }
        public ActionResult Edit([Bind(Include = "PartnerId,CompanytName,ImgUrl,Link")] Partner partner)
        {
            if (ModelState.IsValid)
            {
                if (db.Partners.Where(x => x.CompanytName == partner.CompanytName && x.PartnerId != partner.PartnerId).FirstOrDefault() != null)
                {
                    ViewBag.IsValidName = "Tên công ty đã được sử dụng!!!";
                    return(View(partner));
                }

                db.Entry(partner).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(partner));
        }
예제 #6
0
        public ActionResult Edit([Bind(Include = "PostId,Title,TitleId,Intro,Keyword,Context,IsDisable,ImgUrl")] Post post)
        {
            if (ModelState.IsValid)
            {
                if (post.TitleId == null)
                {
                    post.TitleId = DreamCMS.FuncHelp.DHelp.SEOurl(post.Title);
                }
                if (db.Posts.Where(x => x.TitleId == post.TitleId && x.PostId != post.PostId).FirstOrDefault() != null)
                {
                    ViewBag.IsValidName = "Tên bài viết đã được sử dụng!!!";
                    return(View(post));
                }

                db.Entry(post).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(post));
        }
예제 #7
0
        public ActionResult Edit([Bind(Include = "PageId,Title,TitleId,Intro,Keyword,Context,IsDisable,ImgUrl")] Page page)
        {
            if (ModelState.IsValid)
            {
                if (page.TitleId == null)
                {
                    page.TitleId = DreamCMS.FuncHelp.DHelp.SEOurl(page.Title);
                }
                if (db.Pages.Where(x => x.TitleId == page.TitleId && x.PageId != page.PageId).FirstOrDefault() != null)
                {
                    ViewBag.IsValidName = "Tên trang đã được sử dụng!!!";
                    return(View(page));
                }

                db.Entry(page).State = EntityState.Modified;
                db.SaveChanges();
                ViewBag.IsSuccess   = true;
                ViewBag.IsValidName = "Cập nhật dữ liệu thành công!!!";
                return(View(page));
            }
            return(View(page));
        }
        public ActionResult Edit([Bind(Include = "ProductId,ProductName,SeoUrl,ImgUrl,Order,Price,IsDisable,IsKM,GroupProductId,Intro,Keyword,Des")] Product product)
        {
            if (ModelState.IsValid)
            {
                if (product.SeoUrl == null)
                {
                    product.SeoUrl = DreamCMS.FuncHelp.DHelp.SEOurl(product.ProductName);
                }
                if (db.Products.Where(x => x.SeoUrl == product.SeoUrl && x.ProductId != product.ProductId).FirstOrDefault() != null)
                {
                    ViewBag.IsValidName    = "Tên sản phẩm đã được sử dụng!!!";
                    ViewBag.GroupProductId = new SelectList(db.GroupProducts, "GroupProductId", "GroupName", product.GroupProductId);
                    return(View(product));
                }

                db.Entry(product).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.GroupProductId = new SelectList(db.GroupProducts, "GroupProductId", "GroupName", product.GroupProductId);
            return(View(product));
        }