Пример #1
0
        public double calculating(string typecurency, double amount, string tocurrency)
        {
            usd   = new USD();
            pound = new POUND();
            euro  = new EURO();
            yuan  = new YUAN();

            if (typecurency.Equals("usd"))
            {
                return(amount * usd.getRate(tocurrency));
            }
            else if (typecurency.Equals("pound"))
            {
                return(amount * pound.getRate(tocurrency));
            }
            else if (typecurency.Equals("euro"))
            {
                return(amount * euro.getRate(tocurrency));
            }
            else
            {
                return(amount * yuan.getRate(tocurrency));
            }
        }
        private async void BtnGuardarDimensiones_Clicked(object sender, EventArgs e)
        {
            string connectionString = ConfigurationManager.AppSettings["ipServer"];

            try
            {
                var USAV           = USA.Text;
                var UKV            = UK.Text;
                var EUROV          = EURO.Text;
                var CMV            = CM.Text;
                var CategoriaSizeV = pickerCategoriaSizes.SelectedIndex + 1;


                if (string.IsNullOrEmpty(USAV))
                {
                    await DisplayAlert("Validacion", "Ingrese el Size de USA", "Aceptar");

                    USA.Focus();
                    return;
                }
                if (string.IsNullOrEmpty(UKV))
                {
                    await DisplayAlert("Validacion", "Ingrese el Size de UK", "Aceptar");

                    UK.Focus();
                    return;
                }
                if (string.IsNullOrEmpty(EUROV))
                {
                    await DisplayAlert("Validacion", "Ingrese el Size de EURO", "Aceptar");

                    EURO.Focus();
                    return;
                }
                if (string.IsNullOrEmpty(CMV))
                {
                    await DisplayAlert("Validacion", "Ingrese el Size por CM", "Aceptar");

                    CM.Focus();
                    return;
                }
                if (string.IsNullOrEmpty(CategoriaSizeV.ToString()))
                {
                    await DisplayAlert("Validacion", "Seleccione la Categoria del Sizes", "Aceptar");

                    pickerCategoriaSizes.Focus();
                    return;
                }

                HttpClient client = new HttpClient();
                client.BaseAddress = new Uri(connectionString);

                var sizes = new Sizes()
                {
                    SizeID          = 0,
                    USA             = USAV,
                    UK              = UKV,
                    EURO            = EUROV,
                    CM              = CMV,
                    CategoriaSizeID = CategoriaSizeV
                };

                //Convetir a Json
                var           json          = JsonConvert.SerializeObject(sizes);
                StringContent stringContent = new StringContent(json, Encoding.UTF8, "application/json");

                //Ejecutar el api el introduces el metodo
                var request = await client.PostAsync("/api/Size/registrar", stringContent);

                if (request.IsSuccessStatusCode)
                {
                    var responseJson = await request.Content.ReadAsStringAsync();

                    var respuesta = JsonConvert.DeserializeObject <Request>(responseJson);

                    //Status
                    if (respuesta.status)
                    {
                        await MaterialDialog.Instance.AlertAsync(message : "Sizes registrado correctamente",
                                                                 title : "Registro",
                                                                 acknowledgementText : "Aceptar");
                    }
                    else
                    {
                        await MaterialDialog.Instance.AlertAsync(message : "Sizes no pudo registrarse correctamente",
                                                                 title : "Registro",
                                                                 acknowledgementText : "Aceptar");
                    }
                }
                else
                {
                    await MaterialDialog.Instance.AlertAsync(message : "Error",
                                                             title : "Error",
                                                             acknowledgementText : "Aceptar");
                }
            }
            catch (Exception ex)
            {
                await MaterialDialog.Instance.AlertAsync(message : ex.Message,
                                                         title : "Error",
                                                         acknowledgementText : "Aceptar");
            }
            await Navigation.PushAsync(new Dimensiones.GestionarDimensiones());
        }