public ActionResult Register(RegisterViewModel rvm) { AccountModel am = new AccountModel(); Account recieved = new Account { FullName = rvm.FullName, Email = rvm.Email, Username = rvm.Username, Password = rvm.Password, Roles = rvm.Roles };//creating an account from viewmodel recieved data thats why its called recieved //for testing //ViewBag.Error = recieved.Email; if (am.find(recieved.Username)!=null) { ViewBag.Error = "Username already exists,please choose other one"; return View(); } if (ModelState.IsValid) { db.Accounts.Add(recieved); db.SaveChanges(); } SessionPersister.Username = recieved.Username; //return View("Success"); //ViewBag.Success = "User Successfully created"; return RedirectToAction("Index", "Home"); }
public CustomPrincipal(Account account) { this.Account = account; this.Identity = new GenericIdentity(account.Username); }