public string ThanhToan(string Name, string Email, string SDT, string Adress, string Des)
        {
            ShoppingCartModels model = new ShoppingCartModels();

            model.Cart = (ShoppingCart)Session["Cart"];

            Order or = new Order();

            or.Name   = Name;
            or.Email  = Email;
            or.Date   = DateTime.Now;
            or.SDT    = SDT;
            or.Adress = Adress;
            or.Des    = Des;
            db.Orders.Add(or);
            db.SaveChanges();

            foreach (var item in model.Cart.ListItem)
            {
                OrderDetail det = new OrderDetail();
                det.OrderId     = or.OrderId;
                det.ProductId   = Convert.ToInt32(item.ProductID);
                det.ProductName = HttpUtility.UrlEncode(item.ProductName);
                det.ImgUrl      = item.ProductImage;
                db.OrderDetails.Add(det);
                db.SaveChanges();
            }
            Session["Cart"] = null;

            return("Successful");
        }
        private void Delete_Recur(DBFrontEnd db, GroupProduct gp)
        {
            List <GroupProduct> ListGroupProduct = gp.GroupProductChildrens.ToList();

            if (ListGroupProduct != null)
            {
                foreach (var i in ListGroupProduct)
                {
                    Delete_Recur(db, i);
                }
            }

            List <Product> ListProduct = gp.Products.ToList();

            if (ListProduct != null)
            {
                foreach (var i in ListProduct)
                {
                    db.Products.Remove(i);
                }
                db.SaveChanges();
            }

            db.GroupProducts.Remove(gp);
            db.SaveChanges();
        }
Exemplo n.º 3
0
        public ActionResult Create([Bind(Include = "VideoId,Title,TitleId,Intro,Keyword,Link,Context,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).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.Videos.Add(Videos);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(Videos));
        }
        public ActionResult Create([Bind(Include = "SliderLeftId,TitleImg,Order,ImgUrl,Link")] SliderLeft sliderLeft)
        {
            if (ModelState.IsValid)
            {
                db.SliderLefts.Add(sliderLeft);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(sliderLeft));
        }
Exemplo n.º 5
0
        public ActionResult Create([Bind(Include = "BannerId,TitleImg,Order,ImgUrl,Link")] Banner Banner)
        {
            if (ModelState.IsValid)
            {
                db.Banners.Add(Banner);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

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

            return(View(partner));
        }
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Contact contact = db.Contacts.Find(id);

            if (contact == null)
            {
                return(HttpNotFound());
            }
            contact.IsSeen = true;
            db.SaveChanges();
            return(View(contact));
        }
Exemplo n.º 8
0
        public ActionResult Create([Bind(Include = "SliderImgId,TitleImg,Order,ImgUrl,Link")] SliderImg sliderImg)
        {
            if (ModelState.IsValid)
            {
                if (db.SliderImgs.Where(x => x.TitleImg == sliderImg.TitleImg).FirstOrDefault() != null)
                {
                    ViewBag.IsValidName = "Tiêu đề hình ảnh đã được sử dụng!!!";
                    return(View(sliderImg));
                }

                db.SliderImgs.Add(sliderImg);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(sliderImg));
        }
Exemplo n.º 9
0
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Order order = db.Orders.Find(id);

            if (order == null)
            {
                return(HttpNotFound());
            }

            order.IsSeen = true;
            db.SaveChanges();

            ViewBag.sp = db.OrderDetails.Where(p => p.OrderId == id).ToList();
            return(View(order));
        }
Exemplo n.º 10
0
        public ActionResult Create([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).FirstOrDefault() != null)
                {
                    ViewBag.IsValidName = "Tên trang đã được sử dụng!!!";
                    return(View(page));
                }

                db.Pages.Add(page);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(page));
        }
