示例#1
0
        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, "Ошибка");
            }
        }
示例#2
0
        public async Task <ActionResult <CardResponse> > DeleteCard(long id)
        {
            var card = await _cardRepository.Delete(id);

            var cardResponse = MapModelToResponse(card);

            return(cardResponse);
        }
示例#3
0
        public void DeleteTest()
        {
            var repo = new CardRepository();

            repo.Delete(2);

            var allSets = repo.SelectAll();

            Assert.AreEqual(1, allSets.Count);
        }
示例#4
0
        public void DeleteTest()
        {
            var repo = new CardRepository();

            repo.Delete(1);

            var allSets = repo.SelectAll();

            Assert.IsNull(allSets.FirstOrDefault(c => c.CardID == 1));
        }
示例#5
0
 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"));
     }
 }
示例#6
0
 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));
     }
 }
示例#7
0
 public static void DeleteGroupMap(int idMap)
 {
   using (ICardRepository cardRepository = new CardRepository(true))
   {
     cardRepository.Delete<CardGroupMap>(p => p.IdMapping == idMap);
     cardRepository.UnitOfWork.SaveChanges();
   }
 }
示例#8
0
 public static void DeleteCard(int idCard)
 {
   using (ICardRepository cardRepository = new CardRepository(true))
   {
     cardRepository.Delete<Card>(p => p.IdCard == idCard);
     cardRepository.UnitOfWork.SaveChanges();
   }
 }