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); }
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); }
public ActionResult Register() { var model = new RegisterViewModel(); return View(model); }
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); }
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; }
public ActionResult AddProfessor() { var model = new RegisterViewModel(); return PartialView("_AddProfessorView", model); }