Пример #1
0
        public ActionResult Create([Bind(Include = "ID,SlideName,SlideImg,Description,Link,Meta,Hide,Order,Datebegin")] Slide slide, HttpPostedFileBase img)
        {
            if (ModelState.IsValid)
            {
                var fileName = "";
                var path     = "";

                if (img != null)
                {
                    fileName = img.FileName;
                    path     = Path.Combine(Server.MapPath("~/Images/Slides/"), fileName);

                    img.SaveAs(path);
                    slide.SlideImg = fileName;
                }
                else
                {
                    slide.SlideImg = "Slide";
                }
                db.Slide.Add(slide);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(slide));
        }
        public ActionResult Create([Bind(Include = "ID,ProductName,ProductPrice,ProductSize,ProductColor,Quantity,ProductImg,Meta,Hide,Order,Datebegin,ProductDescription,MenuCateID")] Product product, HttpPostedFileBase img)
        {
            var path     = "";
            var filename = "";

            if (ModelState.IsValid)
            {
                if (img != null)
                {
                    filename = img.FileName;
                    path     = Path.Combine(Server.MapPath("~/Images/Products/"), filename);
                    img.SaveAs(path);
                    product.ProductImg = filename;
                }
                else
                {
                    product.ProductImg = "logo.png";
                }

                db.Product.Add(product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.MenuCateID = new SelectList(db.MenuCategory, "ID", "MenuCateName", product.MenuCateID);
            return(View(product));
        }
Пример #3
0
        public ActionResult Create([Bind(Include = "ID,NewName,NewImg,Desciption,Link,Detail,Meta,Hide,Order,Datebegin")] FashionShop.Models.EF.News news)
        {
            if (ModelState.IsValid)
            {
                db.News.Add(news);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(news));
        }
Пример #4
0
        public ActionResult Create([Bind(Include = "ID,MenuName,Link,Meta,Hide,Order,Datebegin")] Menu menu)
        {
            if (ModelState.IsValid)
            {
                db.Menu.Add(menu);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(menu));
        }
Пример #5
0
        public ActionResult Create([Bind(Include = "ID,ClientName,PhoneNumber,Address,OrderDate,DeliveryDate,Paid,Status,Meta,Hide,Order1,Datebegin,ClientID")] Order order)
        {
            if (ModelState.IsValid)
            {
                db.Order.Add(order);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ClientID = new SelectList(db.Client, "ID", "UserName", order.ClientID);
            return(View(order));
        }
Пример #6
0
        public void Delete(int id)
        {
            var d = db.OrderDetail.Find(id);

            db.OrderDetail.Remove(d);
            db.SaveChanges();
        }
Пример #7
0
        public int Insert(Order order)
        {
            db.Order.Add(order);
            db.SaveChanges();

            return(order.ID);
        }
Пример #8
0
 public void InsertOrderDetail(OrderDetail orderDetail)
 {
     try
     {
         db.OrderDetail.Add(orderDetail);
         db.SaveChanges();
     }
     catch
     {
         throw;
     }
 }
Пример #9
0
 public void AddContacts(Contact addcontect)
 {
     db.Contact.Add(addcontect);
     db.SaveChanges();
 }