Exemplo n.º 1
0
        CreateQuotaValidations(CreateQuotasRequest createQuotasRequest, ref InfoClientDto infoClientDto)
        {
            (bool clientIsValid, HttpStatusCode clientatusCode, string clientMessage) =
                ClientValidations(createQuotasRequest.IdClient, createQuotasRequest.Quotas.Sum(c => c.CapitalValue),
                                  ref infoClientDto);
            if (!clientIsValid)
            {
                return(false, clientatusCode, clientMessage);
            }
            long idCredit = createQuotasRequest.Quotas.FirstOrDefault().IdCredit;

            if (createQuotasRequest.Quotas.Count > 1)
            {
                foreach (QuotaDataDto quota in createQuotasRequest.Quotas)
                {
                    if (quota.IdCredit != idCredit)
                    {
                        return(false, HttpStatusCode.BadRequest, IdCreditError);
                    }
                }
            }
            if (!_quotaRepository.CreditExist(createQuotasRequest.IdClient, idCredit).Result)
            {
                return(false, HttpStatusCode.BadRequest, CreditNoExist);
            }
            return(true, HttpStatusCode.OK, "");
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([FromBody] CreateQuotasRequest createQuotasRequest)
        {
            (HttpStatusCode statusCode, string message, bool response) =
                await _quotaBusiness.CreateQuotas(createQuotasRequest);

            if (statusCode != HttpStatusCode.NoContent && Response != null)
            {
                Response.StatusCode = (int)statusCode;
            }
            return(ServiceAnswer <bool> .Response(statusCode, message, response));
        }
Exemplo n.º 3
0
        CreateQuotas(CreateQuotasRequest createQuotasRequest)
        {
            InfoClientDto infoClientDto = null;

            (bool isValid, HttpStatusCode validationStatusCode, string validationMessage) =
                CreateQuotaValidations(createQuotasRequest, ref infoClientDto);
            if (!isValid)
            {
                return(validationStatusCode, validationMessage, false);
            }
            List <QuotaEntity> quotas = _mapper.Map <List <QuotaEntity> >(createQuotasRequest.Quotas);

            return(HttpStatusCode.OK, SuccessMsg, _quotaRepository.Create(quotas).Result);
        }