Example #1
0
        public ActionResult CustomerGrid()
        {
            this.ViewData["CurrentPageAccessRight"] = this.PageAccessRight;
            List <Customer> customerList = new List <Customer>();
            Customer        model        = new Customer()
            {
                StartRowIndex = 1,
                EndRowIndex   = ProjectConfiguration.PageSizeGrid,
            };

            customerList = this.memberDataBL.GetCustomerList(model);
            foreach (var customer in customerList)
            {
                customer.IdEncrypted = EncryptionDecryption.EncryptByTripleDES(customer.Id.ToString());
            }

            int totalRecord = customerList.FirstOrDefault()?.TotalRecords ?? 0;

            this.ViewBag.TotalPage = Math.Ceiling((float)totalRecord / 20);
            return(this.View(Views.CustomerGrid, customerList));
        }
Example #2
0
        public ActionResult ResetPassword(SmartLibrary.Models.ResetPassword resetPassword)
        {
            if (resetPassword == null || ConvertTo.ToInteger(resetPassword.Id) <= 0)
            {
                this.AddToastMessage(Resources.General.Error, Account.UserNotExist, SystemEnumList.MessageBoxType.Error);
                return(this.View(Views.ResetPassword, resetPassword));
            }

            if (resetPassword.NewPassword != resetPassword.ConfirmPassword)
            {
                this.AddToastMessage(Resources.General.Error, Account.NewPasswordAndConfirmPasswordNotMatch, SystemEnumList.MessageBoxType.Error);
                return(this.View(Views.ResetPassword, resetPassword));
            }

            var userModel = this.userDataBL.GetUsersList(new User()
            {
                Id = resetPassword.Id
            }).FirstOrDefault();

            if (userModel != null && userModel.Id > 0)
            {
                userModel.Password = EncryptionDecryption.EncryptByTripleDES(resetPassword.NewPassword);
                bool response = this.commonBL.ChangePassword(userModel.Id, userModel.Password, Infrastructure.SystemEnumList.ChangePasswordFor.User.GetDescription());
                if (response)
                {
                    this.AddToastMessage(Resources.General.Success, Account.PasswordChangedSuccessfully, Infrastructure.SystemEnumList.MessageBoxType.Success);
                    return(new RedirectResult(this.Url.Action(Views.Index, Controllers.Account)));
                }
                else
                {
                    this.AddToastMessage(Resources.General.Error, Messages.ChangePasswordError, Infrastructure.SystemEnumList.MessageBoxType.Error);
                    return(this.View(Views.ResetPassword, resetPassword));
                }
            }
            else
            {
                this.AddToastMessage(Resources.General.Error, Account.UserNotExist, Infrastructure.SystemEnumList.MessageBoxType.Error);
                return(this.View(Views.ResetPassword, resetPassword));
            }
        }
        public ActionResult StaffLogin(Login model)
        {
            if (this.ModelState.IsValid)
            {
                if (ProjectConfiguration.IsActiveDirectory)
                {
                    var adResponse = this.commonBL.ActiveDirectoryResponse(model);
                    if (adResponse == null || adResponse.Status?.ToLower() == "failure" || !string.IsNullOrEmpty(adResponse.Error_description) || !string.IsNullOrEmpty(adResponse.Error))
                    {
                        this.AddToastMessage(Resources.General.Error, Account.InvalidCredenitals, Infrastructure.SystemEnumList.MessageBoxType.Error);
                        model.Password = EncryptionDecryption.DecryptByTripleDES(model.Password);
                        return(this.View(Views.StaffLogin, model));
                    }

                    if (string.IsNullOrEmpty(adResponse.UserName) && string.IsNullOrEmpty(adResponse.Email))
                    {
                        this.AddToastMessage(Resources.General.Error, Messages.EmailNotExistInAD, Infrastructure.SystemEnumList.MessageBoxType.Error);
                        model.Password = EncryptionDecryption.DecryptByTripleDES(model.Password);
                        return(this.View(Views.StaffLogin, model));
                    }

                    Login userLogin = this.commonBL.GetUserLoginwithEmail(adResponse.Email);
                    if (userLogin != null && userLogin.Userdata != null)
                    {
                        if (userLogin.Userdata.Active.ToBoolean() == false)
                        {
                            this.AddToastMessage(Resources.General.Error, Account.InactiveUserMessage, Infrastructure.SystemEnumList.MessageBoxType.Error);
                            return(this.View(Views.StaffLogin, model));
                        }

                        if (model.RememberMe)
                        {
                            System.Web.HttpCookie cookie = new System.Web.HttpCookie("SmartLibraryAD");
                            cookie.Values.Add("LoginEmail", model.Email);
                            cookie.Values.Add("LoginPassword", EncryptionDecryption.EncryptByTripleDES(model.Password));
                            cookie.Values.Add("LoginIsRemember", Convert.ToString(model.RememberMe));
                            cookie.Expires  = DateTime.Now.AddMonths(1);
                            cookie.HttpOnly = true;
                            this.Response.Cookies.Add(cookie);
                        }
                        else
                        {
                            this.Response.Cookies["SmartLibraryAD"].Expires = DateTime.Now.AddMonths(-1);
                        }

                        ProjectSession.AdminPortalLanguageId = userLogin.Userdata.Language ?? SystemEnumList.Language.English.GetHashCode();
                        ProjectSession.UserId         = userLogin.Userdata.Id;
                        ProjectSession.UserRole       = userLogin.Userdata.RoleId;
                        ProjectSession.UserRoleRights = this.commonBL.GetPageAccessBasedOnUserRole(userLogin.Userdata.RoleId);
                        ProjectSession.SuperAdmin     = userLogin.Userdata.SuperAdmin ?? false;
                        ProjectSession.LoginType      = SystemEnumList.LoginType.Staff.GetHashCode();

                        if (!string.IsNullOrEmpty(model.ReturnUrl))
                        {
                            if (this.Url.IsLocalUrl(model.ReturnUrl))
                            {
                                return(this.Redirect(model.ReturnUrl));
                            }
                        }

                        return(this.RedirectToAction(Actions.BookGrid, Controllers.Book));
                    }
                    else
                    {
                        this.AddToastMessage(Resources.General.Error, Account.InvalidCredenitals, Infrastructure.SystemEnumList.MessageBoxType.Error);
                        model.Password = EncryptionDecryption.DecryptByTripleDES(model.Password);
                        return(this.View(Views.StaffLogin, model));
                    }
                }
                else
                {
                    model.Password = EncryptionDecryption.EncryptByTripleDES(model.Password);
                    Login response = this.commonBL.GetUserLogin(model);
                    if (response != null && response.Userdata != null)
                    {
                        if (response.Userdata.Active.ToBoolean() == false)
                        {
                            this.AddToastMessage(Resources.General.Error, Account.InactiveUserMessage, Infrastructure.SystemEnumList.MessageBoxType.Error);
                            return(this.View(Views.StaffLogin, model));
                        }

                        if (model.RememberMe)
                        {
                            System.Web.HttpCookie cookie = new System.Web.HttpCookie("SmartLibraryAD");
                            cookie.Values.Add("LoginEmail", model.Email);
                            cookie.Values.Add("LoginPassword", EncryptionDecryption.EncryptByTripleDES(model.Password));
                            cookie.Values.Add("LoginIsRemember", Convert.ToString(model.RememberMe));
                            cookie.Expires  = DateTime.Now.AddMonths(1);
                            cookie.HttpOnly = true;
                            this.Response.Cookies.Add(cookie);
                        }
                        else
                        {
                            this.Response.Cookies["SmartLibraryAD"].Expires = DateTime.Now.AddMonths(-1);
                        }

                        ProjectSession.AdminPortalLanguageId = response.Userdata.Language ?? SystemEnumList.Language.English.GetHashCode();
                        ProjectSession.UserId         = response.Userdata.Id;
                        ProjectSession.UserRole       = response.Userdata.RoleId;
                        ProjectSession.UserRoleRights = this.commonBL.GetPageAccessBasedOnUserRole(response.Userdata.RoleId);
                        ProjectSession.SuperAdmin     = response.Userdata.SuperAdmin ?? false;
                        if (!string.IsNullOrEmpty(model.ReturnUrl))
                        {
                            if (this.Url.IsLocalUrl(model.ReturnUrl))
                            {
                                return(this.Redirect(model.ReturnUrl));
                            }
                        }

                        return(this.RedirectToAction(Actions.BookGrid, Controllers.Book));
                    }
                    else
                    {
                        this.AddToastMessage(Resources.General.Error, Account.InvalidCredenitals, Infrastructure.SystemEnumList.MessageBoxType.Error);
                        model.Password = EncryptionDecryption.DecryptByTripleDES(model.Password);
                        return(this.View(Views.StaffLogin, model));
                    }
                }
            }
            else if (string.IsNullOrEmpty(model.Email))
            {
                this.ViewBag.ErrorMessage = SmartLibrary.Resources.Messages.RequiredFieldMessage.SetArguments(SmartLibrary.Resources.Account.InvalidEmailAddress);
            }
            else if (string.IsNullOrEmpty(model.Password))
            {
                this.ViewBag.ErrorMessage = Messages.RequiredFieldMessage.SetArguments(SmartLibrary.Resources.Account.Password);
            }

            return(this.View(Views.StaffLogin, model));
        }
