Beispiel #1
0
        public TbSeUsuario ViewModelToDomainNuevo(UsuarioViewModel officeViewModel)

        {
            //var domain = userService.GetUsuarioConPerfiles(officeViewModel.codigo);

            //if (domain != null)
            //{
            //    return null;
            //}
            var savePath = System.IO.Path.Combine(hostingEnvironment.WebRootPath, "uploads");

            var nuevoDomain = new TbSeUsuario
            {
                Nombre     = officeViewModel.nombre,
                Codigo     = officeViewModel.codigo,
                Correo     = officeViewModel.correo,
                Contrasena = officeViewModel.contrasena,
                Estado     = officeViewModel.estado,
                Iniciales  = officeViewModel.iniciales,
                FechaMod   = DateTime.Now,
                IdUsuario  = officeViewModel.Id_Usuario,
                Avatar     = FotosService.SubirFotoUsuarios1(officeViewModel.Foto, savePath)
            };


            return(nuevoDomain);
        }
Beispiel #2
0
        public TbSeUsuario ViewModelToDomainEditar(UsuarioViewModel officeViewModel)
        {
            var domain = userService.GetSingleUser(officeViewModel.id);

            domain.Codigo    = officeViewModel.codigo;
            domain.Nombre    = officeViewModel.nombre;
            domain.Estado    = officeViewModel.estado;
            domain.Iniciales = officeViewModel.iniciales;
            if (officeViewModel.contrasena != null || officeViewModel.contrasena != "")
            {
                domain.Contrasena = officeViewModel.contrasena;
            }
            domain.Correo   = officeViewModel.correo;
            domain.FechaMod = DateTime.Now;



            if (officeViewModel.Foto != null && domain.Avatar != null)
            {
                var savePath = System.IO.Path.Combine(hostingEnvironment.WebRootPath, "uploads");

                domain.Avatar = FotosService.SubirFotoUsuarios1(officeViewModel.Foto, savePath);
            }

            return(domain);
        }
Beispiel #3
0
        public TbGeEmpresa ViewModelToDomainEditar(EmpresaViewModel model)
        {
            var domain = service.GetEmpresaById(model.Id);

            domain.Bd = model.Bd;

            if (domain.CedJuridica != model.CedJuridica)
            {
                if (service.GetByCedula(model.CedJuridica) == null)
                {
                    domain.CedJuridica = model.CedJuridica;
                }
            }
            domain.Correo    = model.Correo;
            domain.Direccion = model.Direccion;
            domain.Estado    = model.Estado;
            domain.FechaMod  = DateTime.Now;
            domain.Nombre    = model.Nombre;
            domain.Telefono1 = model.Telefono1;
            domain.Telefono2 = model.Telefono2;
            domain.TienePuntoVentaDefecto = model.TienePuntoVentaDefecto;
            domain.IdPuntoVenta           = model.IdPuntoVenta;
            //domain.IdGrupoEmpresarial = model.Id_GE;
            if (model.Foto != null)
            {
                var savePath = System.IO.Path.Combine(hostingEnvironment.WebRootPath, "uploads");
                domain.Foto = FotosService.SubirFotoEmpresa(model.Foto, savePath);
            }

            return(domain);
        }
Beispiel #4
0
        public TbGeEmpresa ViewModelToDomainCrear(EmpresaViewModel model)
        {
            var savePath = System.IO.Path.Combine(hostingEnvironment.WebRootPath, "uploads");
            var domain   = new TbGeEmpresa
            {
                Bd                     = model.Bd,
                CedJuridica            = model.CedJuridica,
                Correo                 = model.Correo,
                Direccion              = model.Direccion,
                Estado                 = true,
                FechaCreacion          = DateTime.Now,
                FechaMod               = DateTime.Now,
                Nombre                 = model.Nombre,
                Telefono1              = model.Telefono1,
                Telefono2              = model.Telefono2,
                IdGrupoEmpresarial     = model.Id_GE,
                TienePuntoVentaDefecto = model.TienePuntoVentaDefecto,
                IdPuntoVenta           = model.IdPuntoVenta
            };

            if (model.Foto != null)
            {
                domain.Foto = FotosService.SubirFotoEmpresa(model.Foto, savePath);
            }
            else
            {
                domain.Foto = "";
            }


            return(domain);
        }
