public IActionResult Create(CrearViewModel modelo) { if (ModelState.IsValid) { int persona = (from p in _context.Persona where p.IdPersona == modelo.IdPersona select p).Count(); if (persona <= 0) { if (modelo.Genero == "M" || modelo.Genero == "F" || modelo.Genero == "I") { var password = "******"; _context.Persona.Add(new Model.Persona { NombreCompleto = modelo.Nombre + " " + modelo.Apellido1 + " " + modelo.Apellido2, IdTipoPersona = modelo.IdTipoPersona, Correo = modelo.Correo, Genero = modelo.Genero, Carnet = modelo.Carnet, Pais = modelo.Pais, Ciudad = modelo.Ciudad, Password = password, IdPersona = modelo.IdPersona }); _context.SaveChanges(); return(RedirectToAction("Index", new Microsoft.AspNetCore.Routing.RouteValueDictionary( new { controller = "Home", action = "Index" }))); } } return(View(modelo)); } return(View(modelo)); }
public IActionResult Create(CrearViewModel modelo) { if (ModelState.IsValid) { _context.PersonaXtipo.Add(new Model.PersonaXtipo { IdPersona = modelo.PersonaSelecionada, IdTipoPersona = modelo.TipoPersonaSelecionada }); _context.SaveChanges(); return(RedirectToAction("Index", new Microsoft.AspNetCore.Routing.RouteValueDictionary( new { controller = "Home", action = "Index" }))); } var personas = (from c in _context.Persona select c).ToList(); var tipo_persona = (from c in _context.TipoPersona select c).ToList(); modelo.Persona = personas; modelo.TipoPersona = tipo_persona; return(View(modelo)); }
public IActionResult Create(CrearViewModel modelo) { if (ModelState.IsValid) { //var carrera = (from c in _context.Carreras select c.IdCarrera); //se ocupa generar una tabla secuencias donde se almacenan los ids de las entidades string Id = "TP001"; _context.TipoPersona.Add(new Model.TipoPersona { IdTipoPersona = Id, Descripción = modelo.TipoNombre, Persona = null, PersonaXtipo = null }); _context.SaveChanges(); return(RedirectToAction("Index", new Microsoft.AspNetCore.Routing.RouteValueDictionary( new { controller = "Home", action = "Index" }))); } return(View()); }
public IActionResult Create(CrearViewModel modelo) { if (ModelState.IsValid) { //var carrera = (from c in _context.Carreras select c.IdCarrera); ////se ocupa generar una tabla secuencias donde se almacenan los ids de las entidades //string id = "Carrera02"; var db = (from c in _context.Secuencias where c.Descripcion == "Carreras" select c.Value).ToList(); int Id = 0; foreach (var item in db) { Id = int.Parse(item.ToString()); } var index = (from c in _context.Secuencias where c.Descripcion == "Carreras" select new { c.Value, c.Descripcion }).FirstOrDefault(); //index.Value = index.Value + 1; //FINALIZA string id = "Carrera" + Id; _context.Carreras.Add(new Model.Carreras { NombreCarrera = modelo.NombreCarrera, Cursos = null, IdCarrera = id, IdPersona = modelo.PersonaAsignada }); _context.SaveChanges(); return(RedirectToAction("Index", new Microsoft.AspNetCore.Routing.RouteValueDictionary( new { controller = "Home", action = "Index" }))); } return(View()); }
public IActionResult Create(CrearViewModel modelo) { if (ModelState.IsValid) { var cursos = (from c in _context.Cursos select c.IdCurso); _context.Cursos.Add(new Model.Cursos { IdCurso = modelo.CursoSeleccionado, Grupos = modelo.Grupos, IdPersona = modelo.Persona.ToString(), }); _context.SaveChanges(); return(RedirectToAction("Index", new Microsoft.AspNetCore.Routing.RouteValueDictionary( new { controller = "Home", action = "Index" }))); } return(View()); }
public IActionResult Create(CrearViewModel modelo) { if (ModelState.IsValid) { var cursos = (from c in _context.Cursos select c.IdCarrera); _context.Rubros.Add(new Model.Rubros { //Id = modelo.CursoSeleccionado, NombreRubro = modelo.NombreRubro, Porcentaje = modelo.Porcentaje, IdRubro = "Rubro01", }); _context.SaveChanges(); return(RedirectToAction("Index", new Microsoft.AspNetCore.Routing.RouteValueDictionary( new { controller = "Home", action = "Index" }))); } return(View()); }
public IActionResult Create(CrearViewModel modelo) { if (ModelState.IsValid) { var cursos = (from c in _context.Cursos select c.IdCurso); _context.Cursos.Add(new Model.Cursos { Descripcion = modelo.NombreCurso, IdMateriarequerida = modelo.CursoSeleccionada, IdCarrera = modelo.CarreraSeleccionada, Creditos = modelo.Creditos, IdCurso = "Curso02", Precio = 120, Estado = 2, }); _context.SaveChanges(); return(RedirectToAction("Index", new Microsoft.AspNetCore.Routing.RouteValueDictionary( new { controller = "Home", action = "Index" }))); } return(View()); }
public IActionResult Create(CrearViewModel modelo) { if (ModelState.IsValid) { var ventana = (from c in _context.Ventanas select c.IdVentana); //se ocupa generar una tabla secuencias donde se almacenan los ids de las entidades string id = "ventana02"; _context.Ventanas.Add(new Model.Ventanas { Descripcion = modelo.Descripcion, VentanasXperfil = null, IdVentana = id, }); _context.SaveChanges(); return(RedirectToAction("Index", new Microsoft.AspNetCore.Routing.RouteValueDictionary( new { controller = "Home", action = "Index" }))); } return(View()); }