Ejemplo n.º 1
0
        public async Task <IActionResult> Put(Guid ImagenId, [FromBody] ImagenDTO imagen)
        {
            imagen.ImaId = ImagenId;
            await Service.Insert(imagen);

            return(Ok(true));
        }
Ejemplo n.º 2
0
        public int delete(ImagenDTO imagenDTO)
        {
            int retorno = 0;

            string        sql = "DELETE FROM Imagen WHERE imagenID=@imagenID";
            SqlConnection con = new SqlConnection(connectionString);
            SqlCommand    cmd = new SqlCommand(sql, con);

            cmd.Parameters.AddWithValue("@imagenID", imagenDTO.imagenID);
            cmd.CommandType = CommandType.Text;
            con.Open();

            try
            {
                retorno = cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                retorno = 0;
            }
            finally
            {
                con.Close();
            }
            return(retorno);
        }
Ejemplo n.º 3
0
        public IHttpActionResult verempresas()
        {
            try
            {
                List <EmpresaDTO> Empresas = new List <EmpresaDTO>();
                var listem = empresaServicio.ObtenerEmpresas();
                foreach (var e in listem)
                {
                    ImagenDTO i = new ImagenDTO()
                    {
                        idEmpresa = e.idEmpresa,
                        principal = true
                    };
                    Empresas.Add(new EmpresaDTO
                    {
                        idEmpresa    = e.idEmpresa,
                        nombrempresa = e.nombreEmpresa,
                        nit          = e.nit,
                        razon        = e.razonSocial,
                        direccion    = e.direccionCentral,
                        rutaimagen   = imagenServicio.Obtenerimagen(i)
                    });
                }

                return(Ok(RespuestaApi <List <EmpresaDTO> > .createRespuestaSuccess(Empresas, "success")));
            }
            catch (Exception ex)
            {
                return(Ok(RespuestaApi <string> .createRespuestaError(ex.ToString(), "error")));
            }
        }
Ejemplo n.º 4
0
        public IHttpActionResult verempresa([FromBody] EmpresaDTO e)
        {
            try
            {
                Empresa    em  = new Empresa();
                EmpresaDTO emp = new EmpresaDTO();
                em = empresaServicio.ObtenerEmpresa(e);
                ImagenDTO i = new ImagenDTO()
                {
                    idEmpresa = em.idEmpresa,
                    principal = true
                };
                emp.idEmpresa    = em.idEmpresa;
                emp.nombrempresa = em.nombreEmpresa;
                emp.nit          = em.nit;
                emp.razon        = em.razonSocial;
                emp.direccion    = em.direccionCentral;
                emp.rutaimagen   = imagenServicio.Obtenerimagen(i);

                return(Ok(RespuestaApi <EmpresaDTO> .createRespuestaSuccess(emp, "success")));
            }
            catch (Exception ex)
            {
                return(Ok(RespuestaApi <string> .createRespuestaError(ex.ToString(), "error")));
            }
        }
Ejemplo n.º 5
0
        public DataTable read(ImagenDTO imagenDTO)
        {
            //List<ExamenDTO> retornoDTO = new List<ExamenDTO>();

            DataTable dataTable = new DataTable();

            SqlConnection conn = new SqlConnection(connectionString);
            string        sql  = "select * from Imagen where imagenID = @imagenID";

            SqlCommand sqlcmd = new SqlCommand(sql, conn);

            sqlcmd.Parameters.Add(new SqlParameter("@imagenID", SqlDbType.Int));
            sqlcmd.Parameters["@imagenID"].Value = imagenDTO.ingresoID;

            try
            {
                conn.Open();
                SqlDataReader rdr = sqlcmd.ExecuteReader();
                dataTable.Load(rdr);
                rdr.Close();
            }
            catch
            {
                dataTable = null;
            }
            finally
            {
                conn.Close();
            }
            return(dataTable);
        }
