コード例 #1
0
        public ActionResult Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
					var repository = new RepositoryBase<LmPlatformModelsContext, AccessCode>(new LmPlatformModelsContext());

					var code = repository.GetAll().OrderBy(e => e.Id).ToList().LastOrDefault();

	                if (code.Number.ToLower() != model.Code.ToLower())
	                {
		                throw new Exception("Неверный код доступа");
	                }

                    model.RegistrationUser(new[] { "student" });

                    return RedirectToAction("Index", "Home");
                }
				catch (MembershipCreateUserException e)
				{
					ModelState.AddModelError(string.Empty, ErrorCodeToString(e.StatusCode));
				}
				catch (Exception e)
				{
					ModelState.AddModelError(string.Empty, e.Message);
				}
            }

            return View(model);
        }
コード例 #2
0
ファイル: AccountController.cs プロジェクト: slaq777/lmsystem
        public ActionResult Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    model.RegistrationUser(new[] { "student" });

                    return RedirectToAction("Index", "Home");
                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError(string.Empty, ErrorCodeToString(e.StatusCode));
                }
            }

            return View(model);
        }
コード例 #3
0
 public ActionResult Register()
 {
     var model = new RegisterViewModel();
     return View(model);
 }
コード例 #4
0
        public ActionResult AddProfessorAjax(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var user = UsersManagementService.GetUserByName(model.Name, model.Surname, model.Patronymic);
                    if (user == null)
                    {
                        model.RegistrationUser(new[] { "lector" });
                        return Json(new { resultMessage = "Преподаватель сохранен" });
                    }

                    ModelState.AddModelError(string.Empty, "Пользователь с таким именем уже существует");
                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError(string.Empty, e.StatusCode.ToString());
                }
            }

            return PartialView("_AddProfessorView", model);
        }
コード例 #5
0
        public ActionResult AddProfessor(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    model.RegistrationUser(new[] { "lector" });
                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError(string.Empty, e.StatusCode.ToString());
                    return View(model);
                }
            }

            return null;
        }
コード例 #6
0
 public ActionResult AddProfessor()
 {
     var model = new RegisterViewModel();
     return PartialView("_AddProfessorView", model);
 }