示例#1
0
        public OperationResult Register(RegisterAccount command)
        {
            var operationResult = new OperationResult();

            if (string.IsNullOrWhiteSpace(command.Mobile) ||
                string.IsNullOrWhiteSpace(command.FullName) ||
                string.IsNullOrWhiteSpace(command.Username) ||
                string.IsNullOrWhiteSpace(command.Password) ||
                string.IsNullOrWhiteSpace(command.RePassword))
            {
                return(operationResult.Failed(ApplicationMessage.RegisterErrorMessage));
            }

            if (_accountRepo.Exists(c => c.Username == command.Username || c.Mobile == command.Mobile))
            {
                return(operationResult.Failed(ApplicationMessage.duplicated));
            }
            if (command.Password != command.RePassword)
            {
                return(operationResult.Failed(ApplicationMessage.PasswordsNotMatch));
            }

            var path        = $"ProfileImage";
            var Picturepath = _fileUploader.Upload(command.ProfilePicture, path);

            var password = PasswordHelper.EncodePasswordMd5(command.Password);

            var Account = new Account(command.FullName, command.Username, command.Mobile,
                                      password, command.RoleId, Picturepath);

            _accountRepo.Create(Account);
            _accountRepo.Save();
            return(operationResult.Succeeded("ثبت نام شما در فروشگاه انجام شد میتواند در فروشگاه لاگین کنید"));
        }