Пример #1
0
 public void OnPostInsert(Item item)
 {
     _sl.Items.Add(new Item {
         ItemName = item.ItemName, ItemDescription = item.ItemDescription
     });
     _sl.SaveChanges();
 }
Пример #2
0
 public void OnPostUpdate(Item item)
 {
     using (Shopping_listDataContext _sl = new Shopping_listDataContext())
     {
         _sl.Items.Update(item);
         _sl.SaveChanges();
     }
 }
Пример #3
0
 public void OnPostDelete(Brand brand)
 {
     using (Shopping_listDataContext _sl = new Shopping_listDataContext())
     {
         _sl.Brand.Remove(brand);
         _sl.SaveChanges();
     }
 }
Пример #4
0
 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();
     }
 }
Пример #5
0
        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());
        }
Пример #6
0
 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();
     }
 }
Пример #7
0
        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"));
        }