Пример #1
0
 public IActionResult DeleteRecord(long id)
 {
     _logger.LogInformation($"{nameof(RecordController)} : {nameof(DeleteRecord)} was called.");
     try
     {
         var record = _recordService.FindById(id);
         if (record == null)
         {
             return(StatusCode((int)HttpStatusCode.Gone));
         }
         _recordService.Delete(record);
         _recordService.Save();
         return(Ok());
     }
     catch (DbException exception)
     {
         _logger.LogError(exception.Message);
         return(BadRequest(exception.Message));
     }
     catch (Exception exception)
     {
         _logger.LogError(exception.Message);
         throw;
     }
 }
Пример #2
0
        public IActionResult DeleteConfirmed(Guid id)
        {
            var news = _service.GetNewsById(id);

            _service.Delete(news);

            return(RedirectToAction(nameof(Index)));
        }
Пример #3
0
        public async Task <IActionResult> Delete([FromBody] RecordDo record)
        {
            if (record == null)
            {
                return(BadRequest(RecordShouldNotBeNull));
            }

            return(await TryExecutingServiceAsync(() => _recordService.Delete(record), Ok()));
        }
Пример #4
0
        public async Task Delete(Guid id)
        {
            var record = await _recordService.GetById(id);

            if (record != null)
            {
                await _recordService.Delete(record);
            }
        }
Пример #5
0
        public async Task Delete_ShouldCallUnitOfWorkDeleteAndSaveChanges()
        {
            CreateSubject();
            var record = new RecordDo();

            await _subject.Delete(record);

            await _unitOfWork.Received().SaveChangesAsync();
        }
Пример #6
0
        public async Task <IActionResult> Delete(string id)
        {
            var result = await recordService.Delete(UserId, id);

            if (result.Succeeded)
            {
                return(Ok());
            }
            return(BadRequest(result.Error));
        }
        public async Task Delete_WhenRecordServiceThrowException_ShouldReturnInternalServerError()
        {
            var record = Substitute.For <RecordDo>();

            _recordService.Delete(record).Throws <Exception>();

            var result = await _recordsController.Delete(record);

            result.Should().BeOfType <StatusCodeResult>();
            result.As <StatusCodeResult>().StatusCode.Should().Be(500);
        }
Пример #8
0
        public IActionResult Delete(int idRecord)
        {
            Record record      = _recordService.GetById(idRecord);
            int    entryTypeId = _categoryService.GetById(record.CategoryId).EntryTypeId;
            bool   isIncome    = _entryTypeService.CheckIfIncome(entryTypeId);

            record.MoneyAmount = record.MoneyAmount * -1;

            _accountService.ChangeAccountMoneyAmount(record.AccountId, record.MoneyAmount, isIncome);
            _recordService.Delete(idRecord);

            return(Ok());
        }
Пример #9
0
        public async Task <IActionResult> DeleteRecord(short id)
        {
            var currentUserId = int.Parse(User.Identity.Name);

            try
            {
                var entity = await _recordService.Delete(id, currentUserId);

                return(Ok(entity));
            }
            catch (Exception ex)
            {
                return(BadRequest(new { message = ex.Message }));
            }
        }
Пример #10
0
        public async Task <IActionResult> DeleteRecord([FromRoute] int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var record = await _recordService.FindBy(m => m.RecordId == id);

            if (record == null)
            {
                return(NotFound());
            }

            await _recordService.Delete(record);

            return(Ok(record));
        }
        public async Task <IActionResult> Delete(TId id)
        {
            _log.LogDebug("Recieved Delete request");
            try
            {
                await _service.Delete(id);

                return(Ok());
            }
            catch (NotFoundException e)
            {
                _log.LogError(e, "There was an error processing a Delete request");
                return(NotFound(e.Message));
            }
            catch (Exception e)
            {
                _log.LogError(e, "There was an error processing a Delete request");
                return(BadRequest(e.Message));
            }
        }
 public IHttpActionResult Delete(int id)
 {
     recordService.Delete(id);
     return(Ok());
 }
Пример #13
0
 public IActionResult Delete(int id)
 {
     _recordsService.Delete(id);
     return(NoContent());
 }
Пример #14
0
 public void Delete(IEnumerable <ITransaction> entities)
 {
     // only actual transactions can be removed
     _recordService.Delete(entities.Where(x => x is RecordModel).Select(x => x as RecordModel));
     _moneyTransferService.Delete(entities.Where(x => x is MoneyTransferModel).Select(x => x as MoneyTransferModel));
 }
Пример #15
0
 public ActionResult Delete(int recordId)
 {
     recordService.Delete(recordId, User.Identity.Name);
     return(Json(new { success = true }));
 }
Пример #16
0
        public async Task Delete()
        {
            var result = await recordService.Delete(userId, recordId);

            Assert.IsTrue(result.Succeeded);
        }
Пример #17
0
        public async Task <IHttpActionResult> Delete([FromBody] int id)
        {
            await _recordService.Delete(id);

            return(Ok());
        }
Пример #18
0
        public async Task <ActionResult> Delete(int id)
        {
            await _recordService.Delete(id);

            return(RedirectToAction("Index"));
        }
Пример #19
0
 public static void Delete(this IRecordService recordService, IRecord record)
 {
     recordService.Delete(record.Type, record.Id);
 }
Пример #20
0
 public void Delete(int id)
 {
     _service.Delete(id);
 }