public async Task <IActionResult> Edit(Guid id, [Bind("Id,Product,Brand,Ounces,Price,PricePerOunce,ProductLink,Comments,DatePurchased,SkincareCategory")] SkincareProduct skincareProduct) { if (id != skincareProduct.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(skincareProduct); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SkincareProductExists(skincareProduct.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["SkincareCategory"] = new SelectList(_context.SkincareCategory, "Id", "Category", skincareProduct.SkincareCategory); return(View(skincareProduct)); }
public async Task <IActionResult> Create([Bind("Id,Product,Brand,Ounces,Price,PricePerOunce,ProductLink,Comments,DatePurchased,SkincareCategory")] SkincareProduct skincareProduct) { if (ModelState.IsValid) { skincareProduct.Id = Guid.NewGuid(); _context.Add(skincareProduct); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["SkincareCategory"] = new SelectList(_context.SkincareCategory, "Id", "Category", skincareProduct.SkincareCategory); return(View(skincareProduct)); }