Exemplo n.º 11
0
        public ActionResult Create([Bind(Include = "NewsId,Title,TitleId,Intro,Keyword,Context,IsDisable,ImgUrl")] News news)
        {
            if (ModelState.IsValid)
            {
                if (news.TitleId == null)
                {
                    news.TitleId = DreamCMS.FuncHelp.DHelp.SEOurl(news.Title);
                }
                if (db.Newss.Where(x => x.TitleId == news.TitleId).FirstOrDefault() != null)
                {
                    ViewBag.IsValidName = "Tên bài viết đã được sử dụng!!!";
                    return(View(news));
                }

                db.Newss.Add(news);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(news));
        }
        public ActionResult Create([Bind(Include = "GroupProductId,GroupName,SeoUrl,Order,IsDisable,IsShowOnTop,ImgUrl,IdRoot,CountNode")] GroupProduct groupProduct)
        {
            List <GroupProduct> ListGroupProduct = db.GroupProducts.Where(x => x.CountNode < 2).OrderBy(x => x.GroupName).ToList();

            ListGroupProduct.Insert(0, new GroupProduct()
            {
                GroupName = "Gốc"
            });

            if (ModelState.IsValid)
            {
                if (groupProduct.SeoUrl == null)
                {
                    groupProduct.SeoUrl = DreamCMS.FuncHelp.DHelp.SEOurl(groupProduct.GroupName);
                }
                if (db.GroupProducts.Where(x => x.SeoUrl == groupProduct.SeoUrl).FirstOrDefault() != null)
                {
                    ViewBag.IsValidName = "Tên nhóm đã được sử dụng!!!";
                    ViewBag.IdRoot      = new SelectList(ListGroupProduct, "GroupProductId", "GroupName", groupProduct.IdRoot);
                    return(View(groupProduct));
                }

                if (groupProduct.IdRoot == 0)
                {
                    groupProduct.IdRoot = null; groupProduct.CountNode = 0;
                }
                else
                {
                    GroupProduct gpRoot = db.GroupProducts.Where(x => x.GroupProductId == groupProduct.IdRoot).FirstOrDefault();
                    groupProduct.CountNode = gpRoot.CountNode + 1;
                }

                db.GroupProducts.Add(groupProduct);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.IdRoot = new SelectList(ListGroupProduct, "GroupProductId", "GroupName", groupProduct.IdRoot);
            return(View(groupProduct));
        }
Exemplo n.º 13
0
        public ActionResult Create([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).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.Products.Add(product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.GroupProductId = new SelectList(db.GroupProducts, "GroupProductId", "GroupName", product.GroupProductId);
            return(View(product));
        }
Exemplo n.º 14
0
        public ActionResult Contact([Bind(Include = "ContactId,FullName,Address,Email,Phone,Content")] Contact contact, string codeauth)
        {
            if (ModelState.IsValid)
            {
                string CodeAuthContact = Session["CodeAuthContact"].ToString();

                if (string.IsNullOrEmpty(CodeAuthContact) || string.IsNullOrEmpty(codeauth))
                {
                    ViewBag.ErrorCodeAuth = "Mã xác nhận không trùng khớp";
                    ViewBag.IsSuccess     = false;
                    return(View(contact));
                }
                else if (CodeAuthContact != codeauth.Trim())
                {
                    ViewBag.ErrorCodeAuth = "Mã xác nhận không trùng khớp";
                    ViewBag.IsSuccess     = false;
                    return(View(contact));
                }

                db.Contacts.Add(contact);
                db.SaveChanges();

                ViewBag.IsSuccess = true;

                string emailrc = Setting.Get("EmailReceiveContact");
                if (emailrc.Length > 0)
                {
                    //sendmail
                    string content = FuncHelp.DHelp.Email.TemplateMail("Thư gửi từ BaoBiToanQuoc",
                                                                       "Thư gửi từ BaoBiToanQuoc",
                                                                       contact.ContactId.ToString(),
                                                                       contact.FullName,
                                                                       contact.Address,
                                                                       contact.Email,
                                                                       contact.Phone,
                                                                       contact.Content);
                    FuncHelp.DHelp.Email.SendMail(emailrc, "[BaoBiToanQuoc] #" + contact.ContactId.ToString() + " Thư từ " + contact.FullName, content);
                }

                Session.Remove("CodeAuthContact_Hold");
                return(View(contact));
            }
            ViewBag.IsSuccess = false;
            return(View(contact));
        }