public ActionResult Delete(int id) { try { IRepositorio<Lugar> myRepoLugar = new LugarRepositorio(); myRepoLugar.Delete(myRepoLugar.GetById(id)); return RedirectToAction("Index"); } catch { return RedirectToAction("Index"); } }
public ActionResult Create(Lugar lugar,FormCollection collection) { try { if (collection.GetValue("Foranea").AttemptedValue.CompareTo("null")!=0) { ValueProviderResult valor = collection.GetValue("Foranea"); int idForanea = Convert.ToInt32(valor.AttemptedValue); ValueProviderResult valorNombre = collection.GetValue("Nombre"); String Nombre = valorNombre.AttemptedValue; ValueProviderResult valorTipo = collection.GetValue("Lugar"); String Tipo = valorTipo.AttemptedValue; lugar = new Lugar(); lugar.Nombre = Nombre; lugar.Tipo = Tipo; lugar.FkLugar = idForanea; IRepositorio<Lugar> myRepoLugar = new LugarRepositorio(); myRepoLugar.Save(lugar); } else { ValueProviderResult valorNombre = collection.GetValue("Nombre"); String Nombre = valorNombre.AttemptedValue; ValueProviderResult valorTipo = collection.GetValue("Lugar"); String Tipo = valorTipo.AttemptedValue; lugar = new Lugar(); lugar.Nombre = Nombre; lugar.Tipo = Tipo; lugar.FkLugar = null; IRepositorio<Lugar> myRepoLugar = new LugarRepositorio(); myRepoLugar.Save(lugar); } return RedirectToAction("Index"); } catch { return View(); } }
public ActionResult GetForaneas() { IRepositorio<Lugar> repoMotor = new LugarRepositorio(); IList<Lugar> query2 = repoMotor.GetAll(); IRepositorio<Lugar> repoMarca = new LugarRepositorio(); IList<Lugar> query = repoMarca.GetAll(); List<JsonSelectObject> citiesList = new List<JsonSelectObject>(); citiesList.Add(new JsonSelectObject { When = "Pais", Value = null, Text = null }); foreach (var lugar in query) { if (lugar.Tipo == "Pais") citiesList.Add(new JsonSelectObject { When = "Estado", Value = lugar.IdLugar.ToString(), Text = lugar.Nombre }); } foreach (var lugar in query) { if (lugar.Tipo == "Estado") citiesList.Add(new JsonSelectObject { When = "Localidad", Value = lugar.IdLugar.ToString(), Text = lugar.Nombre }); } return Json(citiesList, JsonRequestBehavior.AllowGet); }
public ActionResult Index(string Nombre) { IRepositorio<Lugar> myRepoLugar = new LugarRepositorio(); IList<Lugar> listaLugar = myRepoLugar.GetAll(); IList<Lugar> lugarBuscados = new List<Lugar>(); if (Nombre != null) { foreach (var lugar in listaLugar) { if (lugar.Nombre == Nombre) { lugarBuscados.Add(lugar); } } return View(lugarBuscados); } return View(listaLugar); }
public ActionResult Edit(Lugar Lugar, int id, FormCollection collection) { try { IRepositorio<Lugar> myRepoLugar = new LugarRepositorio(); Lugar.IdLugar = id; myRepoLugar.Update(Lugar); return RedirectToAction("Index"); } catch (Exception O) { return View(); } }
public ActionResult Find(string q) { IRepositorio<Lugar> repoC = new LugarRepositorio(); IList<Lugar> Lugares = repoC.GetAll(); IList<Lugar> posiblesLugares = new List<Lugar>(); foreach (var item in Lugares) { if (item.Nombre.Contains(q.ToUpper()) || item.Nombre.Contains(q.ToLower())) { posiblesLugares.Add(item); } } string[] emp = new string[posiblesLugares.Count]; int i = 0; foreach (var Lugar in posiblesLugares) { emp[i] = Lugar.Nombre; i++; } return Content(string.Join("\n", emp)); ; }
public ActionResult Edit(int id) { IRepositorio<Lugar> myRepoLugar = new LugarRepositorio(); return View(myRepoLugar.GetById(id)); }
protected override void Initialize(RequestContext requestContext) { var items3 = new List<string>(); IRepositorio<Lugar> repoMarca = new LugarRepositorio(); IList<Lugar> query = repoMarca.GetAll(); items3.Add("--Seleccione--"); foreach (var lugar in query) { if (lugar.Tipo == "Pais") { items3.Add(lugar.Nombre); } } ViewData["Pais"] = new SelectList(items3); IEnumerable<string> items2 = new string[] { "--Seleccione--" }; ViewData["Estado"] = new SelectList(items2); IEnumerable<string> items4 = new string[] { "--Seleccione--" }; ViewData["Ciudad"] = new SelectList(items4); var repoSubCat = new SubCategoriumRepositorio(); var repoCat = new CategoriumRepositorio(); //Lista de Subcategoria para las publicaciones var miLista = repoSubCat.GetAll(); if (miLista != null) { var items = (from subCategorium in miLista let miCategorium = repoCat.GetById(subCategorium.IdCategoria) select miCategorium.Nombre + " - " + subCategorium.Nombre).ToList(); ViewData["SubCategorium.Nombre"] = new SelectList(items); } //Lista de Categoria de la publicacion var itemsCategoria = new List<string> { "1 Estrella", "2 Estrellas", "3 Estrellas", "4 Estrellas", "5 Estrellas", "Otra" }; ViewData["Idioma[0].Categoria"] = new SelectList(itemsCategoria); var itemsPrecio = new List<string> { "Bs.", "$", "€", "£", "¥" }; ViewData["Precios[0].Moneda"] = new SelectList(itemsPrecio); ViewData["Precios[1].Moneda"] = new SelectList(itemsPrecio); //Lista de Servicios Para la Publiacion var repoServ = new ServicioRepositorio(); var servicios = repoServ.GetAll(); var itemsCategoria3 = new List<string>(); var itemsCategoria2 = new List<string>(); foreach (var servicio in servicios) { if (servicio.Idioma.CompareTo("es-MX") == 0) { itemsCategoria3.Add(servicio.Nombre); itemsCategoria2.Add(servicio.IdServicio.ToString()); } } ViewData["Servicios-Es"] = itemsCategoria3; ViewData["Servicios-Es-id"] = itemsCategoria2; itemsCategoria3 = new List<string>(); itemsCategoria2 = new List<string>(); foreach (var servicio in servicios) { if (servicio.Idioma.CompareTo("en-US") == 0) { itemsCategoria3.Add(servicio.Nombre); itemsCategoria2.Add(servicio.IdServicio.ToString()); } } ViewData["Servicios-En"] = itemsCategoria3; ViewData["Servicios-En-id"] = itemsCategoria2; base.Initialize(requestContext); }
public ActionResult Create(Publicacion p,FormCollection collection) { //Empresa var nombreEmpresa = collection[0]; var repoEmp = new EmpresaRepositorio(); var listaEmp = repoEmp.GetAll(); foreach (var empresa in listaEmp.Where(empresa => empresa.Nombre == nombreEmpresa)) { p.IdEmpresa = empresa.IdEmpresa; } if (String.IsNullOrEmpty(nombreEmpresa) || p.IdEmpresa == 0) { ModelState.AddModelError("NombreE", "Nombre Empresa es Necesario"); return View(p); } if (String.IsNullOrEmpty(p.Pais) || p.Pais.CompareTo("--Seleccione--")==0) { ModelState.AddModelError("Pais", "Pais es Necesario"); return View(p); } if (String.IsNullOrEmpty(p.Estado) || p.Estado.CompareTo("--Seleccione--") == 0) { ModelState.AddModelError("Estado", "Estado es Necesario"); return View(p); } if (String.IsNullOrEmpty(p.Ciudad) || p.Ciudad.CompareTo("--Seleccione--") == 0) { ModelState.AddModelError("Ciudad", "Ciudad es Necesario"); return View(p); } //fin Empresa //Sub Categoria var repoSub = new SubCategoriumRepositorio(); var listaSub = repoSub.GetAll(); var subCategorias = p.SubCategorium.Nombre.Split('-'); var subCategoria = ""; subCategoria = subCategorias[1].Substring(1); p.SubCategorium = new SubCategorium(); foreach (var subCategorium in listaSub.Where(subCategorium => subCategorium.Nombre == subCategoria)) { p.IdSubCategoria = subCategorium.IdSubCategoria; } //fin Sub Categoria var repoPubli = new PublicacionRepositorio(); IList<Idioma> myIdiomas = p.Idioma; p.Idioma = null; var repoLug = new LugarRepositorio(); p.Ciudad = repoLug.GetById(Convert.ToInt32(p.Ciudad)).Nombre; p.Estado = repoLug.GetById(Convert.ToInt32(p.Estado)).Nombre; var idPublicacion = repoPubli.Save(p); //Precios IList<Precio> listaPrecios = p.Precios; var repoPrecios = new PrecioRepositorio(); foreach (var precio in listaPrecios) { precio.IdPublicacion = idPublicacion; repoPrecios.Save(precio); } //fin Precios p.Idioma = myIdiomas; //Servicios if (p.Servicios != null){ var misServicios = new List<Servicio>(p.Servicios); foreach (var misServicio in misServicios) { if (misServicio.IdServicio == 0) continue; var pB = new PublicacionServicio { IdPublicacion = idPublicacion, IdServicio = misServicio.IdServicio }; var repoPubSer = new PublicacionServicioRepositorio(); repoPubSer.Save(pB); } } //fin Servicios //Idioma var repoIdioma = new IdiomaRepositorio(); var idioma = p.Idioma[0]; idioma.IdPublicacion = idPublicacion; if(p.Idioma[0].Categoria != "Otra") { p.Idioma[0].Categoria.Substring(0, 1); repoIdioma.Save(idioma); } else { idioma.Categoria = p.Idioma[1].Categoria; repoIdioma.Save(idioma); } //fin Idioma //Session para las fotos Session["IdPublicacion"] = idPublicacion; return RedirectToAction("Upload"); }
public ActionResult GetForaneas() { IRepositorio<Lugar> repoMotor = new LugarRepositorio(); IList<Lugar> query2 = repoMotor.GetAll(); IRepositorio<Lugar> repoMarca = new LugarRepositorio(); IList<Lugar> query = repoMarca.GetAll(); IRepositorio<Lugar> repoMarca2 = new LugarRepositorio(); IList<Lugar> query3 = repoMarca.GetAll(); List<JsonSelectObject> citiesList = new List<JsonSelectObject>(); foreach (var pais in query) { foreach (var estado in query2) { if (pais.IdLugar == estado.FkLugar) { citiesList.Add(new JsonSelectObject { When = pais.Nombre, Value = estado.IdLugar.ToString(), Text = estado.Nombre }); foreach (var localidad in query3) { if (estado.IdLugar == localidad.FkLugar) citiesList.Add(new JsonSelectObject { When = estado.IdLugar.ToString(), Value = localidad.IdLugar.ToString(), Text = localidad.Nombre }); } } } } return Json(citiesList, JsonRequestBehavior.AllowGet); }
public ActionResult Index() { IRepositorio<Lugar> myRepoLugar = new LugarRepositorio(); IList<Lugar> listaLugar = myRepoLugar.GetAll(); return View(listaLugar); }