public MonthSheetRepository(IOptions <MonthSheetDetails> sheetDetails, ISheetApiService sheetApi)
            : base(sheetDetails.Value.SheetId, sheetApi)
        {
            _sheetDetails = sheetDetails.Value;
            _sheetApi     = sheetApi ?? throw new ArgumentNullException(nameof(sheetApi));

            var missingDetail = _sheetDetails.GetType().GetProperties()
                                .Where(p => p.PropertyType == typeof(string))
                                .Select(p => (name: p.Name, value: (string)p.GetValue(_sheetDetails)))
                                .FirstOrDefault(r => string.IsNullOrEmpty(r.value));

            if (!string.IsNullOrEmpty(missingDetail.name))
            {
                throw new ArgumentNullException($"Missing Month detail: {missingDetail.name}");
            }
        }
Пример #2
0
 public MonthSheetService(IOptions <MonthSheetDetails> sheetDetails, IMonthSheetRepository repo)
 {
     _sheetDetails = sheetDetails.Value;
     _repo         = repo;
 }