public async Task <IActionResult> Edit(int id, [Bind("Photo,ProductId,ProductName,Price,Brands,Sizes,Description,InventoriesId")] BeautyProduct beautyProduct) { if (id != beautyProduct.ProductId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(beautyProduct); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BeautyProductExists(beautyProduct.ProductId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(beautyProduct)); }
public ActionResult DeleteConfirmed(int id) { BeautyProduct beautyProduct = db.BeautyProducts.Find(id); db.BeautyProducts.Remove(beautyProduct); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ProductID,ProductName,image,ProductDescription")] BeautyProduct beautyProduct) { if (ModelState.IsValid) { db.Entry(beautyProduct).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(beautyProduct)); }
public ActionResult Create([Bind(Include = "ProductID,ProductName,image,ProductDescription")] BeautyProduct beautyProduct) { if (ModelState.IsValid) { db.BeautyProducts.Add(beautyProduct); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(beautyProduct)); }
public async Task <IActionResult> Create([Bind("ProductId,ProductName,Price,Brands,Sizes,Description,InventoriesId")] BeautyProduct beautyProduct) { if (ModelState.IsValid) { _context.Add(beautyProduct); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(beautyProduct)); }
// GET: BeautyProducts/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BeautyProduct beautyProduct = db.BeautyProducts.Find(id); if (beautyProduct == null) { return(HttpNotFound()); } return(View(beautyProduct)); }
static void Main(string[] args) { using (var ctx = new EFDbContext()) { var Beautyproduct = new BeautyProduct() { Name = "EyebrowBrush", Price = 25m, Description = "This is a beauty product.", Category = "BeautyProduct" }; ctx.BeautyProducts.Add(Beautyproduct); ctx.SaveChanges(); } Console.WriteLine("Done."); Console.ReadLine(); }