public async Task <ActionResult> Register(RegisterViewModel model, String Name) { BCS_Context db = new BCS_Context(); if (ModelState.IsValid) { Encrypt encrypt = new Encrypt(model.Password); var user = new ApplicationUser { UserName = model.UserName, Email = model.Email, LastName = model.LastName, MiddleName = model.MiddleName, GivenName = model.GivenName, ZoneGroup = model.ZoneGroupCode, Status = model.Status, Division = model.Division, LocalPass = encrypt.EncryptedValue, Zone = model.Zone }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { //Assign Role to user Here await this.UserManager.AddToRoleAsync(user.Id, Name); RoleAssignmentMatrix roleAssignmentMatrix = new RoleAssignmentMatrix(); roleAssignmentMatrix.UserName = model.UserName; roleAssignmentMatrix.ZoneGroup = model.ZoneGroupCode; db.RoleAssignmentMatrix.Add(roleAssignmentMatrix); await db.SaveChangesAsync(); //Ends Here //await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false); // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); //return RedirectToAction("Index", "Home"); TempData["TransactionSuccess"] = "Add"; SL.LogInfo(User.Identity.Name, Request.RawUrl, "Account Registered - from Terminal: " + ipaddress); return(RedirectToAction("ViewUser", "Account")); } AddErrors(result); } // If we got this far, something failed, redisplay form ViewBag.ZoneGroupCode = new SelectList(db.ZoneGroup.ToList(), "ZoneGroupCode", "ZoneGroupName"); ViewBag.Name = new SelectList(context.Roles.ToList(), "Name", "Name"); ViewBag.Division = new SelectList(db.Division.ToList(), "Code", "Name"); TempData["TransactionSuccess"] = "Failed"; return(View(model)); }