Ejemplo n.º 1
0
 //ToAdd: start
 public ActionResult shMapping()
 {
     //if (Convert.ToString(TempData["pid"]) == "")
     //{
     //    return RedirectToAction("Index", "Projects");
     //}
     //TempData["pid"] = TempData["pid"];
     TempData["project"] = TempData["project"];
     TempData["fundsMapping"] = TempData["fundsMapping"];
     ViewBag.hdnUsr = TempData["hdnUsr"];
     ViewBag.hdnRid = TempData["hdnRid"];
     TempData["hdnFunds"] = TempData["hdnFunds"];
     var Db = new ApplicationDbContext();
     var model = new RegisterViewModel();
     var list = Db.Roles.OrderBy(r => r.Name).Where(adm => adm.Name != "Admin").ToList()
         .Select(rr => new SelectListItem { Value = rr.Id.ToString(), Text = rr.Name })
         .ToList();
     model.Roles = (IEnumerable<SelectListItem>)list;
     return View(model);
 }
Ejemplo n.º 2
0
        public async Task<ActionResult> Register(RegisterViewModel model)
        {
            var Db = new ApplicationDbContext();            
            var list = Db.Roles.OrderBy(r => r.Name).ToList().Select(rr => new SelectListItem { Value = rr.Name.ToString(), Text = rr.Name }).ToList();
            model.Roles = (IEnumerable<SelectListItem>)list;

            if (ModelState.IsValid)
            {
                var user = new ApplicationUser { UserName = model.Email, Email = model.Email, FirstName = model.FirstName, LastName = model.LastName, Gender = model.Gender,
                PhoneNumber = model.PhoneNumber, City = model.City, State = model.State, Country = model.Country, Zip = model.Zip, AddressLine = model.AddressLine, Salary = model.Salary};
                var result = await UserManager.CreateAsync(user, model.Password);
                if (result.Succeeded)
                {
                    await UserManager.AddToRoleAsync(user.Id, model.Role);
                    //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");
                    return RedirectToAction("ListUsers");
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
Ejemplo n.º 3
0
 public ActionResult Register()
 {
     var Db = new ApplicationDbContext();
     var model = new RegisterViewModel();
     var list = Db.Roles.OrderBy(r => r.Name).ToList().Select(rr =>new SelectListItem { Value = rr.Name.ToString(), Text = rr.Name }).ToList();
     model.Roles = (IEnumerable<SelectListItem>)list;
     return View(model);
 }