Esempio n. 1
0
        public async Task <CreateDebtResponse> DebtorUpdateDebtAsync(UpdateDebtRequest model)
        {
            var debtId = await _moneyAdviserGateway.UpdateDebtAsync(model);

            return(new CreateDebtResponse {
                DebtId = debtId
            });
        }
Esempio n. 2
0
        public async Task <IActionResult> Update([FromBody] UpdateDebtRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            await _debtService.Update(request);

            return(Ok());
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 6
0
        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))));
        }