Exemplo n.º 1
0
 public ActionResult Create(CreateTeacherAccountVM details)
 {
     if (ModelState.IsValid)
     {
         var user = new ApplicationUser
         {
             UserName  = details.Email,
             FirstName = details.FirstName,
             LastName  = details.LastName,
             Email     = details.Email,
             LastLogon = new DateTime(1970, 1, 1)
         };
         var result = UserManager.Create(user, details.Password);
         if (!result.Succeeded)
         {
             throw new System.Exception(string.Join("\n", result.Errors));
         }
         UserManager.AddToRole(user.Id, "Teacher");
         details.Id          = user.Id;
         TempData["Message"] = "Teacher Account created.";
         return(RedirectToAction("Index"));
     }
     return(View(details));
 }
Exemplo n.º 2
0
        public ActionResult Create()
        {
            var vm = new CreateTeacherAccountVM();

            return(View(vm));
        }