public async Task<ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                //var user = new ApplicationUser { UserName = model.Email, Email = model.Email };
                var user = new ApplicationUser { UserName = model.Email, Email = model.Email, FirstName = model.FirstName, LastName = model.LastName };
                var result = await UserManager.CreateAsync(user, model.Password);

                // Hema

                UserRoleHelpers roleHelper = new UserRoleHelpers();
                var role = roleHelper.AddUserToRole(user.Id, "Submitter");
                // End Hema

                if (result.Succeeded)
                {
                    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");
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
 public ActionResult EditUserRole(string userId, AdminViewModel adminModel)
 {
     UserRoleHelpers helper = new UserRoleHelpers();
     if(ModelState.IsValid)
     {
         string[] empt = { };
         adminModel.SelectedRoles = adminModel.SelectedRoles ?? empt;
         foreach (var role in db.Roles.ToList())
         {
             //If selected but user doesn't have, add
             if (adminModel.SelectedRoles.Contains(role.Name))
             {
                 helper.AddUserToRole(userId, role.Name);
             }
             //If not selected remove
             else
             {
                 helper.RemoveuserFromRole(userId, role.Name);
             }
         }
     }
     return RedirectToAction("AdminIndex");
 }
        // GET: Tickets/Edit/5
        public ActionResult Edit(int? id)
        {
            UserRoleHelpers roleHelpers = new UserRoleHelpers();
            UserProjectHelpers helper = new UserProjectHelpers();
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            Tickets tickets = db.Tickets.Find(id);
            if (tickets == null)
            {
                return HttpNotFound();
            }
            var projId = db.Projects.Find(tickets.ProjectId);
            var projUsers = projId.Users.ToList();
            var resultList = new List<ApplicationUser>();

            foreach (var user in projUsers)
            {
                if (roleHelpers.IsUserInRole(user.Id,"Developer"))
                {
                    resultList.Add(user);
                }
            }

            ViewBag.AssignedToUserId = new SelectList(resultList, "Id", "FirstName", tickets.AssignedToUserId);
            ViewBag.TicketStatusId = new SelectList(db.TicketStatus, "Id", "StatusName", tickets.TicketStatusId);
            ViewBag.TicketTypeId = new SelectList(db.TicketType, "Id", "TicketName", tickets.TicketTypeId);
            ViewBag.TicketPriorityId = new SelectList(db.TicketPriority, "Id", "PriorityName", tickets.TicketPriorityId);
            return View(tickets);
        }
        public ActionResult EditUserRole(string userId)
        {
            var user = db.Users.Find(userId);
            AdminViewModel adminModel = new AdminViewModel();
            // Creating an object of helper class
            UserRoleHelpers helper = new UserRoleHelpers();
            // Calling Helper Method
            var selected = helper.ListUserRoles(userId);
            adminModel.Roles = new MultiSelectList(db.Roles, "Name", "Name", selected);
            adminModel.User = user;

            return View(adminModel);
        }