public async Task ValidateAsync(IOrderContainer orderContainer) { if (orderContainer == null) { throw new ArgumentNullException(nameof(orderContainer)); } var order = await this.GetBy(orderContainer); if (orderContainer.OrderId.HasValue && order == null) { throw new InvalidOperationException($"Order not found by id {orderContainer.OrderId}"); } }
public async Task <Order> GetByAsync(IOrderContainer order) { return(order.OrderId.HasValue ? this.Mapper.Map <Order>(await this.Context.Order.FirstOrDefaultAsync(x => x.Id == order.OrderId)) : null); }
private Task <Order> GetBy(IOrderContainer orderContainer) { return(this.OrderDataAccess.GetByAsync(orderContainer)); }