Exemplo n.º 1
0
        public ActionResult Create(CreateUserViewModel createUserViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var isUser = _iUserMaster.CheckUsernameExists(createUserViewModel.UserName);
                    if (isUser)
                    {
                        ModelState.AddModelError("", "Username already exists");
                    }

                    AesAlgorithm aesAlgorithm = new AesAlgorithm();

                    var usermaster = AutoMapper.Mapper.Map <Usermaster>(createUserViewModel);
                    usermaster.Status     = true;
                    usermaster.CreateDate = DateTime.Now;
                    usermaster.UserId     = 0;
                    usermaster.CreatedBy  = Convert.ToInt32(Session["UserID"]);

                    var userId = _iUserMaster.AddUser(usermaster);
                    if (userId != -1)
                    {
                        var passwordMaster = new PasswordMaster
                        {
                            CreateDate = DateTime.Now,
                            UserId     = userId,
                            PasswordId = 0,
                            Password   = aesAlgorithm.EncryptString(createUserViewModel.Password)
                        };

                        var passwordId = _iPassword.SavePassword(passwordMaster);
                        if (passwordId != -1)
                        {
                            var savedAssignedRoles = new SavedAssignedRoles()
                            {
                                RoleId         = createUserViewModel.RoleId,
                                UserId         = userId,
                                AssignedRoleId = 0,
                                Status         = true,
                                CreateDate     = DateTime.Now
                            };
                            _savedAssignedRoles.AddAssignedRoles(savedAssignedRoles);

                            TempData["MessageCreateUsers"] = "User Created Successfully";
                        }
                    }

                    return(RedirectToAction("Create", "CreateUsers"));
                }
                else
                {
                    return(View("Create", createUserViewModel));
                }
            }
            catch
            {
                throw;
            }
        }
Exemplo n.º 2
0
        public ActionResult Register(UsermasterView usermaster)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var autoUsermaster = AutoMapper.Mapper.Map <Usermaster>(usermaster);
                    var isUser         = _iUserMaster.CheckUsernameExists(usermaster.UserName);
                    if (isUser)
                    {
                        ModelState.AddModelError("", "Username already exists");
                    }

                    AesAlgorithm aesAlgorithm = new AesAlgorithm();

                    var userId = _iUserMaster.AddUser(autoUsermaster);
                    if (userId != -1)
                    {
                        PasswordMaster passwordMaster = new PasswordMaster
                        {
                            CreateDate = DateTime.Now,
                            UserId     = userId,
                            PasswordId = 0,
                            Password   = aesAlgorithm.EncryptString(usermaster.Password)
                        };

                        var passwordId = _iPassword.SavePassword(passwordMaster);

                        if (passwordId != -1)
                        {
                            TempData["MessageRegistration"] = "Registration Successful";
                        }
                    }

                    return(RedirectToAction("Register", "Registration"));
                }
                else
                {
                    return(View("Register", usermaster));
                }
            }
            catch
            {
                throw;
            }
        }
