예제 #1
0
        public ActionResult Index(string returnUrl)
        {
            if (ProjectSession.UserId > 0)
            {
                return(new RedirectResult(this.Url.Action(Actions.AllActivities, Controllers.Home)));
            }

            Login loginModel = new Login();

            if (this.Request.Cookies["SmartLibrary"] != null)
            {
                HttpCookie cookie = this.Request.Cookies["SmartLibrary"];

                loginModel.RememberMe = ConvertTo.ToBoolean(cookie.Values.Get("LoginIsRemember"));
                if (loginModel.RememberMe)
                {
                    if (cookie.Values.Get("LoginEmail") != null)
                    {
                        loginModel.Email = cookie.Values.Get("LoginEmail");
                    }

                    if (cookie.Values.Get("LoginPassword") != null)
                    {
                        loginModel.Password = EncryptionDecryption.DecryptByTripleDES(cookie.Values.Get("LoginPassword"));
                    }
                }
            }

            loginModel.ReturnUrl = returnUrl;
            return(this.View(Views.Index, loginModel));
        }
예제 #2
0
        public ActionResult StaffLogin(string returnUrl)
        {
            Login loginModel = new Login();

            if (this.Request.Cookies["SmartLibraryAD"] != null)
            {
                System.Web.HttpCookie cookie = this.Request.Cookies["SmartLibraryAD"];

                loginModel.RememberMe = ConvertTo.ToBoolean(cookie.Values.Get("LoginIsRemember"));
                if (loginModel.RememberMe)
                {
                    if (cookie.Values.Get("LoginEmail") != null)
                    {
                        loginModel.Email = cookie.Values.Get("LoginEmail");
                    }

                    if (cookie.Values.Get("LoginPassword") != null)
                    {
                        loginModel.Password = EncryptionDecryption.DecryptByTripleDES(cookie.Values.Get("LoginPassword"));
                    }
                }
            }

            loginModel.ReturnUrl = returnUrl;
            return(this.View(Views.StaffLogin, loginModel));
        }
예제 #3
0
        public JsonResult HistoryOfMember([ModelBinder(typeof(DataTablesBinder))] IDataTablesRequest requestModel, string searchdata = "", string data = "", int historyType = 1)
        {
            int id             = ConvertTo.ToInteger(EncryptionDecryption.DecryptByTripleDES(data));
            int totalRecord    = 0;
            int filteredRecord = 0;

            if (historyType == 1)
            {
                List <BorrowedBook> borrowedBookList;
                borrowedBookList = this.commonDataBL.GetBookDetailsOfCustomer(id, searchdata, requestModel.Start + 1, requestModel.Start + requestModel.Length, requestModel.Columns.ElementAt(requestModel.OrderColumn).Data, requestModel.OrderDir);
                if (borrowedBookList != null && borrowedBookList.Count > 0)
                {
                    totalRecord    = borrowedBookList.FirstOrDefault().TotalRecords;
                    filteredRecord = borrowedBookList.FirstOrDefault().TotalRecords;
                }

                return(this.Json(new DataTablesResponse(requestModel.Draw, borrowedBookList, filteredRecord, totalRecord), JsonRequestBehavior.AllowGet));
            }
            else
            {
                List <SpaceBooking> spaceList;
                spaceList = this.commonDataBL.GetSpaceDetailsOfCustomer(id, searchdata, requestModel.Start + 1, requestModel.Start + requestModel.Length, requestModel.Columns.ElementAt(requestModel.OrderColumn).Data, requestModel.OrderDir);
                if (spaceList != null && spaceList.Count > 0)
                {
                    totalRecord    = spaceList.FirstOrDefault().TotalRecords;
                    filteredRecord = spaceList.FirstOrDefault().TotalRecords;
                }

                return(this.Json(new DataTablesResponse(requestModel.Draw, spaceList, filteredRecord, totalRecord), JsonRequestBehavior.AllowGet));
            }
        }
예제 #4
0
        public ActionResult SignUp(string q, string loginType, string pcnumber)
        {
            if (q == null)
            {
                return(this.RedirectToAction(Views.Index));
            }

            string emailDecrypt     = EncryptionDecryption.DecryptByTripleDES(q);
            string pcNoDecrypt      = EncryptionDecryption.DecryptByTripleDES(pcnumber);
            var    decryptLoginType = EncryptionDecryption.DecryptByTripleDES(loginType);

            if (string.IsNullOrEmpty(emailDecrypt))
            {
                return(this.RedirectToAction(Actions.Index, Controllers.Account));
            }

            Customer objCustomer = this.memberDataBL.GetCustomerList(new Customer()).Where(x => x.Email == emailDecrypt).FirstOrDefault();

            if (objCustomer == null)
            {
                objCustomer           = new Customer();
                objCustomer.Email     = emailDecrypt;
                objCustomer.LoginType = Convert.ToInt32(decryptLoginType);
                objCustomer.PCNumber  = pcNoDecrypt;
                return(this.View(Views.SignUp, objCustomer));
            }

            this.AddToastMessage(Account.CreateAccount, Messages.MemberAlreadyRegistered, Infrastructure.SystemEnumList.MessageBoxType.Error);
            return(this.RedirectToAction(Actions.Index, Controllers.Account));
        }
