public SupplierRateDTO AddSupplierRate(int supplierId, decimal rate, DateTime startDate, DateTime?endDate) { if (endDate.HasValue && startDate >= endDate.Value) { throw new ValidationException("The end date must be greater than start date"); } SupplierDTO supplier = Get(supplierId); if (supplier == null) { throw new NotFoundException($"The supplier of id {supplierId} does not exists"); } ValidateOverLapping(startDate, endDate, supplier.SupplierRates); var supplierRate = new SupplierRateDTO { Rate = rate, StartDate = startDate, EndDate = endDate }; return(_supplierDao.SaveSupplierRate(supplier.SupplierId, supplierRate)); }