Ejemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("Name,MiddleName,LastName,FacultyNumber,Password,ConfirmPassword,Specialty,Year,FormOfEducation")] Student student)
        {
            if (ModelState.IsValid)
            {
                _context.Add(student);
                await _context.SaveChangesAsync();

                await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme,
                                              LoginController.AuthenticateUser(student.FacultyNumber));

                return(RedirectToAction(nameof(AssignmentsController.Index), "Assignments"));
            }

            return(View(nameof(RegistrationController.Index), new RegistrationViewModel
            {
                Student = student,
            }));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Add(AssignmentViewModel assignmentViewModel)
        {
            if (ModelState.IsValid)
            {
                var ms = new MemoryStream();
                assignmentViewModel.FormFile.CopyTo(ms);

                var assignment = new Assignment()
                {
                    Date = DateTime.UtcNow,
                    Name = assignmentViewModel.Name,
                    File = ms.ToArray(),
                };

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

                return(RedirectToAction(nameof(Index), "Assignments"));
            }

            return(View(nameof(AssignmentsAddForm)));
        }