Ejemplo n.º 6
0
        public IHttpActionResult versucursal([FromBody] SucursalDTO s)
        {
            try
            {
                Sucursal    su  = new Sucursal();
                SucursalDTO suc = new SucursalDTO();
                su = sucursalServicio.ObtenerSucursal(s);
                EmpresaDTO emm = new EmpresaDTO
                {
                    idEmpresa = su.idEmpresa
                };
                ImagenDTO i = new ImagenDTO()
                {
                    idSucursal = su.idSucursal,
                    principal  = true
                };
                suc.idSucursal    = su.idSucursal;
                suc.nombre        = su.nombreSucursal;
                suc.direccion     = su.direccion;
                suc.idEmpresa     = su.idEmpresa;
                suc.nombreEmpresa = empresaServicio.ObtenerEmpresa(emm).nombreEmpresa;
                suc.rutaimagen    = imagenServicio.Obtenerimagen(i);

                return(Ok(RespuestaApi <SucursalDTO> .createRespuestaSuccess(suc, "success")));
            }
            catch (Exception ex)
            {
                return(Ok(RespuestaApi <string> .createRespuestaError(ex.ToString(), "error")));
            }
        }
Ejemplo n.º 7
0
        public IHttpActionResult vercategorias()
        {
            try
            {
                List <CategoriaDTO> categorias = new List <CategoriaDTO>();
                var listca = categoriaServicio.Obtenercategorias();
                foreach (var e in listca)
                {
                    ImagenDTO i = new ImagenDTO()
                    {
                        idcategoria = e.idCategoria,
                        principal   = true
                    };
                    categorias.Add(new CategoriaDTO
                    {
                        idCategoria = e.idCategoria,
                        nombre      = e.nombreCategoria,
                        rutaimagen  = imagenServicio.Obtenerimagen(i)
                    });
                }

                return(Ok(RespuestaApi <List <CategoriaDTO> > .createRespuestaSuccess(categorias, "success")));
            }
            catch (Exception ex)
            {
                return(Ok(RespuestaApi <string> .createRespuestaError(ex.ToString(), "error")));
            }
        }
Ejemplo n.º 8
0
        public List <ImagenDTO> readxIngreso(ImagenDTO imagenDTO)
        {
            List <ImagenDTO> retornoDTO = new List <ImagenDTO>();
            ImagenDAO        ImagenDAO  = new ImagenDAO();

            DataTable dt = new DataTable();

            dt = ImagenDAO.readxIngreso(imagenDTO);

            ImagenDTO imDTO = null;

            foreach (DataRow row in dt.Rows)
            {
                imDTO = new ImagenDTO();

                imDTO.imagenID      = Convert.ToInt64(row["imagenID"].ToString());
                imDTO.fecha_informe = Convert.ToDateTime(row["fecha_informe"].ToString());
                imDTO.descripcion   = row["descripcion"].ToString();
                imDTO.diagnostico   = row["diagnostico"].ToString();
                imDTO.ingresoID     = Convert.ToInt64(row["ingresoID"].ToString());
                imDTO.ingresoID     = Convert.ToInt64(row["pacienteID"].ToString());

                retornoDTO.Add(imDTO);
            }

            return(retornoDTO);
        }
