private void HasWeeklySummary(int entityID) { WeeklySummaryCollection _wsa; using (WeeklySummaryAccessClient _weeklySummaryAccessClient = new WeeklySummaryAccessClient(EndpointName.WeeklySummaryAccess)) { var _period = PeriodService.Instance.GetCurrentPeriod()[0]; _wsa = new WeeklySummaryCollection(_weeklySummaryAccessClient.Query(_period.ID, entityID)); if (!_wsa.Any()) { using (EntityAccessClient _entityAccessClient = new EntityAccessClient(EndpointName.EntityAccess)) { var _entity = _entityAccessClient.Query2(entityID)[0]; if (_entity.SumType != SumType.Not) { WeeklySummary _newWeeklySummary = new WeeklySummary { Entity = _entity, ExchangeRate = _entity.ExchangeRate, Period = _period, BaseCurrency = _entity.Currency.CurrencyID, }; _weeklySummaryAccessClient.Insert1(_newWeeklySummary); } } } } }
//TODO: public WeeklySummaryCollection GetWeeklySummary(int entityID) { using (WeeklySummaryAccessClient _weeklySummaryAccessClient = new WeeklySummaryAccessClient(EndpointName.WeeklySummaryAccess)) { HasWeeklySummary(entityID); return new WeeklySummaryCollection(_weeklySummaryAccessClient.Query(PeriodService.Instance.GetCurrentPeriod()[0].ID, entityID)); } }