コード例 #1
0
        public async Task <ActionResult> pvwAddFundingInterestRate([FromBody] FundingInterestRateDTO _sarpara)

        {
            FundingInterestRateDTO _FundingInterestRate = new FundingInterestRateDTO();

            try
            {
                string     baseadress = config.Value.urlbase;
                HttpClient _client    = new HttpClient();
                _client.DefaultRequestHeaders.Add("Authorization", "Bearer " + HttpContext.Session.GetString("token"));
                var result = await _client.GetAsync(baseadress + "api/FundingInterestRate/GetFundingInterestRateById/" + _sarpara.Id);

                string valorrespuesta = "";
                if (result.IsSuccessStatusCode)
                {
                    valorrespuesta       = await(result.Content.ReadAsStringAsync());
                    _FundingInterestRate = JsonConvert.DeserializeObject <FundingInterestRateDTO>(valorrespuesta);
                }

                if (_FundingInterestRate == null)
                {
                    _FundingInterestRate = new FundingInterestRateDTO();
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                throw ex;
            }

            return(PartialView(_FundingInterestRate));
        }
コード例 #2
0
        public async Task <ActionResult <FundingInterestRate> > SaveFundingInterestRate([FromBody] FundingInterestRateDTO _FundingInterestRateS)
        {
            {
                string valorrespuesta = "";
                try
                {
                    FundingInterestRate _listVendorType = new FundingInterestRate();
                    string     baseadress = config.Value.urlbase;
                    HttpClient _client    = new HttpClient();
                    _client.DefaultRequestHeaders.Add("Authorization", "Bearer " + HttpContext.Session.GetString("token"));
                    var result = await _client.GetAsync(baseadress + "api/FundingInterestRate/GetFundingInterestRateByDescripcion/" + _FundingInterestRateS.Descripcion);

                    if (result.IsSuccessStatusCode)
                    {
                        valorrespuesta  = await(result.Content.ReadAsStringAsync());
                        _listVendorType = JsonConvert.DeserializeObject <FundingInterestRate>(valorrespuesta);
                        if (_listVendorType != null && _FundingInterestRateS.Id == 0)
                        {
                            if (_listVendorType.Descripcion == _FundingInterestRateS.Descripcion)
                            {
                                result = await _client.GetAsync(baseadress + "api/FundingInterestRate/GetFundingInterestRateByMonths/" + _FundingInterestRateS.Months);

                                if (result.IsSuccessStatusCode)
                                {
                                    valorrespuesta  = await(result.Content.ReadAsStringAsync());
                                    _listVendorType = JsonConvert.DeserializeObject <FundingInterestRate>(valorrespuesta);
                                    if (_listVendorType != null && _FundingInterestRateS.Id == 0)
                                    {
                                        if (_listVendorType.Months == _FundingInterestRateS.Months)
                                        {
                                            return(await Task.Run(() => BadRequest($"Ya existe una tasa de interes registrada con ese mes.")));
                                        }
                                    }
                                }
                            }
                        }
                    }



                    result = await _client.GetAsync(baseadress + "api/FundingInterestRate/GetFundingInterestRateById/" + _FundingInterestRateS.Id);

                    _FundingInterestRateS.FechaModificacion   = DateTime.Now;
                    _FundingInterestRateS.UsuarioModificacion = HttpContext.Session.GetString("user");
                    if (result.IsSuccessStatusCode)
                    {
                        valorrespuesta  = await(result.Content.ReadAsStringAsync());
                        _listVendorType = JsonConvert.DeserializeObject <FundingInterestRate>(valorrespuesta);
                    }

                    if (_listVendorType == null)
                    {
                        _listVendorType = new Models.FundingInterestRate();
                    }

                    if (_listVendorType.Id == 0)
                    {
                        _FundingInterestRateS.FechaCreacion   = DateTime.Now;
                        _FundingInterestRateS.UsuarioCreacion = HttpContext.Session.GetString("user");
                        var insertresult = await Insert(_FundingInterestRateS);
                    }
                    else
                    {
                        _FundingInterestRateS.FechaCreacion   = DateTime.Now;
                        _FundingInterestRateS.UsuarioCreacion = HttpContext.Session.GetString("user");
                        var updateresult = await Update(_FundingInterestRateS.Id, _FundingInterestRateS);
                    }
                }
                catch (Exception ex)
                {
                    _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                    throw ex;
                }

                return(Json(_FundingInterestRateS));
            }
        }