Ejemplo n.º 9
0
        public IHttpActionResult verproductos([FromBody] ProductoEmpresaDTO p)
        {
            try
            {
                List <ProductoEmpresaDTO> productos = new List <ProductoEmpresaDTO>();
                var listpro = productoempresaservico.Obtenerproductos(p);
                foreach (var pr in listpro)
                {
                    ProductoDTO pp = new ProductoDTO()
                    {
                        idProducto = pr.idProducto
                    };
                    long         idc = productoServicio.Obtenerproducto(pp).idCategoria;
                    CategoriaDTO c   = new CategoriaDTO()
                    {
                        idCategoria = idc
                    };
                    EmpresaDTO e = new EmpresaDTO()
                    {
                        idEmpresa = Convert.ToInt64(pr.idEmpresa)
                    };
                    ImagenDTO i = new ImagenDTO()
                    {
                        idProductoEmpresa = pr.idProductoEmpresa,
                        principal         = true
                    };
                    productos.Add(new ProductoEmpresaDTO
                    {
                        idProductoEmpresa = pr.idProductoEmpresa,
                        idProducto        = pr.idProducto,
                        precio            = Convert.ToDecimal(pr.Precio),
                        nombre            = productoServicio.Obtenerproducto(pp).nombreProducto,
                        idEmpresa         = Convert.ToInt64(pr.idEmpresa),
                        nombreEmpresa     = empresaSevicio.ObtenerEmpresa(e).nombreEmpresa,
                        idCategoria       = categoriaServicio.Obtenercategoria(
                            new CategoriaDTO()
                        {
                            idCategoria = productoServicio.Obtenerproducto(pp).idCategoria
                        }
                            ).idCategoria,
                        nombreCategoria = categoriaServicio.Obtenercategoria(
                            new CategoriaDTO()
                        {
                            idCategoria = productoServicio.Obtenerproducto(pp).idCategoria
                        }
                            ).nombreCategoria,
                        rutaimagen = imagenService.Obtenerimagen(i)
                    });
                }

                return(Ok(RespuestaApi <List <ProductoEmpresaDTO> > .createRespuestaSuccess(productos, "success")));
            }
            catch (Exception ex)
            {
                return(Ok(RespuestaApi <string> .createRespuestaError(ex.ToString(), "error")));
            }
        }
Ejemplo n.º 10
0
        public int delete(ImagenDTO imagenDTO)
        {
            int       retorno   = 0;
            ImagenDAO imagenDAO = new ImagenDAO();

            retorno = imagenDAO.delete(imagenDTO);

            return(retorno);
        }
Ejemplo n.º 11
0
        public async Task <IActionResult> Post([FromBody] ImagenDTO imagen)
        {
            //await Service.Insert(imagen);
            //return Ok(true);
            if (!ModelState.IsValid)
            {
                throw new Exception("Model is not Valid");
            }
            await Service.Insert(imagen);

            return(Ok(true));
        }
Ejemplo n.º 12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            cargardatospaciente();

            IngresoDTO  ingresoDTO  = (IngresoDTO)Session["ingresoDTO"];
            PacienteDTO pacienteDTO = (PacienteDTO)Session["pacienteDTO"];

            List <ExamenDTO> listExamenDTO = new List <ExamenDTO>();
            ExamenNEG        examenNEG     = new ExamenNEG();
            ExamenDTO        examenDTOIN   = new ExamenDTO();

            examenDTOIN.ingresoID = ingresoDTO.ingresoID;

            listExamenDTO = examenNEG.readxIngreso(examenDTOIN);

            gvExamenes.DataSource = listExamenDTO;
            gvExamenes.DataBind();


            List <ImagenDTO> listImagenDTO = new List <ImagenDTO>();
            ImagenNEG        imagenNEG     = new ImagenNEG();
            ImagenDTO        imagenDTOIN   = new ImagenDTO();

            imagenDTOIN.ingresoID = ingresoDTO.ingresoID;

            listImagenDTO = imagenNEG.readxIngreso(imagenDTOIN);

            gvImagenes.DataSource = listImagenDTO;
            gvImagenes.DataBind();

            //List<ImagenesDTO> listExamenDTO = new List<ImagenesDTO>();
            //ExamenNEG examenNEG = new ExamenNEG();
            //ExamenDTO examenDTOIN = new ExamenDTO();

            //gvImagenes.DataSource = dtImagenes;
            //gvImagenes.DataBind();

            //DataTable dtImagenes = new DataTable();

            //dtImagenes.Clear();
            //dtImagenes.Columns.Add("nombre_imagen");
            //dtImagenes.Columns.Add("fecha_imagen");
            //dtImagenes.Columns.Add("diagnostico");

            //DataRow rowImagenes = dtImagenes.NewRow();
            //rowImagenes["nombre_imagen"] = "Radiografia Pierna Derecha";
            //rowImagenes["fecha_imagen"] = "26/11/2016";
            //rowImagenes["diagnostico"] = "Diagnostico 1";
            //dtImagenes.Rows.Add(rowImagenes);

            //gvImagenes.DataSource = dtImagenes;
            //gvImagenes.DataBind();
        }