예제 #5
0
        public ActionResult StaffSignUp(string q, string pcnumber)
        {
            Customer user = new Customer();

            if (q == null)
            {
                return(this.RedirectToAction(Actions.ActiveDirectoryLogin, Controllers.ActiveDirectory));
            }

            string emailDecrypt = EncryptionDecryption.DecryptByTripleDES(q);
            string pcNoDecrypt  = EncryptionDecryption.DecryptByTripleDES(pcnumber);

            if (string.IsNullOrEmpty(emailDecrypt))
            {
                return(this.RedirectToAction(Actions.ActiveDirectoryLogin, Controllers.ActiveDirectory));
            }

            var response = this.commonBL.GetADuserDataWithPCNo(pcNoDecrypt);

            if (response == null && response.Status != SystemEnumList.ApiStatus.Success.GetDescription())
            {
                this.AddToastMessage(Account.CreateAccount, response.Message, Infrastructure.SystemEnumList.MessageBoxType.Error);
                return(this.RedirectToAction(Actions.ActiveDirectoryLogin, Controllers.ActiveDirectory));
            }

            if (response.Status == SystemEnumList.ApiStatus.Success.GetDescription())
            {
                user.FirstName = response.Data.Name;
                user.Email     = response.Data.Email;
                user.LoginType = SystemEnumList.LoginType.Staff.GetHashCode();
                user.PCNumber  = response.Data.PCNumber;
                user.Active    = true;
                user.Language  = 2;
                int saveStatus = this.memberDataBL.SaveCustomer(user);
                var msgBox     = Infrastructure.SystemEnumList.MessageBoxType.Success;
                if (saveStatus > 0)
                {
                    return(this.RedirectToAction(Actions.StaffLogin, Controllers.ActiveDirectory));
                }
                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.RedirectToAction(Actions.StaffLogin, Controllers.ActiveDirectory));
                    }
                }
            }

            this.AddToastMessage(Account.CreateAccount, response.Message, Infrastructure.SystemEnumList.MessageBoxType.Error);
            return(this.RedirectToAction(Actions.ActiveDirectoryLogin, Controllers.ActiveDirectory));
        }
예제 #6
0
        public ActionResult ResetPassword(string q)
        {
            ResetPassword resetPasswordModel = new ResetPassword();

            if (!string.IsNullOrEmpty(q))
            {
                try
                {
                    string parameterString = EncryptionDecryption.DecryptByTripleDES(q);
                    var    parameters      = parameterString.Split('#');

                    if (parameters != null && parameters.Count() == 2)
                    {
                        DateTime urlExpiredTime = DateTime.ParseExact(parameters[1], ProjectConfiguration.EmailDateTimeFormat, System.Globalization.CultureInfo.InvariantCulture);
                        int      id             = parameters[0].ToInteger();

                        if (DateTime.Now > urlExpiredTime)
                        {
                            this.AddToastMessage(Resources.General.Error, Messages.UrlExpiredMessage, SystemEnumList.MessageBoxType.Error);
                            return(this.RedirectToAction(Actions.Index, Controllers.Account));
                        }

                        var user = this.memberDataBL.GetCustomerList(new Customer {
                            Id = id
                        }).FirstOrDefault();
                        if (user != null && user.Id > 0)
                        {
                            resetPasswordModel.Id = user.Id;
                        }
                        else
                        {
                            this.AddToastMessage(Resources.General.Error, Messages.UserAccountNotmatched, SystemEnumList.MessageBoxType.Error);
                            return(this.RedirectToAction(Actions.Index, Controllers.Account));
                        }
                    }
                    else
                    {
                        this.AddToastMessage(Resources.General.Error, Messages.InvalidUrlMessage, SystemEnumList.MessageBoxType.Error);
                        return(this.RedirectToAction(Actions.Index, Controllers.Account));
                    }
                }
                catch (Exception)
                {
                    return(this.RedirectToAction(Actions.Index, Controllers.Account));
                }
            }
            else
            {
                this.ViewBag.ResetPasswordMessage = Messages.InvalidUrlMessage;
                return(this.RedirectToAction(Actions.Index, Controllers.Account));
            }

            return(this.View(Views.ResetPassword, resetPasswordModel));
        }