Beispiel #5
0
        public TbSeUsuario ViewModelToDomainNuevo(UsuarioViewModel officeViewModel)

        {
            //var domain = userService.GetUsuarioConPerfiles(officeViewModel.codigo);

            //if (domain != null)
            //{
            //    return null;
            //}

            var nuevoDomain = new TbSeUsuario
            {
                Nombre     = officeViewModel.nombre,
                Codigo     = officeViewModel.codigo,
                Correo     = officeViewModel.correo,
                Contrasena = officeViewModel.contrasena,
                Estado     = officeViewModel.estado,
                Iniciales  = officeViewModel.iniciales,
                FechaMod   = DateTime.Now,
                IdUsuario  = officeViewModel.Id_Usuario,
                Avatar     = FotosService.SubirFotoUsuario(officeViewModel.Foto)
            };


            return(nuevoDomain);
        }
Beispiel #6
0
        public TbGeEmpresa ViewModelToDomainEditar(EmpresaViewModel model)
        {
            var domain = service.GetEmpresaById(model.Id);

            domain.Bd = model.Bd;

            if (domain.CedJuridica != model.CedJuridica)
            {
                if (service.GetByCedula(model.CedJuridica) == null)
                {
                    domain.CedJuridica = model.CedJuridica;
                }
            }
            domain.Correo    = model.Correo;
            domain.Direccion = model.Direccion;
            domain.Estado    = model.Estado;
            domain.FechaMod  = DateTime.Now;
            domain.Nombre    = model.Nombre;
            domain.Telefono1 = model.Telefono1;
            domain.Telefono2 = model.Telefono2;
            //domain.IdGrupoEmpresarial = model.Id_GE;
            if (model.Foto != null)
            {
                domain.Foto = FotosService.SubirFotoEmpresa(model.Foto);
            }


            return(domain);
        }
Beispiel #7
0
 public ContactoController(FotosService pFotos, IUserRepository IUserRepository, IContactoCamposService ICCService, IContactoService contactoService, IContactoMap contactoMap, IcontactoCamposMap pContactoCamposMap, IcontactoCamposMap pContactoMap)
 {
     this.contactoService    = contactoService;
     this.contactoMap        = contactoMap;
     this.pContactoCamposMap = pContactoCamposMap;
     this.pContactoCamposMap = pContactoMap;
     this.ICCService         = ICCService;
     this.userMap            = IUserRepository;
     this.Fotos = pFotos;
 }
Beispiel #8
0
        public JsonResult editFoto(IFormCollection id, IFormFile foto)
        {
            IList <ContactoRelacionGETViewModel> cr = null;

            ViewData["contactoRelacion"] = cr;
            var    idd  = id["id"].ToString();
            string ruta = "";

            ruta = FotosService.SubirFotoContacto(foto);

            int i = Convert.ToInt32(idd);

            this.contactoMap.ingresarImagen(i, ruta);
            return(new JsonResult(1));
        }
Beispiel #9
0
        public IList <TbPrImagenInventario> ViewModelToDomainNuevoImagen(int id, IFormFile[] files)
        {
            var imgInventario = new List <TbPrImagenInventario>();

            var savePath = System.IO.Path.Combine(hostingEnvironment.WebRootPath, "Files");
            var fotos    = FotosService.SubirAdjuntos(files, savePath);

            foreach (var item in fotos)
            {
                imgInventario.Add(new TbPrImagenInventario
                {
                    IdInventario = id,
                    Imagen       = item
                });
            }

            return(imgInventario);
            //service.SaveImagenInventario(imgInventario);
        }
Beispiel #10
0
        public IActionResult GuardarImagen(int idPuntoVenta, IFormFile foto)
        {
            try
            {
                var puntoVenta = service.GetPuntoVentaById(idPuntoVenta);
                var savePath   = System.IO.Path.Combine(Startup.entorno.WebRootPath, "uploads");
                puntoVenta.Imagen = FotosService.SubirImagenPuntoVenta(foto, savePath);

                service.Update(puntoVenta);

                return(Json(new { success = true }));
            }
            catch (Exception ex)
            {
                AltivaLog.Log.Insertar(ex.ToString(), "Error");
                return(BadRequest());

                throw;
            }
        }
Beispiel #11
0
        public TbSeUsuario ViewModelToDomainEditar(UsuarioViewModel officeViewModel)
        {
            var domain = userService.GetSingleUser(officeViewModel.id);

            domain.Codigo     = officeViewModel.codigo;
            domain.Nombre     = officeViewModel.nombre;
            domain.Estado     = officeViewModel.estado;
            domain.Iniciales  = officeViewModel.iniciales;
            domain.Contrasena = officeViewModel.contrasena;
            domain.Correo     = officeViewModel.correo;



            if (officeViewModel.Foto != null && domain.Avatar != null)
            {
                domain.Avatar = FotosService.SubirFotoUsuario(officeViewModel.Foto);
            }

            return(domain);
        }
