예제 #1
0
        public ActionResult Update(UsersModel users)
        {
            ResponseData responseData = new ResponseData();

            WIS.Entities.Account usersModel = _accountBo.GetById(users.UserId);
            if (usersModel != null && usersModel.Id > 0)
            {
                bool isSendMail = !usersModel.Email.Equals(users.Email);
                usersModel.FullName = users.FullName;
                usersModel.Email    = users.Email;
                usersModel.Birthday = users.Birthday;
                usersModel.Avatar   = users.Avatar;
                usersModel.Address  = users.Address;
                usersModel.Gender   = users.Gender;
                usersModel.Phone    = users.Mobile;
                usersModel.UserType = users.UserType.Value;

                ErrorCodes errorCode = _accountBo.Update(usersModel);

                Msg.Error = errorCode != ErrorCodes.Success;
                Msg.Title = StringUtils.GetEnumDescription(errorCode);
                return(AuthorizeJson(Msg));
            }

            WIS.Entities.Account usersByName = _accountBo.GetByUserName(users.UserName);
            if (usersByName == null || usersByName.Id <= 0)
            {
                string strPass = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 6);
                WIS.Entities.Account usersModelTemp = new Account();
                usersModelTemp.UserName         = users.UserName;
                usersModelTemp.Password         = Crypton.Encrypt(strPass);
                usersModelTemp.FullName         = users.FullName;
                usersModelTemp.Email            = users.Email;
                usersModelTemp.Birthday         = users.Birthday;
                usersModelTemp.Avatar           = users.Avatar;
                usersModelTemp.Address          = users.Address;
                usersModelTemp.PasswordQuestion = string.Empty;
                usersModelTemp.PasswordAnswer   = string.Empty;
                usersModelTemp.CreatedDate      = DateTime.Now;
                usersModelTemp.Status           = (int)UserStatusAdmin.Actived;
                usersModelTemp.Gender           = users.Gender;
                usersModelTemp.Phone            = users.Mobile;
                usersModelTemp.UserType         = users.UserType.Value;

                ErrorCodes errorCodes = _accountBo.Insert(usersModelTemp);
                Msg.Error = errorCodes != ErrorCodes.Success;
                Msg.Title = StringUtils.GetEnumDescription(errorCodes);
                return(AuthorizeJson(Msg));
            }

            Msg.Error = true;
            Msg.Title = StringUtils.GetEnumDescription(ErrorCodes.UserNameExisted);
            return(AuthorizeJson(Msg));
        }
예제 #2
0
        public ActionResult GetUserById(int userId)
        {
            WIS.Entities.Account users = _accountBo.GetById(userId);
            if (users != null)
            {
                UsersModel modelCms = new UsersModel(users);
                modelCms.Password = Crypton.Decrypt(modelCms.Password);
                Msg.Obj           = modelCms;
            }

            return(AuthorizeJson(Msg));
        }
예제 #3
0
        public ActionResult GetUserById(int userId)
        {
            ResponseData responseData = new ResponseData();

            WIS.Entities.Account users = _accountBo.GetById(userId);
            if (users != null)
            {
                UsersModel modelCms = new UsersModel(users);
                modelCms.Password    = Crypton.Decrypt(modelCms.Password);
                responseData.Data    = modelCms;
                responseData.Success = true;
                responseData.Message = StringUtils.GetEnumDescription(ErrorCodes.Success);
            }

            return(Json(responseData));
        }
예제 #4
0
        public JsonResult UpdateCatePermission(int userId, int userType)
        {
            WIS.Entities.Account usersModel = _accountBo.GetById(userId);
            if (usersModel != null && usersModel.Id > 0)
            {
                usersModel.UserType = userType;

                ErrorCodes errorCode = _accountBo.Update(usersModel);

                Msg.Error = errorCode != ErrorCodes.Success;
                Msg.Title = StringUtils.GetEnumDescription(errorCode);
                return(AuthorizeJson(Msg));
            }

            Msg.Error = false;
            Msg.Title = StringUtils.GetEnumDescription(ErrorCodes.UserNameExisted);
            return(AuthorizeJson(Msg));
        }
