public async Task <IActionResult> Authorize(Users user) { if (User.Identity.IsAuthenticated) { return(RedirectToAction("Profile", "Account")); } try { if (accountManagement.Verify(user.Login, user.Password)) { Users u = accountManagement.GetUser(user.Login); await Authenticate(u); logger.LogInformation("{@User} has authorized", u); return(RedirectToAction("Profile", "Account")); } else { logger.LogWarning("{User} has failed to Authorize with {Password}", user.Login, user.Password); return(View("Error")); } } catch (System.Exception) { logger.LogWarning("Failed attempt to Authorize with {Login} and {Password}", user.Login, user.Password); return(View("Error")); } }
public IActionResult Profile() { var user = accountManagement.GetUser(User.Identity.Name); var subjects = subjectManagement.GetStudentsFinalChoice(user.UserId); ViewData["FirstName"] = user.FirstName; ViewData["LastName"] = user.LastName; ViewData["MiddleName"] = user.MiddleName; ViewData["Role"] = accountManagement.GetRoleName(user.Role); return(View(subjects)); }
public ViewResult SubjectsFirstTerm(string Search) { var user = accountManagement.GetUser(User.Identity.Name); Subjects[] subjectsList; ViewData["Information"] = ""; if (user.Role == 3) { var student = accountManagement.GetStudent(user.UserId); if (student.Course == 1) { subjectsList = subjectManagement.GetSubjects(3); } else if (student.Course == 2) { subjectsList = subjectManagement.GetSubjects(5); } else { subjectsList = subjectManagement.GetSubjects(1); ViewData["Information"] = "Вибіркові дисципліни для вас не опубліковані."; } } else { subjectsList = new List <Subjects>() .Concat(subjectManagement.GetSubjects(3)) .Concat(subjectManagement.GetSubjects(5)) .ToArray(); } if (!String.IsNullOrEmpty(Search)) { subjectsList = subjectManagement.GetSubjectsByTitle(Search, subjectsList); } return(View(subjectsList)); }