コード例 #1
0
ファイル: BooksRepository.cs プロジェクト: BezdelMA/Book_site
        public void EditBook(Book book)
        {
            var _book = appDBContent.Books.FirstOrDefault(b => b.Id == book.Id);

            appDBContent.Remove(_book);
            appDBContent.Add(book);
            appDBContent.SaveChanges();
        }
コード例 #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("Удалено успешно");
        }
コード例 #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"));
        }
コード例 #4
0
        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"));
            }
        }
コード例 #5
0
 public void RemoveAuthor(Author author)
 {
     appDBContent.Remove(author);
     appDBContent.SaveChanges();
 }