示例#1
0
        public bool Delete(int id)
        {
            var entity = _vouRepo.GetById(id);

            if (entity == null)
            {
                return(false);
            }
            return(_vouRepo.Delete(entity));
        }
示例#2
0
        public IActionResult DeleteVoucher([FromRoute] long id)
        {
            Voucher fin = Vou_repo.Find(id);

            if (fin == null)
            {
                return(NotFound());
            }
            else if (fin.IsFinal == true)
            {
                return(BadRequest("Can't delete posted vouchers"));
            }
            VouDetail_repo.DeleteRange(VouDetail_repo.GetList(a => a.VoucherId == fin.VoucherId));
            Vou_repo.Delete(fin);
            return(Ok());
        }
        public async Task <IActionResult> DeleteVoucher(VoucherCreationDto dto)
        {
            try
            {
                await _voucherRepository.Delete(dto);

                return(Ok());
            }
            catch (Exception e)
            {
                return(NotFound("This Voucher cannot be delete"));
            }
        }
        public IActionResult DeleteVoucher(int id)
        {
            string deleteMessage = null;

            // pokus o odstranění voucheru z DB
            try
            {
                // odstranění voucheru z DB
                Voucher voucher = voucherRepository.Delete(id);
                deleteMessage = "Voucher byl úspěšně smazán";
                // přesměrování uživatele na přehled voucherů
                return(RedirectToAction("index", new { DeleteMessage = deleteMessage }));
            }
            // odchycení případné chyby spojené s chybou v DB při odstraňování voucherz
            catch (DbUpdateException)
            {
                deleteMessage = $"Voucher se nepodařilo smazat";
                return(RedirectToAction("index", new { DeleteMessage = deleteMessage }));
            }
        }
示例#5
0
 public Voucher Delete(int id)
 {
     return(_voucher.Delete(id));
 }
示例#6
0
 public async Task <ActionResult <Voucher> > DeleteById(int id)
 {
     return(await _voucherRepository.Delete(id));
 }