コード例 #1
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.InitSelf();
            if (await this._adminRepo.ExistAsync(x => x.UserName == model.UserName))
            {
                return(res.SetErrorMsg("用户名已存在"));
            }

            await this._adminRepo.AddAsync(model);

            return(res.SetSuccessData(model));
        }