public void OnPostInsert(Item item) { _sl.Items.Add(new Item { ItemName = item.ItemName, ItemDescription = item.ItemDescription }); _sl.SaveChanges(); }
public void OnPostUpdate(Item item) { using (Shopping_listDataContext _sl = new Shopping_listDataContext()) { _sl.Items.Update(item); _sl.SaveChanges(); } }
public void OnPostDelete(Brand brand) { using (Shopping_listDataContext _sl = new Shopping_listDataContext()) { _sl.Brand.Remove(brand); _sl.SaveChanges(); } }
public void OnPostInsert(Item item) { using (Shopping_listDataContext _sl = new Shopping_listDataContext()) { _sl.Items.Add(new Item { ItemName = item.ItemName, ItemDescription = item.ItemDescription }); _sl.SaveChanges(); } }
public async Task <IActionResult> OnPostDeleteAsync(string ItemId) { using (Shopping_listDataContext _sl = new Shopping_listDataContext()) { var item = await _sl.Items.FindAsync(ItemId); _sl.Items.Remove(item); _sl.SaveChanges(); } return(RedirectToPage()); }
public void OnPostInsert(Brand brand) { using (Shopping_listDataContext _sl = new Shopping_listDataContext()) { _sl.Brand.Add(new Brand { BrandName = brand.BrandName, BrandNotes = brand.BrandNotes, BrandWebsite = brand.BrandWebsite }); _sl.SaveChanges(); } }
public IActionResult OnPostUpdate(int id) { try { Item.ItemId = id; //Set the primary key _sl.Items.Update(Item); //The rest of the new values are automatically bound _sl.SaveChanges(); //Update the database Message = "Good or Service update successful"; //Alert the user Success = true; } catch { Message = "Good or Service update not successful"; //Alert the user Success = false; } return(RedirectToPage("./Items")); }