Ejemplo n.º 13
0
        public IHttpActionResult verproducto([FromBody] ProductoEmpresaDTO p)
        {
            try
            {
                ProductoEmpresa    pro      = new ProductoEmpresa();
                ProductoEmpresaDTO producto = new ProductoEmpresaDTO();
                pro = productoempresaservico.Obtenerproducto(p);
                ProductoDTO pp = new ProductoDTO()
                {
                    idProducto = pro.idProducto
                };
                long         idc = productoServicio.Obtenerproducto(pp).idCategoria;
                CategoriaDTO c   = new CategoriaDTO()
                {
                    idCategoria = idc
                };
                EmpresaDTO e = new EmpresaDTO()
                {
                    idEmpresa = Convert.ToInt64(pro.idEmpresa)
                };
                ImagenDTO i = new ImagenDTO()
                {
                    idProductoEmpresa = pro.idProductoEmpresa,
                    principal         = true
                };
                producto.idProductoEmpresa = pro.idProductoEmpresa;
                producto.idProducto        = pro.idProducto;
                producto.precio            = Convert.ToDecimal(pro.Precio);
                producto.nombre            = productoServicio.Obtenerproducto(pp).nombreProducto;
                producto.idEmpresa         = Convert.ToInt64(pro.idEmpresa);
                producto.nombreEmpresa     = empresaSevicio.ObtenerEmpresa(e).nombreEmpresa;
                producto.idCategoria       = categoriaServicio.Obtenercategoria(
                    new CategoriaDTO()
                {
                    idCategoria = productoServicio.Obtenerproducto(pp).idCategoria
                }
                    ).idCategoria;
                producto.nombreCategoria = categoriaServicio.Obtenercategoria(
                    new CategoriaDTO()
                {
                    idCategoria = productoServicio.Obtenerproducto(pp).idCategoria
                }
                    ).nombreCategoria;
                producto.rutaimagen = imagenService.Obtenerimagen(i);

                return(Ok(RespuestaApi <ProductoEmpresaDTO> .createRespuestaSuccess(producto, "success")));
            }
            catch (Exception ex)
            {
                return(Ok(RespuestaApi <string> .createRespuestaError(ex.ToString(), "error")));
            }
        }
Ejemplo n.º 14
0
        public ActionResult Nuevo(ImagenDTO imagen, ImageViewModel img)
        {
            try
            {
                var    random      = new Random().Next(0, 100);
                string extension   = Path.GetExtension(img.foto.FileName);
                bool   extensionOk = ValidarExtension(extension);

                if (extensionOk == true)
                {
                    Redimensionar(img.foto.InputStream);
                    string ImageName = System.IO.Path.GetFileName(img.foto.FileName);
                    imagen.Nombre = random + ImageName;

                    HttpClient clienteHttp = new HttpClient();
                    clienteHttp.BaseAddress = new Uri("http://localhost:5476/");

                    var request = clienteHttp.PostAsync("api/Imagen", imagen, new JsonMediaTypeFormatter()).Result;

                    if (request.IsSuccessStatusCode)
                    {
                        string physicalPath = Server.MapPath("~/Content/Imagenes/Upload/" + ImageName);

                        img.foto.SaveAs(physicalPath);

                        var resultString = request.Content.ReadAsStringAsync().Result;
                        var correcto     = JsonConvert.DeserializeObject <bool>(resultString);

                        if (correcto)
                        {
                            return(RedirectToAction("index"));
                        }

                        return(View(imagen));
                    }
                }
            }
            catch (Exception ex)
            {
                log.ErrorFormat("Error: {0}{1}", ex.StackTrace, ex.Message);
            }

            return(View());
        }