예제 #5
0
        public ActionResult ResetPassWord(int userId, string passWord)
        {
            WIS.Entities.Account usersModel = _accountBo.GetById(userId);
            if (usersModel != null && !string.IsNullOrEmpty(passWord))
            {
                usersModel.Password = Crypton.Encrypt(passWord);
                ErrorCodes errorCodes = _accountBo.Update(usersModel);

                Msg.Error = errorCodes != ErrorCodes.Success;
                Msg.Title = StringUtils.GetEnumDescription(errorCodes);
                return(AuthorizeJson(Msg));
            }


            Msg.Error = false;
            Msg.Title = "";
            return(AuthorizeJson(Msg));
        }
예제 #6
0
        public JsonResult UpdateCatePermission(int userId, int userType)
        {
            ResponseData responseData = new ResponseData();

            WIS.Entities.Account usersModel = _accountBo.GetById(userId);
            if (usersModel != null && usersModel.Id > 0)
            {
                usersModel.UserType = userType;

                ErrorCodes errorCode = _accountBo.Update(usersModel);

                responseData.Success = errorCode == ErrorCodes.Success;
                responseData.Message = StringUtils.GetEnumDescription(errorCode);
                return(Json(responseData));
            }

            responseData.Success = false;
            responseData.Message = StringUtils.GetEnumDescription(ErrorCodes.UserNameExisted);
            return(Json(responseData));
        }
예제 #7
0
        public ActionResult ResetPassWord(int userId, string passWord)
        {
            ResponseData responseData = new ResponseData();

            WIS.Entities.Account usersModel = _accountBo.GetById(userId);
            if (usersModel != null && !string.IsNullOrEmpty(passWord))
            {
                usersModel.Password = Crypton.Encrypt(passWord);
                ErrorCodes errorCodes = _accountBo.Update(usersModel);

                responseData.Success = errorCodes == ErrorCodes.Success;
                responseData.Message = StringUtils.GetEnumDescription(errorCodes);
                return(Json(responseData));
            }


            responseData.Success = false;
            responseData.Message = "";
            return(Json(responseData));
        }
예제 #8
0
        public ActionResult UpdateStatus(int userId)
        {
            WIS.Entities.Account usersModel = _accountBo.GetById(userId);
            if (usersModel != null)
            {
                int status = usersModel.Status == (int)UserStatusAdmin.Actived
                    ? (int)UserStatusAdmin.Deactived
                    : (int)UserStatusAdmin.Actived;

                usersModel.Status = status;
                ErrorCodes errorCodes = _accountBo.Update(usersModel);

                Msg.Error = errorCodes != ErrorCodes.Success;
                Msg.Title = StringUtils.GetEnumDescription(errorCodes);
                return(AuthorizeJson(Msg));
            }


            Msg.Error = true;
            Msg.Title = "";
            return(AuthorizeJson(Msg));
        }
예제 #9
0
        public ActionResult UpdateStatus(int userId)
        {
            ResponseData responseData = new ResponseData();

            WIS.Entities.Account usersModel = _accountBo.GetById(userId);
            if (usersModel != null)
            {
                int status = usersModel.Status == (int)UserStatusAdmin.Actived
                    ? (int)UserStatusAdmin.Deactived
                    : (int)UserStatusAdmin.Actived;

                usersModel.Status = status;
                ErrorCodes errorCodes = _accountBo.Update(usersModel);

                responseData.Success = errorCodes == ErrorCodes.Success;
                responseData.Message = StringUtils.GetEnumDescription(errorCodes);
                return(Json(responseData));
            }


            responseData.Success = false;
            responseData.Message = "";
            return(Json(responseData));
        }