Пример #1
0
        public async Task <int> ChangeStockAsync(Guid userId, Guid goodsId, decimal stock)
        {
            var goods = await _dkmsRepository.FirstAsync <GoodsStockEntity>(s => s.UserId == userId && s.GoodsId == goodsId);

            goods.Stock = goods.Stock + stock;
            return(await _dkmsRepository.DbContext.SaveChangesAsync());
        }
        public async Task <int> DeleteAsync <TProperty>(Guid userId, Guid id) where TProperty : DkmsPropertyEntity
        {
            var property = await _dkmsRepository.FirstAsync <TProperty>(s => s.UserId == userId && s.Id == id);

            if (property == null)
            {
                return(0);
            }
            _dkmsRepository.DbContext.Set <TProperty>().Remove(property);
            return(await _dkmsRepository.DbContext.SaveChangesAsync());
        }
Пример #3
0
        public async Task <string> LoginAsync(AccountEntity parameters)
        {
            var account = await _dkmsRepository.FirstAsync <AccountEntity>(s => s.Phone == parameters.Phone);

            if (account == null)
            {
                throw new DkmsException("用户名或密码错误");
            }
            if (!_passwordFactory.VerifyPassword(account, parameters.Password))
            {
                throw new DkmsException("用户名或密码错误");
            }
            var tokenString = _tokenBuilder.Build();
            var token       = new TokenEntity
            {
                Token  = tokenString,
                UserId = account.Id
            };
            await _dkmsRepository.AddAsync(token);

            return(tokenString);
        }