public DataModel GuardarShowroom(int idBanner, string colorBanner, string estaVacioSeccionBanner, bool esNuevoBanner, string textoPrincipalBanner,
                                         string colorFondoPrincipal,
                                         int idCuerpo, bool esNuevoCuerpo, string tipoDeLetraCuerpo, string estaVacioSeccionCuerpo)
        {
            Negocio  negocio  = HttpContext.Session.GetObjectFromJson <Negocio>("negocioEnSession");
            Showroom showroom = ShowroomDao.get(_context, Convert.ToInt32(negocio.ShowroomID));

            if (estaVacioSeccionBanner != "si")
            {
                showroom = guardarSeccionBanner(showroom, idBanner, colorBanner, esNuevoBanner, textoPrincipalBanner);
            }
            if (!String.IsNullOrEmpty("colorFondoPrincipal"))
            {
                showroom = guardarSeccionGeneral(showroom, colorFondoPrincipal);
            }
            if (estaVacioSeccionCuerpo != "si")
            {
                showroom = guardarSeccionCuerpo(showroom, idCuerpo, esNuevoCuerpo, tipoDeLetraCuerpo);
            }
            _context.Showrooms.Update(showroom);
            _context.SaveChanges();
            Negocio negocioEnSession = HttpContext.Session.GetObjectFromJson <HiShop.Entity.Negocio>("negocioEnSession");

            negocioEnSession.Showroom = showroom;
            DataModel respuesta = new DataModel();

            respuesta.data.Add("idBannerActual", showroom.BannerID);
            respuesta.data.Add("mensaje", "seGuardo");
            return(respuesta);
        }
        public void llenarListados(HiShopContext _context)
        {
            List <Provincia> pcias       = ProvinciaDao.getListado(_context);
            List <Localidad> localidades = LocalidadDao.getListado(_context);

            this.setLocalidades(localidades);
            this.setProvincias(pcias);
            Categoria        categoriaPadre = CategoriaDao.getCategoriaPorPadreYNombre(_context, null, "Negocio").Result;
            List <Categoria> lista          = CategoriaDao.getCategoriasPorPadre(_context, categoriaPadre).Result;

            this.listaDeShowrooms = ShowroomDao.getListado(_context);
            this.setCategorias(lista);
        }
        public IActionResult Ver(int id)
        {
            ShowroomVerModelAndView model = new ShowroomVerModelAndView();
            Negocio  negocio  = NegocioDao.get(_context, id);
            Showroom showroom = new Showroom();
            Banner   banner   = new Banner();
            Cuerpo   cuerpo   = new Cuerpo();

            model.llenarDatosGenerales(HttpContext, _context);
            if (negocio.Showroom != null || negocio.ShowroomID != null)
            {
                if (negocio.ShowroomID != null)
                {
                    showroom = ShowroomDao.get(_context, Convert.ToInt32(negocio.ShowroomID));
                }
                else
                {
                    showroom = negocio.Showroom;
                }
            }
            if (showroom.Banner != null || showroom.BannerID != null)
            {
                if (showroom.BannerID != null)
                {
                    banner = BannerDao.get(_context, Convert.ToInt32(showroom.BannerID));
                }
                else
                {
                    banner = showroom.Banner;
                }
            }
            if (showroom.Cuerpo != null || showroom.CuerpoID != null)
            {
                if (showroom.CuerpoID != null)
                {
                    cuerpo = CuerpoDao.get(_context, Convert.ToInt32(showroom.CuerpoID));
                }
                else
                {
                    cuerpo = showroom.Cuerpo;
                }
            }
            model.Showroom = showroom;
            model.Banner   = banner;
            model.Cuerpo   = cuerpo;

            //model.llenarElmentos(_context, negocio);
            return(View(model));
        }
Exemplo n.º 4
0
 /// <summary>
 /// Llenar los elementos del modelo
 /// </summary>
 /// <param name="_context"></param>
 public void llenarElmentos(HiShopContext _context, Entity.Negocio negocio)
 {
     this.showroom = ShowroomDao.get(_context, Convert.ToInt32(negocio.ShowroomID.ToString()));
     if (this.showroom.tieneBanner())
     {
         this.showroom.Banner = BannerDao.get(_context, Convert.ToInt32(this.showroom.BannerID.ToString()));
     }
     else
     {
         this.showroom.Banner = new Banner();
     }
     if (this.showroom.tieneCuerpo())
     {
         this.showroom.Cuerpo = CuerpoDao.get(_context, Convert.ToInt32(this.showroom.CuerpoID.ToString()));
     }
     else
     {
         this.showroom.Cuerpo = new Cuerpo();
     }
 }
        public IActionResult EditarShowroom(/*int? id*/)
        {
            ShowroomDADGeneralModelAndView model = new ShowroomDADGeneralModelAndView(HttpContext, _context);
            Showroom showroom = null;
            Negocio  negocio  = HttpContext.Session.GetObjectFromJson <Negocio>("negocioEnSession");

            if (negocio.tieneShowroom())
            {
                showroom = ShowroomDao.get(_context, Convert.ToInt32(negocio.ShowroomID));
            }
            else
            {
                if (negocio.ShowroomID == null)
                {
                    Entity.Showroom showroomBDD = new Entity.Showroom();
                    ShowroomDao.grabar(_context, showroomBDD);
                    Negocio n = NegocioDao.get(_context, model.negocioModelBase.ID);
                    n.Showroom = showroomBDD;
                    NegocioDao.editar(_context, n);
                    HttpContext.Session.Remove("negocioEnSession");
                    Negocio negocioModel = n;
                    n.Showroom  = null;
                    n.Productos = null;
                    HttpContext.Session.SetObjectAsJson("negocioEnSession", n);
                    model.negocioModelBase = negocioModel;
                }
                else
                {
                    showroom = ShowroomDao.get(_context, Convert.ToInt32(model.negocioModelBase.ShowroomID));
                }
            }

            if (showroom == null)
            {
                model.llenarElmentos(_context, model.negocioModelBase);
            }
            model.showroom = showroom;
            return(View(model));
        }