Beispiel #12
0
        public TbGeEmpresa ViewModelToDomainCrear(EmpresaViewModel model)
        {
            var domain = new TbGeEmpresa
            {
                Bd                 = model.Bd,
                CedJuridica        = model.CedJuridica,
                Correo             = model.Correo,
                Direccion          = model.Direccion,
                Estado             = model.Estado,
                FechaCreacion      = DateTime.Now,
                FechaMod           = DateTime.Now,
                Nombre             = model.Nombre,
                Telefono1          = model.Telefono1,
                Telefono2          = model.Telefono2,
                IdGrupoEmpresarial = model.Id_GE,
                Foto               = FotosService.SubirFotoEmpresa(model.Foto)
            };

            return(domain);
        }
        public IActionResult GuardarImagen(int idContacto, IFormFile foto)
        {
            try
            {
                var contacto = contactoService.GetByIdContacto(idContacto);
                var savePath = System.IO.Path.Combine(Startup.entorno.WebRootPath, "uploads");
                contacto.Ruta = FotosService.SubirFotoContacto(foto, savePath);

                contactoService.Update(contacto);

                return(Json(new { success = true }));
            }
            catch (Exception ex)
            {
                AltivaLog.Log.Insertar(ex.ToString(), "Error");
                return(BadRequest());

                throw;
            }
        }
        public ActionResult CambiarFotoEmpresa(int id, FileViewModel model)
        {
            try
            {
                if (model.file != null)
                {
                    var empresa = service.GetEmpresaById(id);

                    empresa.Foto = FotosService.SubirFotoEmpresa(model.file, System.IO.Path.Combine(Startup.entorno.WebRootPath, "uploads"));
                    var res = service.Update(empresa);
                    Sesion.Sesion.SetFotoEmpresa(HttpContext.Session, res.Foto);
                }

                return(Json(new { success = true }));
            }
            catch (Exception ex)
            {
                AltivaLog.Log.Insertar(ex.ToString(), "Error");
                return(BadRequest());
            }
        }
Beispiel #15
0
        public ActionResult CrearComentarioPost(MensajeViewModel model)
        {
            var id = User.Claims.FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier)?.Value;

            TbSeAdjunto AdjuntoDomain = new TbSeAdjunto();

            List <TbSeAdjunto> listaAdjuntos = new List <TbSeAdjunto>();

            try
            {
                var comentario = this.IMensajeMap.Crear(model, int.Parse(id));
                comentario = this.ImensajeService.create(comentario);

                if (model.Files != null)
                {
                    var savePath = System.IO.Path.Combine(hostingEnvironment.WebRootPath, "Files");
                    var rutas    = FotosService.SubirAdjuntos(model.Files, savePath);
                    foreach (var item in rutas)
                    {
                        AdjuntoDomain = this.IAdjuntoMap.crear(comentario.Id, item);
                        listaAdjuntos.Add(AdjuntoDomain);
                    }
                }
                else
                {
                    AdjuntoDomain = this.IAdjuntoMap.crear(comentario.Id, "");

                    listaAdjuntos.Add(AdjuntoDomain);
                }

                this.IAdjuntoService.Crear(listaAdjuntos);

                return(Json(new { success = true }));
            }
            catch (Exception ex)
            {
                AltivaLog.Log.Insertar(ex.ToString(), "Error");
                throw;
            }
        }
Beispiel #16
0
        public ActionResult CrearComentarioPost(MensajeViewModel model)
        {
            var id = User.Claims.FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier)?.Value;

            TbSeAdjunto AdjuntoDomain = new TbSeAdjunto();

            List <TbSeAdjunto> listaAdjuntos = new List <TbSeAdjunto>();

            try
            {
                var comentario = this.IMensajeMap.Crear(model, int.Parse(id));
                comentario = this.ImensajeService.create(comentario);

                if (model.Files != null)
                {
                    var rutas = FotosService.SubirAdjuntos(model.Files);
                    foreach (var item in rutas)
                    {
                        AdjuntoDomain = this.IAdjuntoMap.crear(comentario.Id, item);
                    }

                    listaAdjuntos.Add(AdjuntoDomain);
                }
                else
                {
                    AdjuntoDomain = this.IAdjuntoMap.crear(comentario.Id, "");

                    listaAdjuntos.Add(AdjuntoDomain);
                }

                this.IAdjuntoService.Crear(listaAdjuntos);

                return(Json(new { success = true }));
            }
            catch (Exception)
            {
                return(BadRequest());
                //throw;
            }
        }