Exemple #1
0
        public async Task ValidateAsync(IBuyerContainer buyerContainer)
        {
            if (buyerContainer == null)
            {
                throw new ArgumentNullException(nameof(buyerContainer));
            }

            var tights = await this.GetBy(buyerContainer);

            if (buyerContainer.BuyerId.HasValue && tights == null)
            {
                throw new InvalidOperationException($"Tights not found by id {buyerContainer.BuyerId}");
            }
        }
Exemple #2
0
        public async Task ValidateAsync(IBuyerContainer BuyerContainer)
        {
            if (BuyerContainer == null)
            {
                throw new ArgumentNullException(nameof(BuyerContainer));
            }
            if (BuyerContainer.BuyerId.HasValue)
            {
                var department = await this.BuyerDAL.GetAsync(new BuyerIdentityModel(BuyerContainer.BuyerId.Value));

                if (department == null)
                {
                    throw new InvalidOperationException($"Department not found by id {BuyerContainer.BuyerId}");
                }
            }
        }
Exemple #3
0
 private Task <Buyer> GetBy(IBuyerContainer departmentContainer)
 {
     return(this.BuyerDataAccess.GetByAsync(departmentContainer));
 }
Exemple #4
0
 public async Task <Buyer> GetByAsync(IBuyerContainer buyer)
 {
     return(buyer.BuyerId.HasValue
         ? this.Mapper.Map <Buyer>(await this.Context.Buyer.FirstOrDefaultAsync(x => x.Id == buyer.BuyerId))
         : null);
 }