Ejemplo n.º 15
0
        public async Task <ActionResult> CambiarImagenProducto([FromRoute] Guid Id, [FromForm] ImagenDTO file)
        {
            var productoExiste = await _productosServicios.ObtenerProductoPorIdAsync(Id);

            if (productoExiste == null)
            {
                return(NotFound("Producto no encontrado"));
            }

            var destino    = $"wwwroot\\assets\\img\\productos\\";
            var rutaImagen = SubidaImagenProducto(file.Imagen, destino);

            var respuesta = await _productosServicios.ActualizarImagenProductoAsync(Id, rutaImagen);

            if (!respuesta)
            {
                return(BadRequest("No se pudo actualizar la imagen"));
            }

            return(Ok(rutaImagen));
        }
Ejemplo n.º 16
0
        public IHttpActionResult vercategoria([FromBody] CategoriaDTO c)
        {
            try
            {
                CategoriaProducto ca  = new CategoriaProducto();
                CategoriaDTO      cat = new CategoriaDTO();
                ca = categoriaServicio.Obtenercategoria(c);
                ImagenDTO i = new ImagenDTO()
                {
                    idcategoria = ca.idCategoria,
                    principal   = true
                };
                cat.idCategoria = ca.idCategoria;
                cat.nombre      = ca.nombreCategoria;
                cat.rutaimagen  = imagenServicio.Obtenerimagen(i);

                return(Ok(RespuestaApi <CategoriaDTO> .createRespuestaSuccess(cat, "success")));
            }
            catch (Exception ex)
            {
                return(Ok(RespuestaApi <string> .createRespuestaError(ex.ToString(), "error")));
            }
        }
Ejemplo n.º 17
0
        public object CalculateIA([FromBody] ImagenDTO imagen)
        {
            string imagenstring = imagen.imagenbase64.ToString();
            var    client       = new RestClient("http://40.84.190.225:5000/webhook");
            var    request      = new RestRequest(Method.POST);

            request.AddHeader("cache-control", "no-cache");
            request.AddHeader("Connection", "keep-alive");
            request.AddHeader("Content-Length", "120889");
            request.AddHeader("Accept-Encoding", "gzip, deflate");
            request.AddHeader("Cookie", "__RequestVerificationToken=WEDM7Tk3zf5Cfk7qX0EieOvRZnqYQa16YlH7BK47mIrmP0B3oN2kJEhOebbELQ7iXp0G3ZYgjVSMhqI_-VUkZahWDodmmfSIljKRUDKyuBc1");
            request.AddHeader("Host", "40.84.190.225:5000");
            /*BORRAR KEY POSTMAN LUEGO DE QUE FUNCIONE*/
            request.AddHeader("Postman-Token", "e253d782-6a01-4625-9376-c1e5f5abf419,449fda2c-a13e-4c4c-ad32-d24b1d93d0f5");
            request.AddHeader("Cache-Control", "no-cache");
            request.AddHeader("Accept", "*/*");
            request.AddHeader("User-Agent", "PostmanRuntime/7.15.2");
            request.AddHeader("Content-Type", "application/json");
            request.AddParameter("undefined", "{\n\t\"imagen\":\" " + imagenstring + " \"\n}\n", ParameterType.RequestBody);
            IRestResponse response    = client.Execute(request);
            var           countPerson = JsonConvert.DeserializeObject(response.Content);

            return(countPerson);
        }
Ejemplo n.º 18
0
        public IHttpActionResult versucursales([FromBody] SucursalDTO s)
        {
            try
            {
                List <SucursalDTO> Sucursales = new List <SucursalDTO>();
                var listsu = sucursalServicio.ObtenerSucursales(s);
                foreach (var e in listsu)
                {
                    EmpresaDTO emm = new EmpresaDTO
                    {
                        idEmpresa = e.idEmpresa
                    };
                    ImagenDTO i = new ImagenDTO()
                    {
                        idSucursal = e.idSucursal,
                        principal  = true
                    };
                    Sucursales.Add(new SucursalDTO
                    {
                        idSucursal    = e.idSucursal,
                        nombre        = e.nombreSucursal,
                        idEmpresa     = e.idEmpresa,
                        direccion     = e.direccion,
                        nombreEmpresa = empresaServicio.ObtenerEmpresa(emm).nombreEmpresa,
                        rutaimagen    = imagenServicio.Obtenerimagen(i),
                        abierto       = turnoServicio.comprobardisponibilidad(e.idSucursal)
                    });
                }

                return(Ok(RespuestaApi <List <SucursalDTO> > .createRespuestaSuccess(Sucursales, "success")));
            }
            catch (Exception ex)
            {
                return(Ok(RespuestaApi <string> .createRespuestaError(ex.ToString(), "error")));
            }
        }
