Пример #1
0
        public ActionResult Usage(Guid id, [Bind(Include = "StartDate")] DateTime?startDate, [Bind(Include = "EndDate")] DateTime?endDate)
        {
            var employer = _employersQuery.GetEmployer(id);

            if (employer == null)
            {
                return(NotFound("employer", "id", id));
            }

            if (startDate == null)
            {
                startDate = DateTime.Now.Date.AddDays(-1 * DefaultUsageDays);
            }
            if (endDate == null)
            {
                endDate = DateTime.Now.Date.AddDays(1);
            }

            // Get credits exercised by this employer.

            var exercisedCredits = _exercisedCreditsQuery.GetExercisedCreditsByExerciserId(id, new DateTimeRange(startDate.Value, endDate.Value));

            // Get all associated data.

            var allocations   = _allocationsQuery.GetAllocations(exercisedCredits);
            var organisations = _organisationsQuery.GetOrganisations((from a in allocations select a.OwnerId).Distinct());

            return(View(new EmployerExercisedCreditsModel
            {
                Employer = employer,
                StartDate = startDate.Value,
                EndDate = endDate.Value,
                ExercisedCredits = exercisedCredits,
                Credits = _creditsQuery.GetCredits().ToDictionary(c => c.Id, c => c),
                Allocations = allocations.ToDictionary(a => a.Id, a => a),
                JobAds = _jobAdsQuery.GetJobAds(exercisedCredits),
                Members = _membersQuery.GetMembers(exercisedCredits),
                Organisations = organisations.ToDictionary(o => o.Id, o => o),
            }));
        }
Пример #2
0
        public ActionResult Usage(Guid id, [Bind(Include = "StartDate")] DateTime?startDate, [Bind(Include = "EndDate")] DateTime?endDate)
        {
            var organisation = _organisationsQuery.GetOrganisation(id);

            if (organisation == null)
            {
                return(NotFound("organisation", "id", id));
            }

            if (startDate == null)
            {
                startDate = DateTime.Now.Date.AddDays(-1 * DefaultUsageDays);
            }
            if (endDate == null)
            {
                endDate = DateTime.Now.Date.AddDays(1);
            }

            // Get credits exercised by this employer.

            var exercisedCredits = _exercisedCreditsQuery.GetExercisedCreditsByOwnerId(id, new DateTimeRange(startDate.Value, endDate.Value));

            // Get all associated data.

            return(View(new OrganisationExercisedCreditsModel
            {
                Organisation = organisation,
                StartDate = startDate.Value,
                EndDate = endDate.Value,
                ExercisedCredits = exercisedCredits,
                Credits = _creditsQuery.GetCredits().ToDictionary(c => c.Id, c => c),
                Allocations = _allocationsQuery.GetAllocations(exercisedCredits).ToDictionary(a => a.Id, a => a),
                JobAds = _jobAdsQuery.GetJobAds(exercisedCredits),
                Members = _membersQuery.GetMembers(exercisedCredits),
                Employers = _employersQuery.GetEmployers(exercisedCredits),
            }));
        }
Пример #3
0
 public static IList <Allocation> GetAllocations(this IAllocationsQuery allocationsQuery, IEnumerable <ExercisedCredit> exercisedCredits)
 {
     return(allocationsQuery.GetAllocations((from c in exercisedCredits where c.AllocationId != null select c.AllocationId.Value).Distinct()));
 }