public async Task <CreateDebtResponse> DebtorUpdateDebtAsync(UpdateDebtRequest model) { var debtId = await _moneyAdviserGateway.UpdateDebtAsync(model); return(new CreateDebtResponse { DebtId = debtId }); }
public async Task <IActionResult> Update([FromBody] UpdateDebtRequest request) { if (!ModelState.IsValid) { return(BadRequest()); } await _debtService.Update(request); return(Ok()); }
public async Task Update(UpdateDebtRequest request) { Debtor debtor = await _debtorRepository.GetById(request.DebtorId); if (debtor is null) { throw new AppCustomException(StatusCodes.Status400BadRequest, "Debtor does not exist"); } Debt debt = _mapper.Map <UpdateDebtRequest, Debt>(request); await _debtRepository.Update(debt); }
public async Task <bool> UpdateDebtAsync(int debtId, UpdateDebtRequest request) { var debtDto = new UpdateDebtDto { Id = debtId, Name = request.Name, Description = request.Description, InitialValue = request.InitialValue }; var debt = _mapper.Map <Debt>(debtDto); return(await _baseRepository.UpdateEntityAsync(debt)); }
public async Task <Guid> UpdateDebtAsync(UpdateDebtRequest model) { await _client.For <Ntt_breathingspacedebt>() .Key(model.DebtId) .Action("ntt_BSSDebtUpdate") .Set(model.ToDictionary().SetDynamicsActionAuditParameters(_auditContext)) .ExecuteAsync(); var contentDict = model.ToDictionary(); contentDict.Add(nameof(model.DebtId), model.DebtId); contentDict.Add("ntt_BSSDebtUpdate", true); await _auditService.PerformAuditing(_auditContext.ToAuditDetail(contentDict)); return(model.DebtId); }
public async Task <IActionResult> UpdateDebt([FromRoute] int debtId, [FromBody] UpdateDebtRequest request) { var userId = User.Claims.FirstOrDefault(c => c.Type == "id").Value; // check if user exists var userExists = await _identityService.CheckIfUserExists(userId); if (!userExists) { return(NotFound(new ErrorResponse(new ErrorModel { Message = $"There is no user with id: {userId}" }))); } var debtInDb = await _debtService.GetDebtAsync(debtId); if (debtInDb == null) { return(NotFound(new ErrorResponse(new ErrorModel { Message = $"There is no debt with id: {debtId}" }))); } if (debtInDb.UserId != userId) { return(Forbid()); } var updateDebt = await _debtService.UpdateDebtAsync(debtId, request); if (!updateDebt) { return(BadRequest(new ErrorResponse(new ErrorModel { Message = $"Could not update debt with id:{debtId}" }))); } var updatedDebt = await _debtService.GetDebtAsync(debtId); return(Ok(new Response <DebtResponse>(_mapper.Map <DebtResponse>(updatedDebt)))); }