public void EditBook(Book book)
        {
            var _book = appDBContent.Books.FirstOrDefault(b => b.Id == book.Id);

            appDBContent.Remove(_book);
            appDBContent.Add(book);
            appDBContent.SaveChanges();
        }
Exemple #2
0
        public string DeleteAuto(int id)                      //Delete objects by ID
        {
            var temp = Autos.FirstOrDefault(p => p.Id == id); //Validate if there is an object with the ID

            if (temp == null)
            {
                return("Объект не найден");
            }
            appDBContent.Remove(temp);
            appDBContent.SaveChanges();
            return("Удалено успешно");
        }
Exemple #3
0
        public RedirectToActionResult Delete(int id)
        {
            var item = _allMerches.Merches.FirstOrDefault(i => i.id == id);

            if (item != null)
            {
                _dbContext.Remove(item);
            }
            _dbContext.SaveChanges();

            return(RedirectToAction("List"));
        }
        public async Task <IActionResult> DeleteOrder(int id)
        {
            try
            {
                var order = await _appDBContent.OrderDetail.FindAsync(id);

                if (order != null)
                {
                    _appDBContent.Remove(order);
                    await _appDBContent.SaveChangesAsync();
                }

                return(RedirectToAction("OrderList"));
            }
            catch (Exception e)
            {
                return(RedirectToAction("OrderList"));
            }
        }
Exemple #5
0
 public void RemoveAuthor(Author author)
 {
     appDBContent.Remove(author);
     appDBContent.SaveChanges();
 }