private void DeleteCard(Card item) { var repository = new CardRepository(); var card = repository.GetById(item.Id); var defaultCard = repository.GetDefaultCard(); if (card.StockUnitList != null) { var stockUnitRepository = new StockUnitRepository(); foreach (var stockUnit in card.StockUnitList) { stockUnit.Card = defaultCard; stockUnitRepository.Update(stockUnit); } } try { repository.Delete(item); } catch (Exception ex) { ShowInfoMessage(ex.Message, "Ошибка"); } }
public async Task <ActionResult <CardResponse> > DeleteCard(long id) { var card = await _cardRepository.Delete(id); var cardResponse = MapModelToResponse(card); return(cardResponse); }
public void DeleteTest() { var repo = new CardRepository(); repo.Delete(2); var allSets = repo.SelectAll(); Assert.AreEqual(1, allSets.Count); }
public void DeleteTest() { var repo = new CardRepository(); repo.Delete(1); var allSets = repo.SelectAll(); Assert.IsNull(allSets.FirstOrDefault(c => c.CardID == 1)); }
public IHttpActionResult RemoveItem([FromUri] int id) { try { var item = _cardRepository.GetById(id); _cardRepository.Delete(item); return(Ok(id)); } catch (Exception e) { _logger.Error("Could not delete item. Exception Message: " + e.Message); return(BadRequest("Could not delete item")); } }
public IActionResult Delete([FromBody] IEnumerable <Card> value) { try { db.Delete(value); logger.LogInformation("------------> Card have been deleted <------------"); return(Ok()); } catch (Exception ex) { logger.LogWarning("------------> An error has occurred <------------ \n" + ex.Message); return(BadRequest(ex.Message)); } }
public static void DeleteGroupMap(int idMap) { using (ICardRepository cardRepository = new CardRepository(true)) { cardRepository.Delete<CardGroupMap>(p => p.IdMapping == idMap); cardRepository.UnitOfWork.SaveChanges(); } }
public static void DeleteCard(int idCard) { using (ICardRepository cardRepository = new CardRepository(true)) { cardRepository.Delete<Card>(p => p.IdCard == idCard); cardRepository.UnitOfWork.SaveChanges(); } }