public ActionResult Configuration(FormCollection frmCollection)
        {
            var createdBy  = Convert.ToInt64(CookieHelper.GetCookie(CookieName.UserMasterId));
            var userRoleId = RoleManagement.ConfigureRoleTransaction(frmCollection, createdBy);

            //Create Current Menu
            Session.Remove("Menu");

            //START | Bind A New Menu HERE | Add | Suchit Khunt | 30052016
            var roleId = Convert.ToInt64(CookieHelper.GetCookie(CookieName.RoleMasterId));

            //If We Found owner Then We Return ZERO.. Coz If Role ID is ZERO then it returns every Links
            if (roleId == (int)EnumList.Roles.Owner)
            {
                roleId = 0;
            }

            var menu = RoleManagement.GetMenu(roleId);

            Session["Menu"] = menu;

            //END | Bind A New Menu HERE | Add | Suchit Khunt | 30052016

            //return RedirectToAction("ConfigureRole");
            TempData["Success"] = "Configuration updated successfully";

            return(RedirectToAction("Configuration", "Role", new { id = userRoleId }));
        }
Esempio n. 2
0
        public ActionResult Login(AccountVm data)
        {
            try
            {
                using (_entities)
                {
                    // Ensure we have a valid viewModel to work with
                    if (!ModelState.IsValid)
                    {
                        return(View(data));
                    }

                    //Initialise object of usermaster table
                    var userMaster = _entities.UserMasters.FirstOrDefault(s => s.Email == data.EmailLogin.Trim());

                    //Check that details is not null
                    if (userMaster != null)
                    {
                        var oldHashValue = userMaster.Hash;
                        var salt         = userMaster.Salt;

                        var isLogin = Utilities.CompareHashValue(data.PasswordLogin.Trim(), userMaster.Email,
                                                                 oldHashValue, salt);

                        if (isLogin)
                        {
                            //Login Success
                            //For Set Authentication in Cookie (Remeber ME Option)
                            SignInRemember(data.Email, data.IsRemember);

                            //Set A Unique ID in session
                            CookieHelper.SetCookie(CookieName.UserMasterId, userMaster.UserMasterId.ToString(), 36);
                            CookieHelper.SetCookie(CookieName.Name, userMaster.Name, 36);
                            CookieHelper.SetCookie(CookieName.RoleMasterId, userMaster.RoleMasterId.ToString(), 36);

                            string profileImage;
                            if (!string.IsNullOrWhiteSpace(userMaster.Profile))
                            {
                                profileImage = BasicProperty.ProfilePath + userMaster.Profile;
                            }
                            else
                            {
                                profileImage = "/Content/img/userIcon.jpg";
                            }

                            CookieHelper.SetCookie(CookieName.ProfileImage, profileImage, 36);

                            //Set Menu in session
                            var menu = RoleManagement.GetMenu(userMaster.RoleMasterId);
                            Session["Menu"] = menu;

                            TempData["Success"] = "Welcome to DevTracker";

                            // If we got this far, something failed, redisplay form
                            // return RedirectToAction("Index", "Dashboard");
                            return(RedirectToLocal(data.ReturnUrl));
                        }

                        TempData["Error"] = "Access Denied! You enter wrong credentials!";
                    }
                    else
                    {
                        TempData["Error"] = "Access Denied! You enter wrong credentials!";
                    }
                }

                return(RedirectToAction("Login"));
            }
            catch (Exception e)
            {
                TempData["Error"] = e.Message;
                throw;
            }
        }