コード例 #1
0
        public async Task AddUserList(UserInfoDto model)
        {
            var user = model.MapTo <Users>();
            await _userRepository.InsertAsync(user);

            Logger.Debug("_userRepository通过构造函数注入注入的方式!");
            Logger.Debug("这是通过属性注入的方式!");
        }
コード例 #2
0
        public string AddorUpdateUserList(UserInfoDto model)
        {
            string Stars = "ok";

            try
            {
                if (model.id == 0)
                {
                    Users user = new Users();

                    user.UserName             = model.UserName;
                    user.Email                = model.Email;
                    user.Password             = string.IsNullOrWhiteSpace(model.Password) ? "123456" : model.Password;
                    user.Address              = string.IsNullOrWhiteSpace(model.Email) ? "深南大道" : model.Email;
                    user.Phone                = string.IsNullOrWhiteSpace(model.Phone) ? "123456789" : model.Phone;
                    user.TrueName             = string.IsNullOrWhiteSpace(model.TrueName) ? "user" : model.TrueName;
                    user.Enabled              = true;
                    user.CreationTime         = DateTime.Now;
                    user.CreatorUserId        = 11;
                    user.LastModificationTime = DateTime.Now;
                    user.IsDeleted            = false;
                    user.UpdateDate           = DateTime.Now;
                    _userRepository.Insert(user);
                }
                else
                {
                    Users user = _userRepository.Get(model.id);
                    user.UserName             = model.UserName;
                    user.Email                = model.Email;
                    user.Password             = string.IsNullOrWhiteSpace(model.Password) ? "123456" : model.Password;
                    user.Address              = string.IsNullOrWhiteSpace(model.Email) ? "深南大道" : model.Email;
                    user.Phone                = string.IsNullOrWhiteSpace(model.Phone) ? "123456789" : model.Phone;
                    user.TrueName             = string.IsNullOrWhiteSpace(model.TrueName) ? "user" : model.TrueName;
                    user.Enabled              = true;
                    user.CreationTime         = DateTime.Now;
                    user.CreatorUserId        = 11;
                    user.LastModificationTime = DateTime.Now;
                    user.IsDeleted            = false;
                    _userRepository.Update(user);
                }
                _unitOfWorkManager.Current.SaveChanges();
            }
            catch (Exception ex)
            {
                throw;
            }

            return(Stars);
        }