public void TestCRUD()
        {
            Core.Entities.Transfer read;
            var entity = testEntity;

            repository.Add(entity);
            Assert.IsTrue(entity.TransferId > 0, "TransferId not set");

            read = repository.Read(entity.TransferId);
            Assert.IsNotNull(read);
            Assert.IsNotNull(read.FromBankAccount);
            Assert.IsNotNull(read.FromBankAccount.Name);
            Assert.IsNotNull(read.FromBankAccount.Bank);
            Assert.IsNotNull(read.FromBankAccount.Bank.Name);
            Assert.IsNotNull(read.ToBankAccount);
            Assert.IsNotNull(read.ToBankAccount.Name);
            Assert.IsNotNull(read.ToBankAccount.Bank);
            Assert.IsNotNull(read.ToBankAccount.Bank.Name);
            Assert.IsNotNull(read.Category);
            Assert.IsNotNull(read.Category.Name);

            CompareTransfers(entity, read, "Read");

            entity.Name += "-UPDATE";
            repository.Update(entity);
            read = repository.Read(entity.TransferId);
            Assert.IsNotNull(read);
            CompareTransfers(entity, read, "Update");

            repository.Delete(entity);

            read = repository.Read(entity.TransferId);
            Assert.IsNull(read);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            transferRepository.Delete(id);
            transferRepository.Save();

            return(RedirectToAction("Index"));
        }
示例#3
0
        public ActionResult DeleteConfirmed(int id)
        {
            var transferVm = new TransferViewModel();

            transferVm.Transfer = _transferRepository.GetWhere(transfer => transfer.Id == id).FirstOrDefault();
            if (transferVm.Transfer == null)
            {
                return(HttpNotFound());
            }
            _transferRepository.Delete(transferVm.Transfer);
            _bankAccountLogic.CalculateBalanceOfAllAccounts();
            return(RedirectToAction("Index"));
        }
示例#4
0
        public async Task <IActionResult> DeleteTransfer([FromRoute] int id)
        {
            Transfer record = await repo.GetByIdToDelete(id);

            if (record == null)
            {
                LoggerExtensions.LogException(id, logger, ControllerContext, null, null);
                return(StatusCode(404, new {
                    response = ApiMessages.RecordNotFound()
                }));
            }
            try {
                repo.Delete(record);
                SendNotificationsToClients();
                return(StatusCode(200, new {
                    response = ApiMessages.RecordDeleted()
                }));
            } catch (DbUpdateException exception) {
                LoggerExtensions.LogException(0, logger, ControllerContext, record, exception);
                return(StatusCode(491, new {
                    response = ApiMessages.RecordInUse()
                }));
            }
        }