public async Task ValidateAsync(ITightsContainer tightsContainer) { if (tightsContainer == null) { throw new ArgumentNullException(nameof(tightsContainer)); } var tights = await this.GetBy(tightsContainer); if (tightsContainer.TightsId.HasValue && tights == null) { throw new InvalidOperationException($"Tights not found by id {tightsContainer.TightsId}"); } }
private Task <Tights> GetBy(ITightsContainer departmentContainer) { return(this.TightsDataAccess.GetByAsync(departmentContainer)); }
public async Task <Tights> GetByAsync(ITightsContainer tights) { return(tights.TightsId.HasValue ? this.Mapper.Map <Tights>(await this.Context.Tights.FirstOrDefaultAsync(x => x.Id == tights.TightsId)) : null); }