Example #4
0
        public ActionResult Index(Login model)
        {
            if (this.ModelState.IsValid)
            {
                if (ProjectConfiguration.IsActiveDirectory)
                {
                    var adResponse = this.commonBL.FormAuthenticationGuestLogin(model);
                    if (adResponse == null || adResponse.Status?.ToLower() == "failure" || !string.IsNullOrEmpty(adResponse.Error_description) || !string.IsNullOrEmpty(adResponse.Error))
                    {
                        this.AddToastMessage(Resources.General.Error, Account.InvalidCredenitals, Infrastructure.SystemEnumList.MessageBoxType.Error);
                        model.Password = EncryptionDecryption.DecryptByTripleDES(model.Password);
                        return(this.View(Views.Index, model));
                    }

                    if (string.IsNullOrEmpty(adResponse.UserName))
                    {
                        this.AddToastMessage(Resources.General.Error, Messages.EmailNotExistInAD, Infrastructure.SystemEnumList.MessageBoxType.Error);
                        model.Password = EncryptionDecryption.DecryptByTripleDES(model.Password);
                        return(this.View(Views.Index, model));
                    }

                    Login customerLogin = this.commonBL.GetCustomerLoginwithEmail(adResponse.UserName);
                    if (customerLogin != null && customerLogin.Customerdata != null)
                    {
                        if (customerLogin.Customerdata != null && customerLogin.Customerdata.Active.ToBoolean() == false)
                        {
                            this.AddToastMessage(Resources.General.Error, Account.InactiveCustomerMessage, Infrastructure.SystemEnumList.MessageBoxType.Error);
                            return(this.View(Views.Index, model));
                        }

                        if (model.RememberMe)
                        {
                            HttpCookie cookie = new HttpCookie("SmartLibrarySite");
                            cookie.Values.Add("SiteEmail", model.Email);
                            cookie.Values.Add("SitePassword", EncryptionDecryption.EncryptByTripleDES(model.Password));
                            cookie.Values.Add("SiteIsRemember", Convert.ToString(model.RememberMe));
                            cookie.Values.Add("SiteLanguageId", Convert.ToString(customerLogin.Customerdata.Language));
                            cookie.Expires  = DateTime.Now.AddMonths(1);
                            cookie.HttpOnly = true;
                            this.Response.Cookies.Add(cookie);
                        }
                        else
                        {
                            this.Response.Cookies["SmartLibrarySite"].Expires = DateTime.Now.AddMonths(-1);
                        }

                        ProjectSession.CustomerId               = customerLogin.Customerdata.Id;
                        ProjectSession.UserId                   = customerLogin.Customerdata.Id;
                        ProjectSession.CustomerLanguageId       = customerLogin.Customerdata.Language;
                        ProjectSession.UserPortalLanguageId     = customerLogin.Customerdata.Language ?? SystemEnumList.Language.English.GetHashCode();
                        ProjectSession.CustomerProfileImagePath = customerLogin.Customerdata.ProfileImagePath;
                        ProjectSession.LoginType                = SystemEnumList.LoginType.Guest.GetHashCode();

                        if (!string.IsNullOrEmpty(model.ReturnUrl))
                        {
                            if (this.Url.IsLocalUrl(model.ReturnUrl))
                            {
                                return(this.Redirect(model.ReturnUrl));
                            }
                        }

                        return(this.RedirectToAction(Actions.BookGrid, Controllers.Book));
                    }
                    else
                    {
                        this.AddToastMessage(Resources.General.Error, Account.InvalidCredenitals, Infrastructure.SystemEnumList.MessageBoxType.Error);
                        model.Password = EncryptionDecryption.DecryptByTripleDES(model.Password);
                        return(this.View(Views.Index, model));
                    }
                }

                model.Password = EncryptionDecryption.EncryptByTripleDES(model.Password);
                Login response = this.commonBL.GetCustomerLogin(model);
                if (response != null && response.Customerdata != null)
                {
                    if (response.Customerdata != null && response.Customerdata.Active.ToBoolean() == false)
                    {
                        this.AddToastMessage(Resources.General.Error, Account.InactiveCustomerMessage, Infrastructure.SystemEnumList.MessageBoxType.Error);
                        return(this.View(Views.Index, model));
                    }

                    if (model.RememberMe)
                    {
                        HttpCookie cookie = new HttpCookie("SmartLibrarySite");
                        cookie.Values.Add("SiteEmail", model.Email);
                        cookie.Values.Add("SitePassword", model.Password);
                        cookie.Values.Add("SiteIsRemember", Convert.ToString(model.RememberMe));
                        cookie.Values.Add("SiteLanguageId", Convert.ToString(response.Customerdata.Language));
                        cookie.Expires  = DateTime.Now.AddMonths(1);
                        cookie.HttpOnly = true;
                        this.Response.Cookies.Add(cookie);
                    }
                    else
                    {
                        this.Response.Cookies["SmartLibrarySite"].Expires = DateTime.Now.AddMonths(-1);
                    }

                    ProjectSession.CustomerId               = response.Customerdata.Id;
                    ProjectSession.UserId                   = response.Customerdata.Id;
                    ProjectSession.CustomerLanguageId       = response.Customerdata.Language;
                    ProjectSession.UserPortalLanguageId     = response.Customerdata.Language ?? SystemEnumList.Language.English.GetHashCode();
                    ProjectSession.CustomerProfileImagePath = response.Customerdata.ProfileImagePath;

                    if (!string.IsNullOrEmpty(model.ReturnUrl))
                    {
                        if (this.Url.IsLocalUrl(model.ReturnUrl))
                        {
                            return(this.Redirect(model.ReturnUrl));
                        }
                    }

                    return(this.RedirectToAction(Actions.BookGrid, Controllers.Book));
                }
                else
                {
                    this.AddToastMessage(Resources.General.Error, Account.InvalidCredenitals, Infrastructure.SystemEnumList.MessageBoxType.Error);
                    model.Password = EncryptionDecryption.DecryptByTripleDES(model.Password);
                    return(this.View(Views.Index, model));
                }
            }
            else if (string.IsNullOrEmpty(model.Email))
            {
                this.ViewBag.ErrorMessage = SmartLibrary.Resources.Messages.RequiredFieldMessage.SetArguments(SmartLibrary.Resources.Account.InvalidEmailAddress);
            }
            else if (string.IsNullOrEmpty(model.Password))
            {
                this.ViewBag.ErrorMessage = Messages.RequiredFieldMessage.SetArguments(SmartLibrary.Resources.Account.Password);
            }

            return(this.View(Views.Index, model));
        }
