public AuthorizationResolution(
     IResolutionServiceRepository resolutionServiceRepository,
     HoursResolutionLoggingService hoursResolutionService
     )
 {
     ResolutionServiceRepository = resolutionServiceRepository;
     LoggingService = hoursResolutionService;
 }
        public ValidationIssueCollection Resolve(EntryApp entryApp)
        {
            this.EntryApp = entryApp;

            NormalizeCoreData(entryApp);

            if (!new CoreValidations(this, _repository).Resolve())
            {
                return(Issues);
            }

            // ensure all entries have IDs
            foreach (var entry in ProposedEntries)
            {
                if (entry.ID == 0)
                {
                    _repository.SaveEntry(entry);
                }
            }

            // resolves any additional SSG entries and adds them to the ProposedHours queue
            // removes any orphaned SSGs as well
            // IMPORTANT: don't reposition this, it needs to come before Case/Provider Auths
            if (!new SSGResolution(this, _repository).Resolve())
            {
                return(Issues);
            }

            if (!new CaseAndProviderValidations(this).Resolve())
            {
                return(Issues);
            }

            if (!new AuthorizationResolution(_repository, HoursResolutionLoggingService.Create()).Resolve(ProposedEntries))
            {
                return(Issues);
            }

            if (!new ScheduleResolution(this).Resolve())
            {
                return(Issues);
            }

            return(Issues);
        }
        private int Resolve(IEnumerable <Domain2.Hours.Hours> hours)
        {
            int count      = 0;
            int loopCount  = 0;
            int totalCount = hours.Count();
            var resolver   = new AuthorizationResolution(new ResolutionServiceRepository(Context), HoursResolutionLoggingService.Create());

            foreach (var h in hours)
            {
                try
                {
                    resolver.Resolve(new List <Domain2.Hours.Hours> {
                        h
                    });
                    Context.SaveChanges();
                    onAuthResolved(totalCount, loopCount, h.ID);
                    count += h.AuthorizationBreakdowns != null ? h.AuthorizationBreakdowns.Count : 0;
                }
                catch (Exception e)
                {
                    onExceptionBypassed(h.ID, e);
                }
                loopCount++;
                System.Diagnostics.Debug.WriteLine("LOOP: " + loopCount + " of " + totalCount);
            }
            return(count);
        }