public IActionResult Index() { var sizeCheck = _db.Optiongroups.First(o => o.OptionGroupName == "size"); var colorCheck = _db.Optiongroups.First(o => o.OptionGroupName == "color"); if (sizeCheck == null) { var size = new Optiongroup { OptionGroupId = 2, OptionGroupName = "size" }; _db.Optiongroups.Add(size); _db.SaveChanges(); } if (colorCheck == null) { var color = new Optiongroup { OptionGroupId = 1, OptionGroupName = "color" }; _db.Optiongroups.Add(color); _db.SaveChanges(); } dynamic metamodel = new ExpandoObject(); metamodel.newOnthisSite = _db.Products.OrderByDescending(o => o.ProductId).Take(6); metamodel.dealsOftheWeek = _db.Products.OrderBy(o => o.ProductPrice).Take(6); return(View(metamodel)); }
public IActionResult DeleteCartProduct(int?id) { if (id == null) { return(BadRequest("Something error happened")); } var tempCarts = _db.TempCarts.First(o => o.TempCartID == id); if (tempCarts == null) { return(BadRequest("Something error happened")); } _db.TempCarts.Remove(tempCarts); _db.SaveChanges(); return(RedirectToAction("Cart")); }