예제 #7
0
 public override Task OnDisconnected(bool stopCalled)
 {
     if (!string.IsNullOrEmpty(Context.QueryString["uid"]) && !string.IsNullOrEmpty(Context.QueryString["ia"]))
     {
         var connectionId = EncryptionDecryption.DecryptByTripleDES(Context.QueryString["uid"]) + "-" + EncryptionDecryption.DecryptByTripleDES(Context.QueryString["ia"]);
         if (SignalRConnections.connections.ContainsKey(connectionId))
         {
             var connectionList = SignalRConnections.connections[connectionId];
             connectionList.RemoveAll(x => x == Context.ConnectionId);
         }
     }
     return(base.OnDisconnected(stopCalled));
 }
예제 #8
0
 public override Task OnConnected()
 {
     if (!string.IsNullOrEmpty(Context.QueryString["uid"]) && !string.IsNullOrEmpty(Context.QueryString["ia"]))
     {
         var connectionId = EncryptionDecryption.DecryptByTripleDES(Context.QueryString["uid"]) + "-" + EncryptionDecryption.DecryptByTripleDES(Context.QueryString["ia"]);
         if (!SignalRConnections.connections.ContainsKey(connectionId))
         {
             SignalRConnections.connections.Add(connectionId, new List <string>());
         }
         SignalRConnections.connections[connectionId].Add(Context.ConnectionId);
     }
     return(base.OnConnected());
 }
예제 #9
0
        public ActionResult HistoryOfMember(string data = "")
        {
            this.ViewData["CurrentPageAccessRight"] = this.PageAccessRight;

            string decryptedVal = EncryptionDecryption.DecryptByTripleDES(data);

            if (decryptedVal != string.Empty)
            {
                this.ViewData["ID"] = data;

                Customer model = new Customer()
                {
                    Id = decryptedVal.ToInteger()
                };

                var customer = this.memberDataBL.GetCustomerList(model).FirstOrDefault();
                this.ViewBag.MemberName = customer.FirstName + " " + customer.LastName;
                return(this.View(Views.HistoryOfMember));
            }
            else
            {
                return(this.RedirectToAction(Actions.CustomerList, Controllers.Member));
            }
        }
예제 #10
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 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));
        }
예제 #11
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));
        }
예제 #12
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));
            }
        }
예제 #13
0
 public ActionResult AllActivities(string borrowedBookId = null, string spaceBookingId = null)
 {
     this.ViewBag.BorrowedBookId = borrowedBookId == null ? null : EncryptionDecryption.DecryptByTripleDES(borrowedBookId);
     this.ViewBag.SpaceBookingId = spaceBookingId == null ? null : EncryptionDecryption.DecryptByTripleDES(spaceBookingId);
     return(this.View());
 }
예제 #14
0
        public ActionResult ResetPassword(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.memberDataBL.GetCustomerList(new Customer()
            {
                Id = resetPassword.Id
            }).FirstOrDefault();

            if (userModel != null && userModel.Id > 0)
            {
                if (ProjectConfiguration.IsActiveDirectory)
                {
                    ActiveDirectoryRegister activeDirectoryChangePassword = new ActiveDirectoryRegister()
                    {
                        Email           = userModel.Email,
                        Password        = EncryptionDecryption.DecryptByTripleDES(userModel.Password),
                        NewPassword     = resetPassword.NewPassword,
                        ConfirmPassword = resetPassword.ConfirmPassword
                    };

                    var changePasswordResponse = this.commonBL.ActiveDirectoryChangePasswordResponse(activeDirectoryChangePassword);

                    if (changePasswordResponse == null || changePasswordResponse.Status != SystemEnumList.ApiStatus.Success.GetDescription())
                    {
                        this.AddToastMessage(Resources.General.Error, changePasswordResponse?.Message ?? Messages.ErrorMessage.SetArguments(Resources.General.Member), Infrastructure.SystemEnumList.MessageBoxType.Error);
                        return(this.View(Views.ResetPassword, resetPassword));
                    }
                }

                if (resetPassword.NewPassword == resetPassword.ConfirmPassword)
                {
                    userModel.Password = Infrastructure.EncryptionDecryption.EncryptByTripleDES(resetPassword.NewPassword);
                    bool response = this.commonBL.ChangePassword(userModel.Id, userModel.Password, Infrastructure.SystemEnumList.ChangePasswordFor.Customer.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, 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));
            }
        }
예제 #15
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));
        }
