コード例 #1
0
        public ActionResult Edit(int id)
        {
            var repoPubli = new PublicacionRepositorio();
            var repoIdioma = new IdiomaRepositorio();
            var repoSer = new ServicioRepositorio();
            var publi = repoPubli.GetById(id);
            var servicios = repoSer.GetAll();
            var itemsCategoria = new List<string>();
            var itemsCategoria2 = new List<string>();
            foreach (var servicio in servicios)
            {
                if(servicio.Idioma.CompareTo("es-MX")==0){
                    itemsCategoria.Add(servicio.Nombre);
                    itemsCategoria2.Add(servicio.IdServicio.ToString());
                }
            }

            ViewData["Servicios-Es"] = itemsCategoria;
            ViewData["Servicios-Es-id"] = itemsCategoria2;

            itemsCategoria = new List<string>();
            itemsCategoria2 = new List<string>();
            foreach (var servicio in servicios)
            {
                if (servicio.Idioma.CompareTo("en-US") == 0){
                    itemsCategoria.Add(servicio.Nombre);
                    itemsCategoria2.Add(servicio.IdServicio.ToString());
                }
            }

            ViewData["Servicios-En"] = itemsCategoria;
            ViewData["Servicios-En-id"] = itemsCategoria2;

            var repoServiPubli = new PublicacionServicioRepositorio();
            var listaSerPub = repoServiPubli.GetAll();
            var listaPubSer = new List<PublicacionServicio>();
            foreach (var publicacionServicio in listaSerPub)
            {
                if(publicacionServicio.IdPublicacion==publi.IdPublicacion)
                    listaPubSer.Add(publicacionServicio);
            }
            var listaSer= listaPubSer.Select(publicacionServicio => repoSer.GetById(publicacionServicio.IdServicio)).ToList();

            publi.Servicios = listaSer;
            var listIdioma = repoIdioma.GetAll();
            publi.Idioma=new List<Idioma>();
            foreach (var idioma in listIdioma.Where(idioma => idioma.IdPublicacion == publi.IdPublicacion))
            {
                publi.Idioma.Add(idioma);
            }

            var repoPrecios = new PrecioRepositorio();
            var listaPre = repoPrecios.GetAll();
            var listaPre2 = new List<Precio>();
            foreach (var precio in listaPre)
            {
                if(precio.IdPublicacion== publi.IdPublicacion)
                    listaPre2.Add(precio);
            }
            publi.Precios = listaPre2;
             /*   var repoImg = new ImageneRepositorio();
            var listaImg = repoImg.GetAll();
            var listaImg2 = new List<Imagene>();
            foreach (var imagene in listaImg)
            {
                if(imagene.IdPublicacion==id)
                    listaImg2.Add(imagene);
            }
            publi.Imagenes = listaImg2;*/
            return View(publi);
        }
コード例 #2
0
        //
        // GET: /Publicacion/Details/5
        public ActionResult Details(int id)
        {
            var myRepoPublicacion = new PublicacionRepositorio();
            var myRepoImagene = new ImageneRepositorio();
            var myRepoServicioP = new PublicacionServicioRepositorio();
            var myRepoCat = new CategoriumRepositorio();
            var myRepoSubCat = new SubCategoriumRepositorio();
            var myRepoEmpresa = new EmpresaRepositorio();
            var myRepoServicio = new ServicioRepositorio();
            var myRepoIdioma = new IdiomaRepositorio();
            var myRepoPrecio = new PrecioRepositorio();
            var p = myRepoPublicacion.GetById(id);
            if (p != null)
            {
                var listaImagenes = myRepoImagene.GetAll();
                var listaImagenesAux = listaImagenes.Where(imagene => imagene.IdPublicacion == id).ToList();
                p.Imagenes = listaImagenesAux;
                var listaIdioma = myRepoIdioma.GetAll();
                if (listaIdioma!=null)
                {
                    p.Idioma = new List<Idioma>();
                    foreach (var idioma in listaIdioma.Where(idioma => idioma.IdPublicacion == id))
                    {
                        p.Idioma.Add(idioma);
                    }
                }

                var listaServicio = myRepoServicioP.GetAll();
                if (listaServicio != null)
                {
                    p.Servicios = new List<Servicio>();
                    foreach (var servicio in listaServicio.Where(servicio => servicio.IdPublicacion == id))
                    {
                        p.Servicios.Add(myRepoServicio.GetById(servicio.IdServicio));
                    }
                }
                p.Empresa = myRepoEmpresa.GetById(p.IdEmpresa);
                p.SubCategorium = myRepoSubCat.GetById(p.IdSubCategoria);
                p.Categorium = myRepoCat.GetById(p.SubCategorium.IdCategoria);
                var listaPrecios = myRepoPrecio.GetAll();
                p.Precios = listaPrecios.Where(listaPrecio => listaPrecio.IdPublicacion == id).ToList();
                p.Reservacion = p.Reservacion == "S" ? "Si" : "No";
                if (p.Idioma[0].Categoria.CompareTo("1 Estrella") == 0 || p.Idioma[0].Categoria.CompareTo("2 Estrellas") == 0 || p.Idioma[0].Categoria.CompareTo("3 Estrellas") == 0 || p.Idioma[0].Categoria.CompareTo("4 Estrellas") == 0 || p.Idioma[0].Categoria.CompareTo("5 Estrellas") == 0)
                {
                    p.Idioma[0].Categoria = p.Idioma[0].Categoria.Substring(0, 1);

                }else
                {
                    p.Idioma.Add(new Idioma { Categoria = p.Idioma[0].Categoria });
                    p.Idioma[0].Categoria = "0";
                }

                return View(p);
            }
            return RedirectToAction("Index");
        }