public ISubscriber Subscribe(string subscriberName, ITariff tariff) { if (_subscribersFee.Keys.Any(s => s.Name.Equals(subscriberName))) { return(null); } ITerminal terminal = new Terminal(_dtHelper); IContract contract = _contractFactory.CreateContract(tariff, _phoneExchange.CreatePort()); contract.ContractStateChanging += BillingContractStateChanging; ISubscriber subscriber = _subscriberFactory.CreateSubscriber(subscriberName, contract, terminal); _subscribersFee.Add(new KeyValuePair <ISubscriber, double>(subscriber, 0)); return(subscriber); }
public async Task <List <Contract> > GetAllContractsByDayAndHour(long employerId, DateTime dateTime) { var contracts = await _contractRepository.GetContractsByEmployerId(employerId); return(contracts .Where(c => c.Workschedule.Workshifts.Any(w => w.StartDateTime.Day == dateTime.Day)) .Select(c => { var filteredWorkshifts = c.Workschedule.Workshifts .Where(w => w.StartDateTime.Hour == dateTime.Hour || w.StartDateTime.Hour == dateTime.AddHours(-1).Hour || w.StartDateTime.Hour == dateTime.AddHours(1).Hour || w.TimerState == "StartedState" || w.TimerState == "PausedState") .ToList(); var workschedule = _workscheduleFactory.CreateWorkschedule(c.Workschedule.Id, filteredWorkshifts); return _contractFactory.CreateContract(c.Id, c.Person, c.Employer, workschedule); }) .Where(c => c.Workschedule.Workshifts.Any()) .ToList()); }