Ejemplo n.º 19
0
        public IHttpActionResult verproductos([FromBody] ProductoDTO p)
        {
            try
            {
                List <ProductoDTO> productos = new List <ProductoDTO>();
                var listpro = productoServicio.Obtenerproductos(p);
                foreach (var pr in listpro)
                {
                    CategoriaDTO c = new CategoriaDTO()
                    {
                        idCategoria = pr.idCategoria
                    };
                    ImagenDTO i = new ImagenDTO()
                    {
                        idProducto = pr.idProducto,
                        principal  = true
                    };
                    productos.Add(new ProductoDTO
                    {
                        idProducto       = pr.idProducto,
                        nombre           = pr.nombreProducto,
                        descripcionCorta = pr.descripcionCortaProducto,
                        descripcionLarga = pr.descripcionLargaProducto,
                        idCategoria      = pr.idCategoria,
                        nombrecategoria  = categoriaServicio.Obtenercategoria(c).nombreCategoria,
                        rutaimagen       = imagenServicio.Obtenerimagen(i)
                    });
                }

                return(Ok(RespuestaApi <List <ProductoDTO> > .createRespuestaSuccess(productos, "success")));
            }
            catch (Exception ex)
            {
                return(Ok(RespuestaApi <string> .createRespuestaError(ex.ToString(), "error")));
            }
        }
