예제 #1
0
        public async Task <EntrenamientoVM> GetWodPreview(SolicitudEntrenamiento datos)
        {
            try
            {
                string        url      = "https://www.creativasoftlineapps.com/ScriptAppUnoMasCliente/frmGetWodPreview.aspx";
                string        content  = JsonConvert.SerializeObject(datos);
                StringContent body     = new StringContent(content, Encoding.UTF8, "application/json");
                var           response = await Client.PostAsync(url, body);

                if (response.IsSuccessStatusCode)
                {
                    var json = await response.Content.ReadAsStringAsync();

                    if (json.Substring(0, 5) != "Error")
                    {
                        var resultado = (EntrenamientoVM)JsonConvert.DeserializeObject(json, typeof(EntrenamientoVM));
                        return(resultado);
                    }
                }
                return(null);
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #2
0
        private async Task CargarEntrenamiento()
        {
            try
            {
                ApiService dataServices = new ApiService();

                if (id != null && id != "")
                {
                    solicitudWodPreview = new SolicitudEntrenamiento {
                        id_wod = id
                    }
                }
                ;

                try
                {
                    var result = await dataServices.GetWodPreview(solicitudWodPreview);

                    if (result != null)
                    {
                        wodPreviewViewModel = result;
                    }
                }
                catch (Exception ex)
                {
                    msgError = ex.Message.ToString();
                }
            }
            catch (Exception ex)
            {
                msgError = ex.Message.ToString();
            }
        }