Example #5
0
        public ActionResult SignUp(Customer user, HttpPostedFileBase file, string loginType)
        {
            int loginTypeId = 0;

            if (user.LoginType == null && int.TryParse(EncryptionDecryption.DecryptByTripleDES(loginType), out loginTypeId))
            {
                user.LoginType = loginTypeId;
            }

            this.ModelState.Clear();
            this.TryValidateModel(user);
            if (loginTypeId == SystemEnumList.LoginType.Guest.GetHashCode())
            {
                this.ModelState.Remove(nameof(user.PCNumber));
            }

            if (!this.ModelState.IsValid)
            {
                return(this.View(Views.SignUp, user));
            }

            ActiveDirectoryRegister activeDirectoryRegister = new ActiveDirectoryRegister()
            {
                Email     = user.Email,
                Password  = user.Password,
                FirstName = user.FirstName,
                LastName  = user.LastName,
                LoginType = user.LoginType,
                Gender    = user.Gender,
                Phone     = user.Phone
            };

            if (ProjectConfiguration.IsActiveDirectory)
            {
                var registerResponse = this.commonBL.ActiveDirectoryRegisterResponse(activeDirectoryRegister);
                var isUserExist      = registerResponse.Data?.IsUserExists;
                if (registerResponse.Status == SystemEnumList.ApiStatus.Success.GetDescription() && isUserExist != null && !isUserExist.Value)
                {
                    user.AGUserId = registerResponse.Data.UserId;
                    if (file != null)
                    {
                        byte[] fileContent = null;
                        var    reader      = new System.IO.BinaryReader(file.InputStream);
                        fileContent = reader.ReadBytes(file.ContentLength); ////Get file data byte array
                        string errorMsg = CommonValidation.ValidateFileTypeProperMessage(file.FileName, fileContent, Constants.MAXIMUM_FILE_UPLOAD_SIZE_BYTES, new[] { SystemEnumList.FileExtension.Jpeg, SystemEnumList.FileExtension.Png, SystemEnumList.FileExtension.Jpg });
                        if (!string.IsNullOrEmpty(errorMsg))
                        {
                            this.AddToastMessage(Resources.General.Error, errorMsg, SystemEnumList.MessageBoxType.Error);
                            return(this.View(Views.SignUp, user));
                        }
                    }

                    if (file != null)
                    {
                        var profileImage = Guid.NewGuid().ToString() + System.IO.Path.GetExtension(file.FileName);
                        var imagepath    = this.Server.MapPath("~/" + ProjectConfiguration.UserProfileImagePath + "/");
                        file.SaveAs(imagepath + profileImage);
                        user.ProfileImagePath = profileImage;
                    }

                    var encryptedPassword = EncryptionDecryption.EncryptByTripleDES(user.Password);
                    user.Password = encryptedPassword;
                    user.PCNumber = EncryptionDecryption.DecryptByTripleDES(user.PCNumber);
                    int    saveStatus = this.memberDataBL.SaveCustomer(user);
                    string msg        = string.Empty;
                    var    msgBox     = Infrastructure.SystemEnumList.MessageBoxType.Success;
                    if (saveStatus > 0)
                    {
                        msg = Account.AccountCreatedSuccessfully;
                    }
                    else
                    {
                        if (saveStatus == -2)
                        {
                            this.AddToastMessage(Account.CreateAccount, Messages.DuplicateMessage.SetArguments(Resources.General.Customer), Infrastructure.SystemEnumList.MessageBoxType.Error);
                            return(this.View(Views.SignUp, user));
                        }
                        else
                        {
                            this.AddToastMessage(Account.CreateAccount, Messages.ErrorMessage.SetArguments(Resources.General.Customer), Infrastructure.SystemEnumList.MessageBoxType.Error);
                            return(this.View(Views.SignUp, user));
                        }
                    }

                    this.AddToastMessage(Account.CreateAccount, msg, msgBox);
                    if (user.LoginType == SystemEnumList.LoginType.Guest.GetHashCode())
                    {
                        return(this.RedirectToAction(Actions.Index, Controllers.Account));
                    }
                    else if (user.LoginType == SystemEnumList.LoginType.Staff.GetHashCode())
                    {
                        return(this.RedirectToAction(Actions.StaffLogin, Controllers.ActiveDirectory));
                    }
                    else
                    {
                        return(this.RedirectToAction(Actions.ActiveDirectoryLogin, Controllers.ActiveDirectory));
                    }
                }

                this.AddToastMessage(Account.CreateAccount, registerResponse.Message.SetArguments(Resources.General.Customer), Infrastructure.SystemEnumList.MessageBoxType.Error);
                return(this.View(Views.SignUp, user));
            }

            if (file != null)
            {
                byte[] fileContent = null;
                var    reader      = new System.IO.BinaryReader(file.InputStream);
                fileContent = reader.ReadBytes(file.ContentLength); ////Get file data byte array
                string errorMsg = CommonValidation.ValidateFileTypeProperMessage(file.FileName, fileContent, Constants.MAXIMUM_FILE_UPLOAD_SIZE_BYTES, new[] { SystemEnumList.FileExtension.Jpeg, SystemEnumList.FileExtension.Png, SystemEnumList.FileExtension.Jpg });
                if (!string.IsNullOrEmpty(errorMsg))
                {
                    this.AddToastMessage(Resources.General.Error, errorMsg, SystemEnumList.MessageBoxType.Error);
                    return(this.View(Views.SignUp, user));
                }
            }

            if (file != null)
            {
                var profileImage = Guid.NewGuid().ToString() + System.IO.Path.GetExtension(file.FileName);
                var imagepath    = this.Server.MapPath("~/" + ProjectConfiguration.UserProfileImagePath + "/");
                file.SaveAs(imagepath + profileImage);
                user.ProfileImagePath = profileImage;
            }

            var passwordEncrypted = EncryptionDecryption.EncryptByTripleDES(user.Password);

            user.Password = passwordEncrypted;
            int    status     = this.memberDataBL.SaveCustomer(user);
            string message    = string.Empty;
            var    messagebox = Infrastructure.SystemEnumList.MessageBoxType.Success;

            if (status > 0)
            {
                message = Account.AccountCreatedSuccessfully;
            }
            else
            {
                if (status == -2)
                {
                    this.AddToastMessage(Account.CreateAccount, Messages.DuplicateMessage.SetArguments(Resources.General.Customer), Infrastructure.SystemEnumList.MessageBoxType.Error);
                    return(this.View(Views.SignUp, user));
                }
                else
                {
                    this.AddToastMessage(Account.CreateAccount, Messages.ErrorMessage.SetArguments(Resources.General.Customer), Infrastructure.SystemEnumList.MessageBoxType.Error);
                    return(this.View(Views.SignUp, user));
                }
            }

            this.AddToastMessage(Account.CreateAccount, message, messagebox);
            if (user.LoginType == SystemEnumList.LoginType.Guest.GetHashCode())
            {
                return(this.RedirectToAction(Actions.Index, Controllers.Account));
            }
            else if (user.LoginType == SystemEnumList.LoginType.Staff.GetHashCode())
            {
                return(this.RedirectToAction(Actions.StaffLogin, Controllers.ActiveDirectory));
            }
            else
            {
                return(this.RedirectToAction(Actions.ActiveDirectoryLogin, Controllers.ActiveDirectory));
            }
        }