Ejemplo n.º 20
0
        public IHttpActionResult verproducto([FromBody] ProductoSucursalDTO p)
        {
            try
            {
                ProductoSucursal    pro      = new ProductoSucursal();
                ProductoSucursalDTO producto = new ProductoSucursalDTO();
                pro = productosucursalService.Obtenerproducto(p);
                ProductoEmpresaDTO ppe = new ProductoEmpresaDTO()
                {
                    idProductoEmpresa = pro.idProductoEmpresa
                };
                long        idp = productoempresaservico.Obtenerproducto(ppe).idProducto;
                ProductoDTO pp  = new ProductoDTO()
                {
                    idProducto = idp
                };
                long         idc = productoServicio.Obtenerproducto(pp).idCategoria;
                CategoriaDTO c   = new CategoriaDTO()
                {
                    idCategoria = idc
                };
                SucursalDTO s = new SucursalDTO()
                {
                    idSucursal = pro.idSucursal
                };
                long       ide = sucursalService.ObtenerSucursal(s).idEmpresa;
                EmpresaDTO e   = new EmpresaDTO()
                {
                    idEmpresa = ide
                };
                ImagenDTO i3 = new ImagenDTO()
                {
                    idProductoSucursal = pro.idProductoSucursal,
                    principal          = true
                };
                ImagenDTO i2 = new ImagenDTO()
                {
                    idProductoEmpresa = pro.idProductoEmpresa,
                    principal         = true
                };
                ImagenDTO i1 = new ImagenDTO()
                {
                    idProducto = idp,
                    principal  = true
                };
                string imag1 = "";
                string imag2 = "";
                string imag3 = "";
                if (string.IsNullOrEmpty(imagenService.Obtenerimagen(i1)))
                {
                    if (string.IsNullOrEmpty(imagenService.Obtenerimagen(i2)))
                    {
                        if (string.IsNullOrEmpty(imagenService.Obtenerimagen(i3)))
                        {
                        }
                        else
                        {
                            imag1 = imagenService.Obtenerimagen(i3);
                        }
                    }
                    else
                    {
                        imag1 = imagenService.Obtenerimagen(i2);
                        if (string.IsNullOrEmpty(imagenService.Obtenerimagen(i3)))
                        {
                        }
                        else
                        {
                            imag2 = imagenService.Obtenerimagen(i3);
                        }
                    }
                }
                else
                {
                    imag1 = imagenService.Obtenerimagen(i1);
                    if (string.IsNullOrEmpty(imagenService.Obtenerimagen(i2)))
                    {
                        if (string.IsNullOrEmpty(imagenService.Obtenerimagen(i3)))
                        {
                        }
                        else
                        {
                            imag2 = imagenService.Obtenerimagen(i3);
                        }
                    }
                    else
                    {
                        imag2 = imagenService.Obtenerimagen(i2);
                        if (string.IsNullOrEmpty(imagenService.Obtenerimagen(i3)))
                        {
                        }
                        else
                        {
                            imag3 = imagenService.Obtenerimagen(i3);
                        }
                    }
                }
                producto.idProductoSucursal = pro.idProductoSucursal;
                producto.idProductoEmpresa  = pro.idProductoEmpresa;
                producto.idProducto         = pp.idProducto;
                producto.precio             = Convert.ToDecimal(pro.precio);
                producto.nombre             = productoServicio.Obtenerproducto(pp).nombreProducto;
                producto.idEmpresa          = Convert.ToInt64(ide);
                producto.nombreEmpresa      = empresaSevicio.ObtenerEmpresa(e).nombreEmpresa;
                producto.idCategoria        = categoriaServicio.Obtenercategoria(
                    new CategoriaDTO()
                {
                    idCategoria = productoServicio.Obtenerproducto(pp).idCategoria
                }
                    ).idCategoria;
                producto.nombreCategoria = categoriaServicio.Obtenercategoria(
                    new CategoriaDTO()
                {
                    idCategoria = productoServicio.Obtenerproducto(pp).idCategoria
                }
                    ).nombreCategoria;
                producto.idSucursal       = s.idSucursal;
                producto.nombreSucursal   = sucursalService.ObtenerSucursal(s).nombreSucursal;
                producto.descripcionCorta = productoServicio.Obtenerproducto(pp).descripcionCortaProducto;
                producto.descripcionLarga = productoServicio.Obtenerproducto(pp).descripcionLargaProducto;
                producto.rutaimagen1      = imag1;
                producto.rutaimagen2      = imag2;
                producto.rutaimagen3      = imag3;



                return(Ok(RespuestaApi <ProductoSucursalDTO> .createRespuestaSuccess(producto, "success")));
            }
            catch (Exception ex)
            {
                return(Ok(RespuestaApi <string> .createRespuestaError(ex.ToString(), "error")));
            }
        }
Ejemplo n.º 21
0
 public async Task Update(ImagenDTO entityDTO)
 {
     var entity =
         Builders.GenericBuilder.builderDTOEntity <TImagen, ImagenDTO> (entityDTO);
     await repository.Save(entity);
 }
Ejemplo n.º 22
0
        public ActionResult Actualizar(ImagenDTO imagen, ImageViewModel img)
        {
            try
            {
                var    random      = new Random().Next(0, 100);
                string extension   = Path.GetExtension(img.foto.FileName);
                bool   extensionOk = ValidarExtension(extension);

                if (extensionOk == true)
                {
                    Image  imagenRedimensionada = Redimensionar(img.foto.InputStream);
                    string ImageName            = System.IO.Path.GetFileName(img.foto.FileName);
                    ImageName     = random + ImageName;
                    imagen.Nombre = ImageName;

                    HttpClient clienteHttp = new HttpClient();
                    clienteHttp.BaseAddress = new Uri("http://localhost:5476/");

                    var request = clienteHttp.PutAsync("api/Imagen/", imagen, new JsonMediaTypeFormatter()).Result;

                    if (request.IsSuccessStatusCode)
                    {
                        #region Elimina la imagen del servidor
                        var peticion = clienteHttp.DeleteAsync("api/Imagen/" + imagen.ImagenId).Result;

                        if (peticion.IsSuccessStatusCode)
                        {
                            var resultadoStringEliminar = request.Content.ReadAsStringAsync().Result;
                            var listado = JsonConvert.DeserializeObject <List <ImagenDTO> >(resultadoStringEliminar);

                            if (ViewBag.ObjUsuario != null)
                            {
                                var resultado = listado.FirstOrDefault(x => x.UsuarioId == ViewBag.ObjUsuario.UsuarioId);
                                System.IO.File.Delete(resultado.Nombre);
                            }
                        }
                        #endregion


                        #region Carga la nueva imagen
                        string physicalPath = Server.MapPath("~/Content/Imagenes/Upload/" + ImageName);
                        img.foto.SaveAs(physicalPath);
                        #endregion

                        var resultString = request.Content.ReadAsStringAsync().Result;
                        var correcto     = JsonConvert.DeserializeObject <bool>(resultString);

                        if (correcto)
                        {
                            return(RedirectToAction("index"));
                        }
                    }

                    return(View(imagen));
                }
            }
            catch (Exception ex)
            {
                log.ErrorFormat("Error: {0}{1}", ex.StackTrace, ex.Message);
            }

            return(View());
        }
