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)); }
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)); }
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)); }
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)); }
public void Delete(int id) { var d = db.OrderDetail.Find(id); db.OrderDetail.Remove(d); db.SaveChanges(); }
public int Insert(Order order) { db.Order.Add(order); db.SaveChanges(); return(order.ID); }
public void InsertOrderDetail(OrderDetail orderDetail) { try { db.OrderDetail.Add(orderDetail); db.SaveChanges(); } catch { throw; } }
public void AddContacts(Contact addcontect) { db.Contact.Add(addcontect); db.SaveChanges(); }