/*public void GuardarAsignacionDeLineas(ListadoDisponibilidadModel model) * { * IList<Disponibilidad> disponibilidades = new List * { * foreach (item in model) * { * * } * } * }*/ public void CrearLinea(CrearLineaModel model) { Linea linea = new Linea(model.Nombre, model.Numero, model.IdEmpresaProfesorSeleccionada); _contexto.Add(linea); _contexto.SaveChanges(); }
public IActionResult CrearLinea(CrearLineaModel model) { if (model.IdEmpresaProfesorSeleccionada == Guid.Empty) { model.IdEmpresaProfesorSeleccionada = null; } _repositorio.CrearLinea(model); return(RedirectToAction("Index")); }
public async Task <ActionResult> RegistrarLinea(CrearLineaModel dto, string submit) { try { ICollection <Parada> paradas = await gp.ListarParadas(); if (submit.Equals("Agregar")) { ICollection <Parada> ret = new List <Parada>(); if (!TryValidateModel(dto, nameof(CrearHorariosModel))) { foreach (var item in paradas) { bool agregar = true; foreach (var itemT in dto.tramos) { if (item.id == itemT.idParada) { agregar = false; continue; } } if (agregar) { ret.Add(item); } } ViewBag.listaParadas = ret; return(View("Linea/RegistrarLinea", dto)); } dto.tramoAux.orden = dto.tramos.Count() + 1; dto.tramos.Add(dto.tramoAux); foreach (var item in paradas) { bool agregar = true; foreach (var itemT in dto.tramos) { if (item.id == itemT.idParada) { agregar = false; continue; } } if (agregar) { ret.Add(item); } } ViewBag.listaParadas = ret; return(View("Linea/RegistrarLinea", dto)); } if (submit.Equals("Crear")) { if (dto.tramos.Count < 2) { ICollection <Parada> ret = new List <Parada>(); foreach (var item in paradas) { bool agregar = true; foreach (var itemT in dto.tramos) { if (item.id == itemT.idParada) { agregar = false; continue; } } if (agregar) { ret.Add(item); } } ViewBag.listaParadas = ret; return(View("Linea/RegistrarLinea", dto)); } Linea l = new Linea(); l.nombre = dto.nombre; foreach (var item in dto.tramos) { Parada p = new Parada() { id = item.idParada }; Tramo t = new Tramo() { numero = item.orden, parada = p, tiempo = item.tiempo }; Precio precio = new Precio() { valor = item.precio, fecha_validez = DateTime.Today }; t.precio.Add(precio); l.tramos.Add(t); } await ap.RegistrarLinea(l); } return(RedirectToAction("ListarLineas")); } catch { return(View("Linea/RegistrarLinea")); } }