Ejemplo n.º 1
0
        public ActionResult ChangePassword()
        {
            if (ProjectSession.LoginType != SystemEnumList.LoginType.Guest.GetHashCode())
            {
                return(this.RedirectToAction(Actions.BookGrid, Controllers.Book));
            }

            if (!string.IsNullOrEmpty(ConvertTo.String(ProjectSession.CustomerId)))
            {
                int userId = ProjectSession.CustomerId.ToInteger();
                using (Services.ServiceContext changePasswordService = new Services.ServiceContext(true))
                {
                    var userModel = changePasswordService.Search(new SmartLibrary.Models.Customer()
                    {
                        Id = userId
                    }).FirstOrDefault();

                    if (userModel != null && userModel.Id > 0)
                    {
                        SmartLibrary.Models.ChangePassword changePassword = new SmartLibrary.Models.ChangePassword();
                        changePassword.Id = userModel.Id;
                        return(this.View(Views.ChangePassword, changePassword));
                    }
                }
            }

            return(this.View(Views.ChangePassword));
        }
Ejemplo n.º 2
0
        public ActionResult ChangePassword(SmartLibrary.Models.ChangePassword changePassword)
        {
            using (Services.ServiceContext changePasswordService = new Services.ServiceContext(true))
            {
                if (changePassword == null || ConvertTo.ToInteger(changePassword.Id) <= 0)
                {
                    this.ViewBag.ChangePasswordMessage = SmartLibrary.Resources.Account.UserNotExist;
                    return(this.View(Views.ChangePassword, changePassword));
                }

                var userModel = changePasswordService.Search(new SmartLibrary.Models.Customer()
                {
                    Id = changePassword.Id,
                }).FirstOrDefault();

                if (userModel != null && userModel.Id > 0)
                {
                    if (ProjectConfiguration.IsActiveDirectory)
                    {
                        ActiveDirectoryRegister activeDirectoryChangePassword = new ActiveDirectoryRegister()
                        {
                            Email                    = userModel.Email,
                            Password                 = changePassword.CurrentPassword,
                            NewPassword              = changePassword.NewPassword,
                            ConfirmPassword          = changePassword.ConfirmPassword,
                            EncryptedPassword        = changePassword.EncryptedCurrentPassword,
                            EncryptedNewPassword     = changePassword.EncryptedNewPassword,
                            EncryptedConfirmPassword = changePassword.EncryptedConfirmPassword
                        };

                        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(General.Member), Infrastructure.SystemEnumList.MessageBoxType.Error);
                            return(this.View(Views.ChangePassword, changePassword));
                        }
                    }
                }
                else
                {
                    this.AddToastMessage(Resources.General.Error, Account.UserNotExist, Infrastructure.SystemEnumList.MessageBoxType.Error);
                    return(this.View(Views.ChangePassword, changePassword));
                }

                this.AddToastMessage(Resources.General.Success, Account.PasswordChangedSuccessfully, Infrastructure.SystemEnumList.MessageBoxType.Success);
                return(new RedirectResult(this.Url.Action(Views.BookGrid, Controllers.Book)));
            }
        }
Ejemplo n.º 3
0
        public ActionResult ChangePassword()
        {
            if (!string.IsNullOrEmpty(ConvertTo.String(ProjectSession.UserId)))
            {
                int userId = ProjectSession.UserId.ToInteger();
                using (Services.ServiceContext changePasswordService = new Services.ServiceContext(true))
                {
                    var userModel = changePasswordService.Search(new SmartLibrary.Models.User()
                    {
                        Id = userId
                    }).FirstOrDefault();

                    if (userModel != null && userModel.Id > 0)
                    {
                        SmartLibrary.Models.ChangePassword changePassword = new SmartLibrary.Models.ChangePassword();
                        changePassword.Id = userModel.Id;
                        return(this.View(Views.ChangePassword, changePassword));
                    }
                }
            }

            return(this.View(Views.ChangePassword));
        }