Example #1
0
        public virtual async Task <_ <AdminEntity> > AddAccount(AdminEntity model, string specific_uid = null)
        {
            model.Should().NotBeNull();
            model.UserName.Should().NotBeNullOrEmpty();

            var data = new _ <AdminEntity>();

            model.InitEntity();
            if (ValidateHelper.IsNotEmpty(model.PassWord))
            {
                model.PassWord = this._passHelper.Encrypt(model.PassWord);
            }
            if (!this.__valid_user_name__(model.UserName, out var msg))
            {
                return(data.SetErrorMsg(msg));
            }
            //检查用户名是否存在
            if (await this.IsUserNameExist(model.UserName))
            {
                return(data.SetErrorMsg("用户名已存在"));
            }

            if (ValidateHelper.IsNotEmpty(specific_uid))
            {
                model.SetId(specific_uid);
            }

            await this.adminAccountRepository.InsertAsync(model);

            data.SetSuccessData(model);
            return(data);
        }
Example #2
0
        public async Task <_ <AdminEntity> > AddAdmin(AdminEntity model)
        {
            model.Should().NotBeNull("adminservice add model");
            model.UserName.Should().NotBeNullOrEmpty("adminservice add model username");

            var res = new _ <AdminEntity>();

            model.InitEntity();
            if (await this.adminRepository.ExistAsync(x => x.UserName == model.UserName))
            {
                return(res.SetErrorMsg("用户名已存在"));
            }

            await this.adminRepository.InsertAsync(model);

            return(res.SetSuccessData(model));
        }
Example #3
0
        public virtual async Task UpdateUser(AdminEntity model)
        {
            model.Should().NotBeNull("admin service model");
            model.Id.Should().NotBeNullOrEmpty("admin service model uid");

            var data = new _ <AdminEntity>();

            var user = await this.adminRepository.QueryOneAsync(x => x.Id == model.Id);

            user.Should().NotBeNull($"admin不存在:{model.Id}");

            user.SetField(new
            {
                model.UserImg,
                model.NickName,
                model.Sex,
                model.ContactPhone,
                model.ContactEmail
            });

            user.SetUpdateTime();

            await this.adminRepository.UpdateAsync(user);
        }
Example #4
0
        public virtual async Task UpdateUser(AdminEntity model)
        {
            model.Should().NotBeNull("admin service model");
            model.UID.Should().NotBeNullOrEmpty("admin service model uid");

            var data = new _ <AdminEntity>();

            var user = await this._adminRepo.GetFirstAsync(x => x.UID == model.UID);

            user.Should().NotBeNull($"admin不存在:{model.UID}");

            user.SetField(new
            {
                model.UserImg,
                model.NickName,
                model.Sex,
                model.ContactPhone,
                model.ContactEmail
            });

            user.Update();

            await this._adminRepo.UpdateAsync(user);
        }