예제 #16
0
        public ActionResult AddEditRole(string id)
        {
            Role model = new Role();

            model.Id = 0;

            if (!string.IsNullOrEmpty(id))
            {
                string decryptedVal = EncryptionDecryption.DecryptByTripleDES(id);
                if (decryptedVal != string.Empty)
                {
                    model.Id = decryptedVal.ToInteger();
                }
                else
                {
                    return(this.RedirectToAction(Actions.Role, Controllers.User));
                }
            }

            if (model.Id > 0)
            {
                model = this.userDataBL.GetRoleList(model).FirstOrDefault();
            }
            else
            {
                model.Active = true;
            }

            List <PageAccess> dbPageAccessList;

            dbPageAccessList = (List <PageAccess>) this.commonBL.GetPageAccessBasedOnUserRole(model.Id);
            List <Page> pageList = this.masterBL.GetPageList(new Page()
            {
                Active = SystemEnumList.ActiveStatus.Active.GetHashCode().ToBoolean()
            });
            var pageAccessList = new List <PageAccess>();

            foreach (var page in pageList)
            {
                PageAccess pageAccess   = new PageAccess();
                PageAccess pageAccessdb = dbPageAccessList?.Where(x => x.PageId == page.Id).FirstOrDefault();
                if (pageAccessdb != null)
                {
                    pageAccess          = pageAccessdb;
                    pageAccess.PageName = page.Name;
                }
                else
                {
                    pageAccess.PageName    = page.Name;
                    pageAccess.RoleId      = model.Id;
                    pageAccess.PageId      = page.Id;
                    pageAccess.CreatedBy   = ProjectSession.UserId;
                    pageAccess.CreatedDate = DateTime.Now;
                    pageAccess.IsView      = false;
                    pageAccess.IsAddUpdate = false;
                    pageAccess.IsDelete    = false;
                }

                pageAccessList.Add(pageAccess);
            }

            model.PageAccessList = pageAccessList;

            this.ViewData["CurrentPageAccessRight"] = this.PageAccessRight;
            return(this.View(model));
        }
예제 #17
0
        public ActionResult BookDetailView(string bookId = null)
        {
            Book   retmodel;
            string returnUrl = string.Empty;

            if (this.Request.UrlReferrer != null)
            {
                returnUrl = this.Request.UrlReferrer.AbsoluteUri;
            }
            else
            {
                returnUrl = this.HttpContext.Request.Url.OriginalString.Replace(this.HttpContext.Request.Url.PathAndQuery, string.Empty);
                if (this.HttpContext.Request.ApplicationPath.Length > 2)
                {
                    returnUrl = returnUrl + this.HttpContext.Request.ApplicationPath;
                }

                returnUrl = returnUrl + "/" + Controllers.Book + "/" + Actions.BookList;
            }

            string decryptedVal = EncryptionDecryption.DecryptByTripleDES(bookId);

            if (decryptedVal != string.Empty)
            {
                int id = decryptedVal.ToInteger();
                retmodel                   = this.commonBL.GetBookDetailsComplete(id, ProjectSession.CustomerId);
                retmodel.Description       = HttpUtility.HtmlDecode(retmodel.Description);
                retmodel.CurrentBookStatus = this.commonBL.GetCurrentBookStatus(id, SystemEnumList.ActiveStatus.Active.GetHashCode());
                retmodel.BookPendingEntry  = this.commonBL.CheckBookPendingEntry(id, ProjectSession.CustomerId);
                retmodel.StatusId          = this.commonBL.GetCheckBookBorrowStatus(id, ProjectSession.CustomerId);
            }
            else
            {
                return(this.Redirect(returnUrl));
            }

            retmodel.CommentList = this.bookDataBL.Search <BookDiscussion>(new BookDiscussion()
            {
                BookId = decryptedVal.ToInteger(), StartRowIndex = 1, EndRowIndex = ProjectConfiguration.CommentSize
            });

            int totalRecord = retmodel.CommentList?.FirstOrDefault()?.TotalRecords ?? 0;

            this.ViewBag.TotalComments = totalRecord;
            this.ViewBag.TotalPage     = Math.Ceiling((float)totalRecord / ProjectConfiguration.CommentSize);

            retmodel.ReturnUrl = returnUrl;
            List <SelectListItem> lstStatus = CommonBL.GetListForDropdown <Statuses>(searchCriteria: new SmartLibrary.Models.Statuses()
            {
                StatusGroupID = 1
            });

            lstStatus.Insert(0, new SelectListItem()
            {
                Text = "All", Value = "-1"
            });
            this.ViewBag.StatusList = lstStatus;
            this.ViewBag.ActiveList = Enum.GetValues(typeof(ActiveStatus)).Cast <ActiveStatus>().Select(x => new SelectListItem {
                Text = x.ToString(), Value = ((int)x).ToString()
            }).ToList();

            return(this.View(retmodel));
        }