private double MapAbonoPuntos(CreditCustomerDTO creditCustomerDTO, Customer customer)
        {
            if (creditCustomerDTO.Abono >= 1000)
            {
                customer.Puntos = 200;
            }
            else
            {
                customer.Puntos = 50;
            }

            return(customer.Puntos);
        }
        public IActionResult Put([FromBody] CreditCustomerDTO creditCustomerDTO)
        {
            if (creditCustomerDTO == null)
            {
                return(BadRequest());
            }

            var response = application.Update(creditCustomerDTO);

            if (response.IsSuccess)
            {
                return(Ok(response));
            }

            return(BadRequest(response.Message));
        }
        public async Task <IActionResult> PutAsync([FromBody] CreditCustomerDTO creditCustomerDTO)
        {
            if (creditCustomerDTO == null)
            {
                return(BadRequest());
            }

            var response = await application.UpdateAsync(creditCustomerDTO);

            if (response.IsSuccess)
            {
                return(Ok(response));
            }

            return(BadRequest(response.Message));
        }
Exemplo n.º 4
0
        private async void abonoButton_Click(object sender, EventArgs e)
        {
            var addCustomerDTO = new CreditCustomerDTO()
            {
                Abono = Convert.ToDouble(montoAbonoText.Text),
                DNI   = documentoIdentidadText.Text,
            };

            var json    = JsonConvert.SerializeObject(addCustomerDTO);
            var content = new StringContent(json, Encoding.UTF8, "application/json");
            HttpResponseMessage httpResponse = await httpClient.PutAsync($"{apiURL}/customers/putAsync", content);

            Response <bool> response = await httpResponse.Content.ReadAsAsync <Response <bool> >();

            if (response.IsSuccess)
            {
                MessageBox.Show(response.Message, "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            MessageBox.Show(response.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
        public Response <bool> Update(CreditCustomerDTO creditCustomerDTO)
        {
            var response = new Response <bool>();

            try
            {
                var customer = mapper.Map <Customer>(creditCustomerDTO);
                response.Data = domain.Update(customer);

                if (response.Data)
                {
                    response.IsSuccess = true;
                    response.Message   = "Actualizacíón exitosa";
                }
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
            }

            return(response);
        }