Beispiel #1
0
        public async Task <IActionResult> Create([Bind("Id,Name")] Matter matter)
        {
            if (ModelState.IsValid)
            {
                _context.Add(matter);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(matter));
        }
Beispiel #2
0
        public async Task <IActionResult> Create([Bind("Id,Description")] Career career)
        {
            if (ModelState.IsValid)
            {
                _context.Add(career);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(career));
        }
Beispiel #3
0
        public async Task <IActionResult> Create([Bind("StudentId,MatterId,EnrollmentDate")] StudentMatter studentMatter)
        {
            if (ModelState.IsValid)
            {
                _context.Add(studentMatter);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MatterId"]  = new SelectList(_context.Matters, "Id", "Id", studentMatter.MatterId);
            ViewData["StudentId"] = new SelectList(_context.Students, "Id", "Id", studentMatter.StudentId);
            return(View(studentMatter));
        }
Beispiel #4
0
        public async Task <IActionResult> Create([Bind("Id,Name,Age,Year,CareerId,NamePhoto")] Student student)
        {
            if (ModelState.IsValid)
            {
                var files = HttpContext.Request.Form.Files;

                if (files != null && files.Count > 0)
                {
                    var filesPhoto   = files[0];
                    var pathDesitine = Path.Combine(env.WebRootPath, "images\\students");
                    if (filesPhoto.Length > 0)
                    {
                        var fileDestine = Guid.NewGuid().ToString().Replace("-", "") + Path.GetExtension(filesPhoto.FileName);

                        using (var filestream = new FileStream(Path.Combine(pathDesitine, fileDestine), FileMode.Create))
                        {
                            filesPhoto.CopyTo(filestream);
                            student.NamePhoto = fileDestine;
                        }
                    }
                }

                _context.Add(student);
                await _context.SaveChangesAsync();

                //Profe intente hacer el auto-role al estudiante que recien se registra, pero me tiro error

                //var userAdmin = userManager.Users.Where(x => x.Email == Roles.MailAdminRole).FirstOrDefault();
                ////if (userAdmin != null) return;

                //userAdmin = new IdentityUser
                //{
                //    UserName = Roles.MailAdminRole,
                //    Email = Roles.MailAdminRole,
                //    EmailConfirmed = true,
                //    PhoneNumberConfirmed = true
                //};

                //await userManager.CreateAsync(userAdmin, "w5KYECgrWfKy3z");
                //await userManager.AddToRoleAsync(userAdmin, Roles.EstudianteRole);


                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CareerId"] = new SelectList(_context.Careers, "Id", "Description", student.CareerId);
            return(View(student));
        }