Ejemplo n.º 1
0
        public async Task ValidateAsync(ISupplierContainer supplierContainer)
        {
            if (supplierContainer == null)
            {
                throw new ArgumentNullException(nameof(supplierContainer));
            }

            var supplier = await this.GetBy(supplierContainer);

            if (supplierContainer.SupplierId.HasValue && supplier == null)
            {
                throw new InvalidOperationException($"Supplier not found by id {supplierContainer.SupplierId}");
            }
        }
Ejemplo n.º 2
0
 private Task <Supplier> GetBy(ISupplierContainer supplierContainer)
 {
     return(this.SupplierDataAccess.GetByAsync(supplierContainer));
 }
Ejemplo n.º 3
0
 public async Task <Supplier> GetByAsync(ISupplierContainer supplier)
 {
     return(supplier.SupplierId.HasValue
         ? this.Mapper.Map <Supplier>(await this.Context.Supplier.FirstOrDefaultAsync(x => x.Id == supplier.SupplierId))
         : null);
 }