Exemple #1
0
        public async Task <ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            // This doesn't count login failures towards account lockout
            // To enable password failures to trigger account lockout, change to shouldLockout: true
            var result = await SignInManager.PasswordSignInAsync(model.UserName, model.Password, model.RememberMe, shouldLockout : false);

            switch (result)
            {
            case SignInStatus.Success:
            {
                AccountModel user = AccountServiceCaller.Get(model.UserName);
                if (user != null)
                {
                    return(RedirectToLocal(returnUrl));
                }
                else
                {
                    goto case SignInStatus.Failure;
                }
            }

            case SignInStatus.RequiresVerification:
                return(RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe }));

            case SignInStatus.Failure:
            default:
                ModelState.AddModelError("", "Invalid login attempt.");
                return(View(model));
            }
        }
        public ActionResult AddExam(ExamViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var currentUser   = AccountServiceCaller.Get(User.Identity.Name);
            var userOrganizer = OrganizerServiceCaller.Get(currentUser.OrganizerId);
            var newExam       = new ExamModel();

            newExam.OrganizerId = userOrganizer.Id;
            newExam.CourseName  = model.CourseName;
            newExam.Hour        = model.Hour;
            newExam.Date        = model.ExamDay;
            newExam.Room        = model.ExamRoom;
            newExam.Difficulty  = model.Difficulty;

            try
            {
                ExamServiceCaller.Add(newExam);
                return(RedirectToAction("Index", "Exam"));
            }
            catch (Exception ex)
            {
                return(View(ex.Message));
            }
        }
        public ActionResult AddCourse(CourseViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var currentUser   = AccountServiceCaller.Get(User.Identity.Name);
            var userOrganizer = OrganizerServiceCaller.Get(currentUser.OrganizerId);
            var newCourse     = new CourseModel();

            newCourse.OrganizerId = userOrganizer.Id;
            newCourse.Name        = model.CourseName;
            newCourse.Hour        = model.CourseHour;
            newCourse.Professor   = model.CourseProfessor;

            newCourse.Day = GetWeekDayFromString(model.CourseDay);

            try
            {
                CourseServiceCaller.Add(newCourse);
                return(RedirectToAction("Index", "Course"));
            }
            catch (Exception ex)
            {
                return(View(ex.Message));
            }
        }
Exemple #4
0
        public ActionResult ChangeUserAccountSettings(ChangeUserAccountSettingsViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            AccountModel account = AccountServiceCaller.Get(User.Identity.GetUserName());

            if (!String.IsNullOrEmpty(model.Email))
            {
                account.Email = model.Email;
            }
            if (!String.IsNullOrEmpty(model.FullName))
            {
                account.FullName = model.FullName;
            }
            if (!String.IsNullOrEmpty(model.PhoneNumber))
            {
                account.PhoneNumber = model.PhoneNumber;
            }

            try
            {
                AccountServiceCaller.Update(account);
                return(RedirectToAction("Index", "Manage"));
            }
            catch (Exception ex)
            {
                return(View(ex.Message));
            }
        }
Exemple #5
0
        public ActionResult Index()
        {
            var nextDay = CalculationClass.GetWeekDayFromDateTime(DateTime.Now.AddDays(1).DayOfWeek);

            ViewBag.NextDay = nextDay.ToString();
            if (Request.IsAuthenticated)
            {
                var account    = AccountServiceCaller.Get(User.Identity.Name);
                var organizer  = OrganizerServiceCaller.Get(account.OrganizerId);
                var courseList = CalculationClass.GetCoursesFromDay(organizer.Courses.ToList(), nextDay);
                ViewBag.CourseList = courseList;
                var nextExam            = CalculationClass.GetNextExam(organizer.Exams.ToList());
                var daysTillTheNextExam = 0;
                if (nextExam != null)
                {
                    daysTillTheNextExam = CalculationClass.CalculateNumberOfDaysTillActivity(nextExam.Date);
                }
                ViewBag.NextExam            = nextExam;
                ViewBag.DaysTillTheNextExam = daysTillTheNextExam;
            }
            else
            {
                ViewBag.CourseList = new List <CourseModel>();
                ViewBag.NextExam   = null;
            }
            return(View());
        }
        // GET: Exam
        public ActionResult Index()
        {
            var currentUser   = AccountServiceCaller.Get(User.Identity.Name);
            var userOrganizer = OrganizerServiceCaller.Get(currentUser.OrganizerId);
            var examList      = CalculationClass.SortExamsByDifficulty(userOrganizer.Exams.ToList());

            return(View(examList));
        }
        // GET: Course
        public ActionResult Index()
        {
            var currentUser   = AccountServiceCaller.Get(User.Identity.Name);
            var userOrganizer = OrganizerServiceCaller.Get(currentUser.OrganizerId);
            var courseList    = userOrganizer.Courses;

            courseList = CalculationClass.SortCoursesByDayAndHour(courseList.ToList());
            return(View(courseList));
        }
Exemple #8
0
        public ActionResult ChangeActivitySettings(ChangeSettingsViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            AccountModel  account  = AccountServiceCaller.Get(User.Identity.GetUserName());
            SettingsModel settings = SettingsServiceCaller.Get(account.SettingsId);

            settings.CourseDuration = model.ActivityLenght;
            switch (model.FirstDayOfWeek)
            {
            case "Luni":
            {
                settings.StartDay = WeekDay.Luni;
                break;
            }

            case "Marti":
            {
                settings.StartDay = WeekDay.Marti;
                break;
            }

            case "Miercuri":
            {
                settings.StartDay = WeekDay.Miercuri;
                break;
            }

            case "Joi":
            {
                settings.StartDay = WeekDay.Joi;
                break;
            }

            case "Vineri":
            {
                settings.StartDay = WeekDay.Vineri;
                break;
            }
            }
            try
            {
                SettingsServiceCaller.Update(settings);
                return(RedirectToAction("Index", "Manage"));
            }
            catch (Exception ex)
            {
                return(View(ex.Message));
            }
        }