Example #1
0
        public ActionResult Index()
        {
            int  userid = User.Identity.GetUserId <int>();
            User users  = new UserRoleDal().GetIndividualUserInfo(userid);

            return(View("Index", users));
        }
Example #2
0
        public static void GetUserRoles(string userId)
        {
            UserRoleDal         userRolsDal = new UserRoleDal(connString);
            List <UserRoleView> userRoles   = userRolsDal.GetAll(userId);

            if (userRoles == null || userRoles.Count == 0)
            {
                userUnassignedRoles = new List <string>(appRolesCodes);
                userAssignedRoles   = new List <string>();
            }
            else if (appRolesCodes != null && appRolesCodes.Count == userRoles.Count)
            {
                userUnassignedRoles = new List <string>();
                userAssignedRoles   = new List <string>(appRolesCodes);
            }
            else
            {
                userAssignedRoles   = userRoles.Select(r => r.RoleCode).ToList();
                userUnassignedRoles = new List <string>(appRolesCodes);
                foreach (string role in userAssignedRoles)
                {
                    if (userUnassignedRoles.Contains(role))
                    {
                        userUnassignedRoles.Remove(role);
                    }
                }
            }
        }
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser
                {
                    UserName  = model.UserName,
                    Email     = model.Email,
                    FirstName = model.FirstName,
                    LastName  = model.LastName
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    UserRoleDal dal = new UserRoleDal();

                    UserRolesInput roles = new UserRolesInput();

                    roles.UserId  = user.Id;
                    roles.RoleId  = int.Parse(Request.Form["usertype"]);
                    roles.MsgText = "";
                    roles.MsgType = "";
                    dal.GetInsertAspNetUserRoles(roles);

                    //var userid = user.Id;
                    //var userrole = Request.Form["usertype"];

                    //if (userrole == "1")
                    //{

                    //    UserManager.AddToRole(userid, "Student");
                    //}

                    //else
                    //{
                    //    UserManager.AddToRole(userid, "Teacher");
                    //}

                    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));
        }
Example #4
0
 public UserRoleBll()
 {
     this._UserRoleDal = new UserRoleDal();
 }
Example #5
0
 public UserRolesWindow()
 {
     InitializeComponent();
     RoleUtil.connString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
     userRoles           = new UserRoleDal(RoleUtil.connString);
 }
        public ActionResult ShowResult()
        {
            List <User> users = new UserRoleDal().GetUserRegisterCompleteResultSheet();

            return(View("ShowResult", users));
        }
Example #7
0
 public UserRoleManager(UserRoleDal userRoleDal)
 {
     _userRoleDal = userRoleDal;
 }
Example #8
0
        public void Test_UserRoleDal()
        {
            messageSeqNo = 0;
            UserRoleDal userRoleDal = new UserRoleDal(sqlConnectionString);
            List<UserRoleView> userRoleList = new List<UserRoleView>();
            userRoleList = userRoleDal.GetAllStub();
            expectedCount = 8;
            actualCount = userRoleList.Count;
            Assert.AreEqual(expectedCount, actualCount, "Selected list count.");

            expectedValue = "CNTRCT-APP";
            actualValue = userRoleList[1].RoleCode;
            Assert.AreEqual(expectedValue, actualValue, "Selected Role.");

            userRoleList = null;
            userRoleList = userRoleDal.GetAll("JVEGA");
            expectedCount = 5;
            actualCount = userRoleList.Count;
            Assert.AreEqual(expectedCount, actualCount, "Selected list count.");

            expectedValue = "FNAPP";
            actualValue = userRoleList[2].RoleCode;
            Assert.AreEqual(expectedValue, actualValue, "Selected Role.");
        }