public ActionResult Create([Bind(Include = "ColorId,Color1")] Color color) { if (ModelState.IsValid) { db.Colors.Add(color); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(color)); }
public ActionResult Create([Bind(Include = "NewsId,UserId,Title,ShortDescription,Content,CreatedDate,Status,Image")] News news) { if (ModelState.IsValid) { db.News.Add(news); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.UserId = new SelectList(db.Users, "UserId", "UserName", news.UserId); return(View(news)); }
public ActionResult ProcessOrder1(FormCollection fc) { List <Cart> list = (List <Cart>)Session[strCart]; Order order = new Order() { CustomerName = fc["cusName"], CustomerPhone = fc["cusPhone"], CustomerAdress = fc["cusAddress"], CustomerEmail = fc["cusEmail"], OderDate = DateTime.Now, PaymentType = "Cash", Status = "In process" }; db.Orders.Add(order); db.SaveChanges(); foreach (Cart item in list) { OrderDetail od = new OrderDetail() { OrderId = order.OrderId, ProductId = item.Product.ProductId, Quantity = item.Quantity, Price = Convert.ToInt32(item.Product.Price) }; db.OrderDetails.Add(od); db.SaveChanges(); } Session.Remove(strCart); return(View("OrderSuccess")); }