Exemplo n.º 3
0
        public JsonResult VerifiyUser(UsermasterView usermaster)
        {
            try
            {
                var givenEmail     = usermaster.EmailId;
                var autoUsermaster = AutoMapper.Mapper.Map <Usermaster>(usermaster);
                var isUser         = _iUserMaster.CheckUsernameExists(usermaster.UserName);
                if (isUser)
                {
                    var user = _iUserMaster.GetUserByUsername(usermaster.UserName);
                    if (user.EmailId == givenEmail)
                    {
                        MailMessage mail = new MailMessage("*****@*****.**", givenEmail);
                        mail.Subject    = "Subject";
                        mail.IsBodyHtml = true;
                        mail.Body       = "this is email body";

                        SmtpClient client = new SmtpClient("64.233.166.109");
                        client.DeliveryMethod        = SmtpDeliveryMethod.Network;
                        client.UseDefaultCredentials = false;
                        client.Credentials           = new NetworkCredential("*****@*****.**", "lilla34402");
                        client.Port      = 587;
                        client.EnableSsl = true;


                        //Add this line to bypass the certificate validation
                        // But do not add these lines in a production code
                        System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate(object s,
                                                                                                      System.Security.Cryptography.X509Certificates.X509Certificate certificate,
                                                                                                      System.Security.Cryptography.X509Certificates.X509Chain chain,
                                                                                                      System.Net.Security.SslPolicyErrors sslPolicyErrors)
                        {
                            return(true);
                        };


                        client.Send(mail);
                    }
                    else
                    {
                        ModelState.AddModelError("", "Invalid Email");
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Invalid UserName");
                }


                return(null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 4
0
        public ActionResult Create(CreateUserViewModel createUserViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (_iUserMaster.CheckEmailIdExists(createUserViewModel.EmailId))
                    {
                        TempData["MessageCreateUsersErrors"] = "EmailId Already Exists";
                    }
                    else if (_iUserMaster.CheckMobileNoExists(createUserViewModel.MobileNo))
                    {
                        TempData["MessageCreateUsersErrors"] = "MobileNo Already Exists";
                    }
                    else if (_iUserMaster.CheckUsernameExists(createUserViewModel.UserName))
                    {
                        ModelState.AddModelError("", "Username already exists");
                    }
                    else
                    {
                        createUserViewModel.FirstName = UppercaseFirst(createUserViewModel.FirstName);
                        createUserViewModel.LastName  = UppercaseFirst(createUserViewModel.LastName);
                        var usermaster = AutoMapper.Mapper.Map <Usermaster>(createUserViewModel);
                        usermaster.Status     = true;
                        usermaster.CreateDate = DateTime.Now;
                        usermaster.UserId     = 0;
                        usermaster.CreatedBy  = Convert.ToInt32(_sessionHandler.UserId);
                        var salt           = GenerateRandomNumbers.RandomNumbers(20);
                        var saltedpassword = GenerateHashSha512.Sha512(createUserViewModel.Password, salt);

                        var userId = _iUserMaster.AddUser(usermaster, saltedpassword, salt, createUserViewModel.RoleId);
                        if (userId != -1)
                        {
                            TempData["MessageCreateUsers"] = "User Created Successfully";
                        }

                        return(RedirectToAction("Create", "CreateUsers"));
                    }

                    createUserViewModel.ListRole = _iRole.GetAllActiveRolesNotAgent();
                    return(View("Create", createUserViewModel));
                }
                else
                {
                    createUserViewModel.ListRole = _iRole.GetAllActiveRolesNotAgent();
                    return(View("Create", createUserViewModel));
                }
            }
            catch
            {
                throw;
            }
        }
Exemplo n.º 5
0
 private bool CheckUsernameExists(string username)
 {
     try
     {
         var isUser = _iUserMaster.CheckUsernameExists(username);
         return(isUser);
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 6
0
        public async Task <ActionResult> Register(UsermasterView usermaster)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (!this.IsCaptchaValid("Captcha is not valid"))
                    {
                        ModelState.AddModelError("", "Error: captcha is not valid.");
                        return(View(usermaster));
                    }

                    if (_iUserMaster.CheckUsernameExists(usermaster.UserName))
                    {
                        ModelState.AddModelError("", "UserName already exists");
                        return(View(usermaster));
                    }

                    if (_iUserMaster.CheckEmailIdExists(usermaster.EmailId))
                    {
                        ModelState.AddModelError("", "EmailId already exists");
                        return(View(usermaster));
                    }

                    if (_iUserMaster.CheckMobileNoExists(usermaster.MobileNo))
                    {
                        TempData["MessageCreateUsersErrors"] = "MobileNo Already Exists";
                    }

                    var autoUsermaster = AutoMapper.Mapper.Map <Usermaster>(usermaster);
                    var salt           = GenerateRandomNumbers.RandomNumbers(20);
                    var saltedpassword = GenerateHashSha512.Sha512(usermaster.Password, salt);

                    var userId = _iUserMaster.AddUser(autoUsermaster, saltedpassword, salt, Convert.ToInt16(StatusMain.Roles.User));
                    if (userId != -1)
                    {
                        var emailVerficationToken = GenerateHashSha256.ComputeSha256Hash((GenerateRandomNumbers.RandomNumbers(6)));
                        _verification.SendRegistrationVerificationToken(userId, emailVerficationToken);

                        SendingEmailhelper sendingEmailhelper = new SendingEmailhelper();
                        var name = string.Concat(usermaster.FirstName, usermaster.LastName);
                        await sendingEmailhelper.SendVerificationEmailasync(usermaster.EmailId, name, emailVerficationToken, "Registration", Convert.ToString(userId));

                        TempData["MessageRegistration"] = "Thank you. Your Registration has been completed successfully.";
                    }
                    else
                    {
                        TempData["ErrorRegistration"] = "Something Went Wrong While you are registering.Please try after sometime.";
                    }

                    return(RedirectToAction("Register", "Registration"));
                }
                else
                {
                    return(View("Register", usermaster));
                }
            }
            catch
            {
                throw;
            }
        }
        public ActionResult Create(CreateAgentViewModel createAgentViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var isUser = _iUserMaster.CheckUsernameExists(createAgentViewModel.UserName);

                    if (createAgentViewModel.CategoryId == null)
                    {
                        ModelState.AddModelError("", "Select Category");
                    }
                    else if (isUser)
                    {
                        ModelState.AddModelError("", "Username already exists");
                    }
                    else
                    {
                        var usermaster = AutoMapper.Mapper.Map <Usermaster>(createAgentViewModel);
                        usermaster.Status       = true;
                        usermaster.CreateDate   = DateTime.Now;
                        usermaster.UserId       = 0;
                        usermaster.CreatedBy    = Convert.ToInt32(_sessionHandler.UserId);
                        usermaster.IsFirstLogin = true;

                        var salt           = GenerateRandomNumbers.RandomNumbers(20);
                        var saltedpassword = GenerateHashSha512.Sha512(createAgentViewModel.Password, salt);

                        var savedAssignedRoles = new SavedAssignedRoles()
                        {
                            RoleId         = Convert.ToInt16(StatusMain.Roles.Agent),
                            AssignedRoleId = 0,
                            Status         = true,
                            CreateDate     = DateTime.Now
                        };

                        var result = _iUserMaster.AddAgent(usermaster, saltedpassword, savedAssignedRoles, createAgentViewModel.CategoryId, salt);

                        if (result > 0)
                        {
                            TempData["MessageCreateUsers"] = "Agent Created Successfully";
                            return(RedirectToAction("Create", "CreateAgent"));
                        }
                        else
                        {
                            return(View(createAgentViewModel));
                        }
                    }

                    createAgentViewModel.ListofCategory = _category.GetAllActiveSelectListItemCategory();
                    return(View("Create", createAgentViewModel));
                }
                else
                {
                    createAgentViewModel.ListofCategory = _category.GetAllActiveSelectListItemCategory();
                    return(View("Create", createAgentViewModel));
                }
            }
            catch
            {
                throw;
            }
        }