Ejemplo n.º 23
0
        public IHttpActionResult verproducto([FromBody] ProductoDTO p)
        {
            try
            {
                Producto    pro      = new Producto();
                ProductoDTO producto = new ProductoDTO();
                pro = productoServicio.Obtenerproducto(p);

                List <EmpresaDTO>  lempresas   = new List <EmpresaDTO>();
                List <SucursalDTO> lsucursales = new List <SucursalDTO>();

                ProductoEmpresaDTO pe = new ProductoEmpresaDTO();
                pe.idProducto = pro.idProducto;
                var prems = productoempresaServicio.obtenerProductosEmpresaByProductoID(pe);
                foreach (var pre in prems)
                {
                    EmpresaDTO objempresa = new EmpresaDTO();
                    objempresa.idEmpresa = Convert.ToInt64(pre.idEmpresa);
                    lempresas.Add(new EmpresaDTO()
                    {
                        idEmpresa         = Convert.ToInt64(pre.idEmpresa),
                        nombrempresa      = empresaServicio.ObtenerEmpresa(objempresa).nombreEmpresa,
                        idproductoempresa = pre.idProductoEmpresa
                    });
                }
                foreach (var e in lempresas)
                {
                    ProductoSucursalDTO ps = new ProductoSucursalDTO();
                    ps.idProductoEmpresa = e.idproductoempresa;
                    var prsus = productosucursalServicio.obtenerProductosSucursalByProductoEmpresaID(ps);
                    foreach (var prs in prsus)
                    {
                        SucursalDTO objsucursal = new SucursalDTO();
                        objsucursal.idSucursal = Convert.ToInt64(prs.idSucursal);
                        lsucursales.Add(new SucursalDTO()
                        {
                            idSucursal             = Convert.ToInt64(prs.idSucursal),
                            nombre                 = sucursalServicio.ObtenerSucursal(objsucursal).nombreSucursal,
                            idProductoSucursal     = prs.idProductoSucursal,
                            idProductoEmpresa      = prs.idProductoEmpresa,
                            precioProductoSucursal = prs.precio
                        });
                    }
                }


                CategoriaDTO c = new CategoriaDTO()
                {
                    idCategoria = pro.idCategoria
                };
                ImagenDTO i = new ImagenDTO()
                {
                    idProducto = pro.idProducto,
                    principal  = true
                };
                producto.nombre           = pro.nombreProducto;
                producto.descripcionCorta = pro.descripcionCortaProducto;
                producto.descripcionLarga = pro.descripcionLargaProducto;
                producto.idCategoria      = pro.idCategoria;
                producto.nombrecategoria  = categoriaServicio.Obtenercategoria(c).nombreCategoria;
                producto.rutaimagen       = imagenServicio.Obtenerimagen(i);
                producto.empresas         = lempresas;
                producto.sucursales       = lsucursales;

                return(Ok(RespuestaApi <ProductoDTO> .createRespuestaSuccess(producto, "success")));
            }
            catch (Exception ex)
            {
                return(Ok(RespuestaApi <string> .createRespuestaError(ex.ToString(), "error")));
            }
        }