public async Task <IActionResult> Create([Bind("Id,Nombre,Apellido,Dni,Activo")] Profesor profesor)
        {
            if (ModelState.IsValid)
            {
                profesor.Id = Guid.NewGuid();
                _context.Add(profesor);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(profesor));
        }
        public async Task <IActionResult> Create(Materia materia)
        {
            if (ModelState.IsValid)
            {
                materia.Id = Guid.NewGuid();
                _context.Add(materia);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProfesorId"] = new SelectList(_context.Profesores, "Id", "Apellido", materia.ProfesorId);
            return(View(materia));
        }
Esempio n. 3
0
        public async Task <IActionResult> Create(Admin admin, string pass)
        {
            try
            {
                pass.ValidarPassword();
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(nameof(Admin.Password), ex.Message);
            }
            if (ModelState.IsValid)
            {
                admin.Id       = Guid.NewGuid();
                admin.Legajo   = Guid.NewGuid();
                admin.Password = pass.Encriptar();
                _context.Add(admin);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(admin));
        }
        public async Task <IActionResult> Create(Alumno alumno)
        {
            try
            {
                alumno.Legajo.ValidarPassword();
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(nameof(Alumno.Password), ex.Message);
            }
            if (ModelState.IsValid)
            {
                alumno.Id       = Guid.NewGuid();
                alumno.Legajo   = alumno.Legajo;
                alumno.Password = alumno.Legajo.Encriptar();
                alumno.Username = alumno.Dni;
                _context.Add(alumno);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(alumno));
        }
Esempio n. 5
0
 protected async Task <int> SaveChanges()
 {
     return(await Db.SaveChangesAsync());
 }