public ActionResult Crear(MateriaViewModel mvm) { try { if (!ModelState.IsValid) { return(View("FormMateria")); } if (mvm.Id == 0) { Materia m = new Materia(); m.nombre = mvm.nombre; m.descripcion = mvm.descripcion; m.activo = mvm.activo; _ctx.Materias.Add(m); } else { //Es una edicion var valor = _ctx.Materias.SingleOrDefault(m => m.Id == mvm.Id); if (valor != null) { valor.nombre = mvm.nombre; valor.descripcion = mvm.descripcion; valor.activo = mvm.activo; } } } catch { return(View()); } //Aqui se llega sIempre _ctx.SaveChanges(); return(RedirectToAction("Index")); }
public EquipmentEntryModel(MateriaEquipment equipment, MateriaViewModel vm) { _equipment = equipment; _materiaVm = vm; EquipmentType = ItemModel.GetItemModels(); CharacterTypes = new KhEnumListModel <CharacterType>(() => Character, x => Character = x); }
public MateriaViewModel ObtenerMateria(int id) { MateriaViewModel estudiante = listaMaterias.FirstOrDefault(x => x.Id == id); return(estudiante); }
public ActionResult agregarMateria(MateriaViewModel model) { List <ListMateriaViewModel> lst; try { if (ModelState.IsValid) { using (SchoolAppEntities db = new SchoolAppEntities()) { var oTabla = new Materias(); oTabla.ID_curso = model.IdCurso; oTabla.Profesor = model.Profesor; oTabla.Materia = model.Materia; oTabla.Horario = model.Horario; oTabla.Duracion = model.Duracion; db.Materias.Add(oTabla); db.SaveChanges(); } return(Redirect("~/Materia/")); } return(View(model)); } catch (Exception ex) { throw new Exception(ex.Message); } }
public ActionResult EditarMateria(MateriaViewModel model) { try { if (ModelState.IsValid) { using (SchoolAppEntities db = new SchoolAppEntities()) { var oTabla = db.Materias.Find(model.IdMaterias); oTabla.ID_curso = model.IdCurso; oTabla.Profesor = model.Profesor; oTabla.Materia = model.Materia; oTabla.Horario = model.Horario; oTabla.Duracion = model.Duracion; db.Entry(oTabla).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } return(Redirect("~/Materia/")); } return(View(model)); } catch (Exception ex) { throw new Exception(ex.Message); } }
public ActionResult Editar(int id) { var materia = _ctx.Materias.Find(id); MateriaViewModel mvm = new MateriaViewModel(materia); return(View("FormMateria", mvm)); }
public void CrearMateria(MateriaViewModel nuevaMateria) { using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Users\Public\TestFolder\WriteLines2.txt")) { file.WriteLine(nuevaMateria.ToString()); } }
public ActionResult Crear(MateriaViewModel model) { BD_escuelaFinalEntities bd = new BD_escuelaFinalEntities(); bd.Materias.Add(model.materia); bd.SaveChanges(); return(RedirectToAction("Principal_Maestro", "Home")); }
public ActionResult Crear() { BD_escuelaFinalEntities bd = new BD_escuelaFinalEntities(); MateriaViewModel viewModel = new MateriaViewModel(); viewModel.maestros = bd.Maestros.ToList(); return(View(viewModel)); }
public EquipmentEntryModel(int index, WeaponFound[] weaponFound, MateriaEquipment equipment, MateriaViewModel vm) { _arrayIndex = index; _weaponFound = weaponFound; _equipment = equipment; _materiaVm = vm; EquipmentType = ItemModel.GetItemModels(); CharacterTypes = new KhEnumListModel <CharacterType>(() => Character, x => Character = x); }
public ActionResult Cadastrar(string msg) { MateriaViewModel materiaVM = new MateriaViewModel() { Cursos = carregarCursos(), Msg = msg }; return(View(materiaVM)); }
public CharacterEntryModel(SaveFf7Remake save, int index, EquipmentsViewModel weapons, MateriaViewModel materia) { _save = save; _characterType = (CharacterType)index; _character = save.Characters[index]; _characterStats = save.CharactersStats[index]; _characterEquipment = save.CharactersEquipment[index]; Weapons = weapons; Materia = materia; }
public void ModificarMateria(MateriaViewModel nuevo) { for (int i = 0; i < listaMaterias.Count; i++) { if (listaMaterias[i].Id == nuevo.Id) { listaMaterias[i].Nombre = nuevo.Nombre; } } //listaMaterias.RemoveAt(listaMaterias.FindIndex(x => x.Id == nuevo.Id)); //listaMaterias.Add(nuevo); }
public ActionResult EditarMateria(int id) { MateriaViewModel model = new MateriaViewModel(); using (SchoolAppEntities db = new SchoolAppEntities()) { var oTabla = db.Materias.Find(id); model.IdCurso = oTabla.ID_curso; model.Profesor = oTabla.Profesor; model.Materia = oTabla.Materia; model.Horario = oTabla.Horario; model.Duracion = oTabla.Duracion; model.IdMaterias = oTabla.ID_materias; } return(View(model)); }
public ActionResult Create([Bind(Include = "COD_MATERIA,NOME")] MateriaViewModel materiaViewModel) { if (ModelState.IsValid) { if (materiaViewModel.NOME == null) { ModelState.AddModelError("NOME", "O campo Materia deve ser preenchido!"); } else { MATERIA mATERIA = new MATERIA(); db.MATERIA.Add(mATERIA); db.SaveChanges(); return(RedirectToAction("Index")); } } return(View(materiaViewModel)); }
public ActionResult Cadastrar(MateriaViewModel materiaVM) { if (ModelState.IsValid) { Materia m = new Materia() { Nome = materiaVM.Nome, CursoId = materiaVM.CursoId }; _unit.MateriaRepository.Cadastrar(m); _unit.Save(); return(RedirectToAction("Cadastrar", new { msg = "Matéria cadastrada com sucesso" })); } else { materiaVM.Cursos = carregarCursos(); return(View(materiaVM)); } }
public void CrearMateria(MateriaViewModel nuevoMateria) { listaMaterias.Add(nuevoMateria); }
public void ModificarMateria(MateriaViewModel nuevo) { throw new NotImplementedException(); }
public ActionResult Create() { MateriaViewModel mvm = new MateriaViewModel(); return(View("FormMateria", mvm)); }