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; } }
public IActionResult DeleteConfirmed(Guid id) { var news = _service.GetNewsById(id); _service.Delete(news); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Delete([FromBody] RecordDo record) { if (record == null) { return(BadRequest(RecordShouldNotBeNull)); } return(await TryExecutingServiceAsync(() => _recordService.Delete(record), Ok())); }
public async Task Delete(Guid id) { var record = await _recordService.GetById(id); if (record != null) { await _recordService.Delete(record); } }
public async Task Delete_ShouldCallUnitOfWorkDeleteAndSaveChanges() { CreateSubject(); var record = new RecordDo(); await _subject.Delete(record); await _unitOfWork.Received().SaveChangesAsync(); }
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); }
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()); }
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 })); } }
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()); }
public IActionResult Delete(int id) { _recordsService.Delete(id); return(NoContent()); }
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)); }
public ActionResult Delete(int recordId) { recordService.Delete(recordId, User.Identity.Name); return(Json(new { success = true })); }
public async Task Delete() { var result = await recordService.Delete(userId, recordId); Assert.IsTrue(result.Succeeded); }
public async Task <IHttpActionResult> Delete([FromBody] int id) { await _recordService.Delete(id); return(Ok()); }
public async Task <ActionResult> Delete(int id) { await _recordService.Delete(id); return(RedirectToAction("Index")); }
public static void Delete(this IRecordService recordService, IRecord record) { recordService.Delete(record.Type, record.Id); }
public void Delete(int id) { _service.Delete(id); }