public static List <Models.ProductoEditVM> IniModalEdit(string Id)
        {
            List <Models.ProductoEditVM> lista = new List <Models.ProductoEditVM>();

            try
            {
                if (Id != "0")
                {
                    Int64               IdPedido = Convert.ToInt64(Id);
                    ApiServices         objApi   = new ApiServices();
                    string              Request  = "{}";
                    HttpResponseMessage response = objApi.CallService("productos/ProductsByIdProd/" + IdPedido, Request, ApiServices.TypeMethods.GET).Result;

                    if (response.IsSuccessStatusCode)
                    {
                        //resp = await response.Content.ReadAsAsync();
                        string        Respuesta = response.Content.ReadAsStringAsync().Result;
                        Models.ItemVM obj       = Newtonsoft.Json.JsonConvert.DeserializeObject <Models.ItemVM>(Respuesta);
                        if (obj != null)
                        {
                            //lista.Add(new Models.Productos
                            //{
                            //    Id = obj.Id,
                            //    Nombre = obj.Nombre,
                            //    Descripcion = obj.Descripcion,
                            //    CodigoDescuento = obj.CodigoDescuento,
                            //    Cantidad = obj.Cantidad,
                            //    PorcentajeDescuento = obj.PorcentajeDesc,
                            //    FechaVencimiento = obj.FechaVencimiento,
                            //    Imagen = obj.Imagen,
                            //    IdUsuario = obj.IdUsuario
                            //});
                            lista.Add(new Models.ProductoEditVM
                            {
                                Id                  = obj.Id,
                                Nombre              = obj.Nombre,
                                Descripcion         = obj.Descripcion,
                                CodigoDescuento     = obj.CodigoDescuento,
                                Cantidad            = obj.Cantidad,
                                PorcentajeDescuento = obj.PorcentajeDesc,
                                FechaVencimiento    = obj.FechaVencimiento,
                                Imagen              = obj.Imagen,
                                IdUsuario           = obj.IdUsuario,
                                IdCategoria         = obj.IdCategoria,
                                FechaVenceAnio      = (obj.FechaVencimiento != null) ? obj.FechaVencimiento.Value.Year : 2020,
                                FechaVenceMes       = (obj.FechaVencimiento != null) ? obj.FechaVencimiento.Value.Month : 12,
                                FechaVenceDia       = (obj.FechaVencimiento != null) ? obj.FechaVencimiento.Value.Day.ToString().PadLeft(2, '0') : "31",
                            });
                        }
                    }
                }
            }
            catch
            {
                int sss = 0;
            }
            return(lista);
        }
Beispiel #2
0
        public void GetDetalleProducto(int idProd)
        {
            ApiServices         objApi   = new ApiServices();
            string              Request  = "{}";
            HttpResponseMessage response = objApi.CallService("Productos/" + idProd, Request, ApiServices.TypeMethods.GET).Result;

            if (response.IsSuccessStatusCode)
            {
                string        Respuesta = response.Content.ReadAsStringAsync().Result;
                Models.ItemVM obj       = Newtonsoft.Json.JsonConvert.DeserializeObject <Models.ItemVM>(Respuesta);

                LblTitulo.Text          = "Detalle de Canje #" + obj.Id.ToString();
                LblUsuarioVendedor.Text = obj.Usuario.ToString();
                LblFechaAltaCanje.Text  = obj.Fecha_Publicacion.Value.ToShortDateString();
                LblImporte.Text         = "$" + obj.Importe.ToString();
                imgUsuario.ImageUrl     = obj.UsuarioImagen;

                string data = "";
                data += "<div class='row mt-3'> ";
                data += "<div class='col-6 pr-1'> ";
                data += "<img src='" + obj.Imagen + "' class='mb-2 mw-100 w-100 rounded' alt='image'> ";
                //if (obj.im != null)
                //    data += "<img src='" + obj.Imagen2 + "' class='mw-100 w-100 rounded' alt='image'> ";

                data += "</div> ";
                data += "</div> ";

                LitImgCanje.Text = data;

                ///////////////
                string dataProd = "";
                dataProd += "<div class='d-flex mt-5 align-items-top'> ";
                //dataProd += "<img src='"+obj.Usuarios.Imagen+"' class='img-sm rounded-circle mr-3' alt='image'> ";
                dataProd += "<div class='mb-0 flex-grow'> ";
                dataProd += "<h5 class='mr-2 mb-2'>" + obj.Nombre + "</h5> ";
                dataProd += "<p class='mb-0 font-weight-light'>" + obj.Descripcion + "</p> ";
                dataProd += "</div></div> ";

                LitDetalleCanje.Text = dataProd;
                DivMatch.Visible     = false;
            }
            else
            {
                string RespuestaService  = response.Content.ReadAsStringAsync().Result;
                ApiServices.Response obj = Newtonsoft.Json.JsonConvert.DeserializeObject <ApiServices.Response>(RespuestaService);
                RespuestaService = response.StatusCode + " - " + obj.Error.message;
            }
            //return ListaOrdenes;
        }