Exemplo n.º 8
0
        public ActionResult Login(LoginViewModel loginViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (!this.IsCaptchaValid("Captcha is not valid"))
                    {
                        ModelState.AddModelError("", "Error: captcha is not valid.");
                        return(View(new LoginViewModel()));
                    }

                    if (!_iUserMaster.CheckUsernameExists(loginViewModel.Username))
                    {
                        ModelState.AddModelError("", "Invalid Credentails");
                        return(View(loginViewModel));
                    }

                    AesAlgorithm aesAlgorithm    = new AesAlgorithm();
                    var          usermasterModel = _iUserMaster.GetUserByUsername(loginViewModel.Username);
                    var          storedpassword  = aesAlgorithm.DecryptString(_password.GetPasswordbyUserId(usermasterModel.UserId));

                    if (storedpassword == loginViewModel.Password)
                    {
                        Session["UserID"]   = usermasterModel.UserId;
                        Session["Username"] = usermasterModel.UserName;
                        int UserID = Convert.ToInt32(usermasterModel.UserId);
                        VW_ProcessByUserManager context             = new VW_ProcessByUserManager(new DataContext());
                        VW_ProcessByUser        objVW_ProcessByUser = context.GetProcessByUserById(UserID);
                        if (objVW_ProcessByUser != null)
                        {
                            Session["UserProcess"] = objVW_ProcessByUser.ProcessName != null ? objVW_ProcessByUser.ProcessName : "";
                        }
                        var user = _iUserMaster.GetUserById(UserID);
                        SetOnlineUser(UserID.ToString());
                        Session["UserPhoto"] = user.ImageName;
                        if (_savedAssignedRoles.GetAssignedRolesbyUserId(usermasterModel.UserId) != null)
                        {
                            // 1 is SuperAdmin
                            if (_savedAssignedRoles.GetAssignedRolesbyUserId(usermasterModel.UserId).RoleId == Convert.ToInt32(ConfigurationManager.AppSettings["SuperAdminRolekey"]))
                            {
                                Session["Role"]     = _savedAssignedRoles.GetAssignedRolesbyUserId(usermasterModel.UserId).RoleId;
                                Session["RoleName"] = "SuperAdmin";
                                return(RedirectToAction("Dashboard", "SuperDashboard"));
                            }

                            // 2 is User
                            if (_savedAssignedRoles.GetAssignedRolesbyUserId(usermasterModel.UserId).RoleId == Convert.ToInt32(ConfigurationManager.AppSettings["UserRolekey"]))
                            {
                                Session["Role"]     = _savedAssignedRoles.GetAssignedRolesbyUserId(usermasterModel.UserId).RoleId;
                                Session["RoleName"] = "User";
                                return(RedirectToAction("Dashboard", "UserDashboard"));
                            }

                            // 3 is Admin
                            if (_savedAssignedRoles.GetAssignedRolesbyUserId(usermasterModel.UserId).RoleId == Convert.ToInt32(ConfigurationManager.AppSettings["AdminRolekey"]))
                            {
                                Session["Role"]     = _savedAssignedRoles.GetAssignedRolesbyUserId(usermasterModel.UserId).RoleId;
                                Session["RoleName"] = "Admin";
                                return(RedirectToAction("Dashboard", "AdminDashboard"));
                            }
                        }
                        else
                        {
                            ModelState.AddModelError("", "Access Not Assigned");
                            return(View(loginViewModel));
                        }

                        return(RedirectToAction("Dashboard", "Dashboard"));
                    }
                    else
                    {
                        ModelState.AddModelError("", "Invalid Credentails");
                        return(View(loginViewModel));
                    }
                }
                else
                {
                    return(View(loginViewModel));
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 9
0
        public ActionResult Create(CreateUserViewModel createUserViewModel, HttpPostedFileBase fileUpload)
        {
            try
            {
                if (createUserViewModel.UserId > 0)
                {
                    ModelState.Remove("UserName");
                    ModelState.Remove("Password");
                    ModelState.Remove("ConfirmPassword");
                    ModelState.Remove("RoleId");
                }
                if (ModelState.IsValid)
                {
                    if (createUserViewModel.UserId == 0)
                    {
                        var isUser = _iUserMaster.CheckUsernameExists(createUserViewModel.UserName);
                        if (isUser)
                        {
                            ModelState.AddModelError("", "Username already exists");
                        }

                        AesAlgorithm aesAlgorithm = new AesAlgorithm();


                        var    usermaster = AutoMapper.Mapper.Map <Usermaster>(createUserViewModel);
                        string path       = Server.MapPath("~/Content/UserImage/");
                        if (!Directory.Exists(path))
                        {
                            Directory.CreateDirectory(path);
                        }
                        if (fileUpload != null && fileUpload.ContentLength > 0)
                        {
                            string extension   = Path.GetExtension(fileUpload.FileName);
                            string newFileName = "u_" + DateTime.Now.Ticks + extension;
                            usermaster.ImageName = newFileName;
                            fileUpload.SaveAs(path + newFileName);
                        }

                        usermaster.Status     = true;
                        usermaster.CreateDate = DateTime.Now;
                        usermaster.UserId     = 0;
                        usermaster.CreatedBy  = Convert.ToInt32(Session["UserID"]);

                        var userId = _iUserMaster.AddUser(usermaster);
                        if (userId != -1)
                        {
                            var passwordMaster = new PasswordMaster
                            {
                                CreateDate = DateTime.Now,
                                UserId     = userId,
                                PasswordId = 0,
                                Password   = aesAlgorithm.EncryptString(createUserViewModel.Password)
                            };

                            var passwordId = _iPassword.SavePassword(passwordMaster);
                            if (passwordId != -1)
                            {
                                var savedAssignedRoles = new SavedAssignedRoles()
                                {
                                    RoleId         = createUserViewModel.RoleId,
                                    UserId         = userId,
                                    AssignedRoleId = 0,
                                    Status         = true,
                                    CreateDate     = DateTime.Now
                                };
                                _savedAssignedRoles.AddAssignedRoles(savedAssignedRoles);

                                TempData["MessageCreateUsers"] = "User Created Successfully";
                            }
                        }
                    }
                    else
                    {
                        var    usermaster = AutoMapper.Mapper.Map <Usermaster>(createUserViewModel);
                        string path       = Server.MapPath("~/Content/UserImage/");
                        if (!Directory.Exists(path))
                        {
                            Directory.CreateDirectory(path);
                        }
                        if (fileUpload != null && fileUpload.ContentLength > 0)
                        {
                            string extension   = Path.GetExtension(fileUpload.FileName);
                            string newFileName = "u_" + DateTime.Now.Ticks + extension;
                            usermaster.ImageName = newFileName;
                            fileUpload.SaveAs(path + newFileName);
                        }

                        usermaster.Status     = true;
                        usermaster.CreateDate = DateTime.Now;
                        usermaster.UserId     = createUserViewModel.UserId;
                        usermaster.CreatedBy  = Convert.ToInt32(Session["UserID"]);

                        var userId = _iUserMaster.UpdateUser(usermaster);
                    }
                    return(RedirectToAction("Create", "CreateUsers"));
                }
                else
                {
                    return(View("Create", createUserViewModel));
                }
            }
            catch
            {
                throw;
            }
        }
Exemplo n.º 10
0
        public ActionResult Login(LoginViewModel loginViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (!_iUserMaster.CheckUsernameExists(loginViewModel.Username))
                    {
                        TempData["LoginErrors"] = "Invalid Credentials";
                        return(View(loginViewModel));
                    }

                    var usermasterModel = _iUserMaster.GetUserByUsername(loginViewModel.Username);
                    if (usermasterModel != null)
                    {
                        if (usermasterModel.Status == false)
                        {
                            TempData["LoginErrors"] = "User Account is Deactivated Please Contact Admin";
                            return(View(loginViewModel));
                        }

                        var usersalt = _iUserMaster.GetUserSaltbyUserid(Convert.ToInt64(usermasterModel.UserId));
                        if (usersalt == null)
                        {
                            TempData["LoginErrors"] = "Entered Username or Password is Invalid";
                            return(View());
                        }

                        var storedpassword = _password.GetPasswordbyUserId(usermasterModel.UserId);
                        if (storedpassword == null)
                        {
                            TempData["LoginErrors"] = "Invalid Credentials";
                            return(View(loginViewModel));
                        }

                        var generatehash = GenerateHashSha512.Sha512(loginViewModel.Password, usersalt.PasswordSalt);


                        if (string.Equals(storedpassword, generatehash, StringComparison.Ordinal))
                        {
                            if (_savedAssignedRoles.GetAssignedRolesbyUserId(usermasterModel.UserId) != null)
                            {
                                var rolesModel = _savedAssignedRoles.GetAssignedRolesbyUserId(usermasterModel.UserId);

                                if (rolesModel.RoleId == Convert.ToInt32(StatusMain.Roles.User))
                                {
                                    if (!_verification.CheckIsEmailVerifiedRegistration(usermasterModel.UserId))
                                    {
                                        TempData["LoginErrors"] = "Please Verify Your Email-Id to Use Application";
                                        return(View(loginViewModel));
                                    }

                                    ApplicationCustomSettings applicationCustomSettings = new ApplicationCustomSettings();
                                    if (applicationCustomSettings.GetGeneralSetting().EnableEmailFeature&& _verify.CheckVerificationCodeExists(usermasterModel.UserId))
                                    {
                                        TempData["LoginErrors"] = "Please Verify Your Email-Id to Use Application";
                                        return(View(loginViewModel));
                                    }
                                }


                                if (rolesModel.RoleId == Convert.ToInt32(StatusMain.Roles.Agent) || rolesModel.RoleId == Convert.ToInt32(StatusMain.Roles.AgentAdmin) || rolesModel.RoleId == Convert.ToInt32(StatusMain.Roles.Hod))
                                {
                                    if (!IsCategogryAssigned(usermasterModel, rolesModel))
                                    {
                                        TempData["LoginErrors"] = "Category is not Assigned, Please contact your administrator";
                                        return(View(loginViewModel));
                                    }
                                }

                                if (usermasterModel.IsFirstLogin)
                                {
                                    Session["ChangePasswordUserId"] = usermasterModel.UserId;
                                    Session["ChangeRoleId"]         = rolesModel.RoleId;
                                    return(RedirectToAction("ChangePassword", "Force"));
                                }

                                AssignSessionValues(usermasterModel, rolesModel);
                                return(RedirectionManager(usermasterModel, rolesModel));
                            }
                            else
                            {
                                TempData["LoginErrors"] = "Access Not Assigned";
                                return(View(loginViewModel));
                            }
                        }
                        else
                        {
                            TempData["LoginErrors"] = "Invalid Credentials";
                            return(View(loginViewModel));
                        }
                    }
                    else
                    {
                        TempData["LoginErrors"] = "Invalid Credentials";
                        return(View(loginViewModel));
                    }
                }
                else
                {
                    return(View(loginViewModel));
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 11
0
        public ActionResult Login(LoginViewModel loginViewModel)
        {
            //AesAlgorithm aesAlgorithm = new AesAlgorithm();
            //var test = aesAlgorithm.DecryptString("07ikhQIubF3dXMDo3glk5A==");
            try
            {
                if (ModelState.IsValid)
                {
                    //if (!this.IsCaptchaValid("Captcha is not valid"))
                    //{
                    //    ModelState.AddModelError("", "Error: captcha is not valid.");
                    //    return View(new LoginViewModel());
                    //}

                    if (!_iUserMaster.CheckUsernameExists(loginViewModel.Username))
                    {
                        ModelState.AddModelError("", "Invalid Credentails");
                        return(View(loginViewModel));
                    }

                    AesAlgorithm aesAlgorithm    = new AesAlgorithm();
                    var          usermasterModel = _iUserMaster.GetUserByUsername(loginViewModel.Username);
                    var          storedpassword  = aesAlgorithm.DecryptString(_password.GetPasswordbyUserId(usermasterModel.UserId));

                    if (storedpassword == loginViewModel.Password)
                    {
                        Session["UserID"]   = usermasterModel.UserId;
                        Session["Username"] = usermasterModel.UserName;
                        FormsAuthentication.SetAuthCookie(usermasterModel.UserName, false);

                        if (_savedAssignedRoles.GetAssignedRolesbyUserId(usermasterModel.UserId) != null)
                        {
                            // 1 is SuperAdmin
                            if (_savedAssignedRoles.GetAssignedRolesbyUserId(usermasterModel.UserId).RoleId == Convert.ToInt32(ConfigurationManager.AppSettings["SuperAdminRolekey"]))
                            {
                                Session["Role"] = _savedAssignedRoles.GetAssignedRolesbyUserId(usermasterModel.UserId).RoleId;
                                return(RedirectToAction("Dashboard", "SuperDashboard"));
                            }

                            // 2 is User
                            if (_savedAssignedRoles.GetAssignedRolesbyUserId(usermasterModel.UserId).RoleId == Convert.ToInt32(ConfigurationManager.AppSettings["UserRolekey"]))
                            {
                                Session["Role"] = _savedAssignedRoles.GetAssignedRolesbyUserId(usermasterModel.UserId).RoleId;
                                return(RedirectToAction("Dashboard", "UserDashboard"));
                            }

                            // 3 is Admin
                            if (_savedAssignedRoles.GetAssignedRolesbyUserId(usermasterModel.UserId).RoleId == Convert.ToInt32(ConfigurationManager.AppSettings["AdminRolekey"]))
                            {
                                Session["Role"] = _savedAssignedRoles.GetAssignedRolesbyUserId(usermasterModel.UserId).RoleId;
                                return(RedirectToAction("Dashboard", "AdminDashboard"));
                            }
                        }
                        else
                        {
                            ModelState.AddModelError("", "Access Not Assigned");
                            return(View(loginViewModel));
                        }

                        return(RedirectToAction("Dashboard", "Dashboard"));
                    }
                    else
                    {
                        ModelState.AddModelError("", "Invalid Credentails");
                        return(View(loginViewModel));
                    }
                }
                else
                {
                    return(View(loginViewModel));
                }
            }
            catch (Exception)
            {
                throw;
            }
        }