Example #6
0
        public ActionResult StaffLogin(Login model)
        {
            if (this.ModelState.IsValid)
            {
                if (ProjectConfiguration.IsActiveDirectory)
                {
                    var adResponse = this.commonBL.ActiveDirectoryResponse(model);
                    if (adResponse == null || adResponse.Status?.ToLower() == "failure" || !string.IsNullOrEmpty(adResponse.Error_description) || !string.IsNullOrEmpty(adResponse.Error))
                    {
                        this.AddToastMessage(Resources.General.Error, Account.InvalidCredenitals, Infrastructure.SystemEnumList.MessageBoxType.Error);
                        model.Password = EncryptionDecryption.DecryptByTripleDES(model.Password);
                        return(this.View(Views.StaffLogin, model));
                    }

                    if (string.IsNullOrEmpty(adResponse.UserName) && string.IsNullOrEmpty(adResponse.Email))
                    {
                        this.AddToastMessage(Resources.General.Error, Messages.EmailNotExistInAD, Infrastructure.SystemEnumList.MessageBoxType.Error);
                        model.Password = EncryptionDecryption.DecryptByTripleDES(model.Password);
                        return(this.View(Views.StaffLogin, model));
                    }

                    Login customerLogin = this.commonBL.GetCustomerLoginwithEmail(adResponse.Email);
                    if (customerLogin != null && customerLogin.Customerdata != null)
                    {
                        if (customerLogin.Customerdata.Active.ToBoolean() == false)
                        {
                            this.AddToastMessage(Resources.General.Error, Account.InactiveUserMessage, Infrastructure.SystemEnumList.MessageBoxType.Error);
                            return(this.View(Views.StaffLogin, model));
                        }

                        this.SetCookies(model, customerLogin.Customerdata.Language);

                        ProjectSession.CustomerId               = customerLogin.Customerdata.Id;
                        ProjectSession.UserId                   = customerLogin.Customerdata.Id;
                        ProjectSession.CustomerLanguageId       = customerLogin.Customerdata.Language;
                        ProjectSession.UserPortalLanguageId     = customerLogin.Customerdata.Language ?? SystemEnumList.Language.English.GetHashCode();
                        ProjectSession.CustomerProfileImagePath = customerLogin.Customerdata.ProfileImagePath;
                        ProjectSession.LoginType                = SystemEnumList.LoginType.Staff.GetHashCode();

                        if (!string.IsNullOrEmpty(model.ReturnUrl))
                        {
                            if (this.Url.IsLocalUrl(model.ReturnUrl))
                            {
                                return(this.Redirect(model.ReturnUrl));
                            }
                        }

                        return(this.RedirectToAction(Actions.BookGrid, Controllers.Book));
                    }
                    else
                    {
                        var adUserDetail = this.commonBL.GetADuserDataWithPCNo(model.Email);

                        if (adUserDetail == null)
                        {
                            this.AddToastMessage(Resources.General.Error, Account.InvalidCredenitals, Infrastructure.SystemEnumList.MessageBoxType.Error);
                            model.Password = EncryptionDecryption.DecryptByTripleDES(model.Password);
                            return(this.View(Views.StaffLogin, model));
                        }

                        if (string.IsNullOrEmpty(adUserDetail.Data.Email))
                        {
                            this.AddToastMessage(Resources.General.Error, Account.EmailNotExist, Infrastructure.SystemEnumList.MessageBoxType.Error);
                            model.Password = EncryptionDecryption.DecryptByTripleDES(model.Password);
                            return(this.View(Views.StaffLogin, model));
                        }

                        var customerdata = new Customer()
                        {
                            Email     = adUserDetail.Data.Email,
                            FirstName = adUserDetail.Data.Name,
                            LastName  = string.Empty,
                            Active    = true,
                            Language  = ConvertTo.ToShort(Language.English.GetHashCode()),
                            LoginType = ConvertTo.ToInteger(LoginType.Staff.GetHashCode()),
                            PCNumber  = adUserDetail.Data.PCNumber,
                        };

                        int saveStatus = this.memberDataBL.SaveCustomer(customerdata);
                        if (saveStatus > 0)
                        {
                            Login customerData = this.commonBL.GetCustomerLoginwithEmail(adResponse.Email);

                            ProjectSession.CustomerId               = customerData.Customerdata.Id;
                            ProjectSession.UserId                   = customerData.Customerdata.Id;
                            ProjectSession.CustomerLanguageId       = customerData.Customerdata.Language;
                            ProjectSession.UserPortalLanguageId     = customerData.Customerdata.Language ?? SystemEnumList.Language.English.GetHashCode();
                            ProjectSession.CustomerProfileImagePath = customerData.Customerdata.ProfileImagePath;
                            ProjectSession.LoginType                = SystemEnumList.LoginType.Staff.GetHashCode();
                            if (!string.IsNullOrEmpty(model.ReturnUrl))
                            {
                                if (this.Url.IsLocalUrl(model.ReturnUrl))
                                {
                                    return(this.Redirect(model.ReturnUrl));
                                }
                            }

                            return(this.RedirectToAction(Actions.BookGrid, Controllers.Book));
                        }
                    }
                }
                else
                {
                    model.Password = EncryptionDecryption.EncryptByTripleDES(model.Password);
                    Login response = this.commonBL.GetCustomerLogin(model);
                    if (response != null && response.Customerdata != null)
                    {
                        if (response.Customerdata.Active.ToBoolean() == false)
                        {
                            this.AddToastMessage(Resources.General.Error, Account.InactiveUserMessage, Infrastructure.SystemEnumList.MessageBoxType.Error);
                            return(this.View(Views.StaffLogin, model));
                        }

                        this.SetCookies(model, response.Customerdata.Language);
                        ProjectSession.CustomerId               = response.Customerdata.Id;
                        ProjectSession.UserId                   = response.Customerdata.Id;
                        ProjectSession.CustomerLanguageId       = response.Customerdata.Language;
                        ProjectSession.UserPortalLanguageId     = response.Customerdata.Language ?? SystemEnumList.Language.English.GetHashCode();
                        ProjectSession.CustomerProfileImagePath = response.Customerdata.ProfileImagePath;
                        if (!string.IsNullOrEmpty(model.ReturnUrl))
                        {
                            if (this.Url.IsLocalUrl(model.ReturnUrl))
                            {
                                return(this.Redirect(model.ReturnUrl));
                            }
                        }

                        return(this.RedirectToAction(Actions.BookGrid, Controllers.Book));
                    }
                    else
                    {
                        this.AddToastMessage(Resources.General.Error, Account.InvalidCredenitals, Infrastructure.SystemEnumList.MessageBoxType.Error);
                        model.Password = EncryptionDecryption.DecryptByTripleDES(model.Password);
                        return(this.View(Views.StaffLogin, model));
                    }
                }
            }
            else if (string.IsNullOrEmpty(model.Email))
            {
                this.ViewBag.ErrorMessage = SmartLibrary.Resources.Messages.RequiredFieldMessage.SetArguments(SmartLibrary.Resources.Account.InvalidEmailAddress);
            }
            else if (string.IsNullOrEmpty(model.Password))
            {
                this.ViewBag.ErrorMessage = Messages.RequiredFieldMessage.SetArguments(SmartLibrary.Resources.Account.Password);
            }

            return(this.View(Views.StaffLogin, model));
        }