コード例 #1
0
        public static Funding CreateFunding(
            HedwigContext context,
            FundingSource source  = FundingSource.CDC,
            Enrollment enrollment = null,
            ReportingPeriod firstReportingPeriod = null,
            ReportingPeriod lastReportingPeriod  = null,
            FundingSpace fundingSpace            = null
            )
        {
            enrollment   = enrollment ?? EnrollmentHelper.CreateEnrollment(context);
            fundingSpace = fundingSpace ??
                           FundingSpaceHelper.CreateFundingSpace(context, enrollment.Site.OrganizationId);
            var funding = new Funding
            {
                EnrollmentId           = enrollment.Id,
                Source                 = source,
                FirstReportingPeriodId = firstReportingPeriod != null ? firstReportingPeriod.Id : null as int?,
                LastReportingPeriodId  = lastReportingPeriod != null ? lastReportingPeriod.Id : null as int?,
                FundingSpaceId         = fundingSpace != null ? fundingSpace.Id : null as int?
            };

            context.Fundings.Add(funding);
            context.SaveChanges();
            return(funding);
        }
コード例 #2
0
        public static Enrollment CreateEnrollment(
            HedwigContext context,
            string entry = "2000-01-01",
            string exit  = null,
            Age ageGroup = Age.InfantToddler,
            Child child  = null,
            Site site    = null
            )
        {
            child = child ?? ChildHelper.CreateChild(context);
            site  = site ?? SiteHelper.CreateSite(context);

            var enrollment = new Enrollment
            {
                ChildId  = child.Id,
                SiteId   = site.Id,
                Entry    = DateTime.Parse(entry),
                AgeGroup = ageGroup
            };

            if (exit != null)
            {
                enrollment.Exit = DateTime.Parse(exit);
            }

            context.Enrollments.Add(enrollment);
            context.SaveChanges();
            return(enrollment);
        }
コード例 #3
0
        public static Child CreateChild(
            HedwigContext context,
            string firstName          = "Test",
            string lastName           = "Child",
            string birthdate          = "2000-01-01",
            Gender gender             = Gender.Unknown,
            Family family             = null,
            Organization organization = null
            )
        {
            family       = family ?? FamilyHelper.CreateFamily(context);
            organization = organization ?? OrganizationHelper.CreateOrganization(context);

            var child = new Child
            {
                FirstName      = firstName,
                LastName       = lastName,
                Birthdate      = DateTime.Parse(birthdate),
                Gender         = gender,
                FamilyId       = family.Id,
                OrganizationId = organization.Id
            };

            context.Add <Child>(child);
            context.SaveChanges();
            return(child);
        }
コード例 #4
0
        public static Report CreateCdcReport(
            HedwigContext context,
            ReportingPeriod reportingPeriod = null,
            Organization organization       = null,
            string submittedAt = null
            )
        {
            reportingPeriod = reportingPeriod ?? ReportingPeriodHelper.CreateReportingPeriod(context, type: FundingSource.CDC);
            organization    = organization ?? OrganizationHelper.CreateOrganization(context);

            var report = new CdcReport
            {
                ReportingPeriodId = reportingPeriod.Id,
                OrganizationId    = organization.Id
            };

            if (submittedAt != null)
            {
                report.SubmittedAt = DateTime.Parse(submittedAt);
            }

            context.Reports.Add(report);
            context.SaveChanges();
            return(report);
        }
コード例 #5
0
		public static FundingSpace CreateFundingSpace(
			HedwigContext context,
			int organizationId,
			FundingSource source = FundingSource.CDC,
			Age ageGroup = Age.Preschool,
			FundingTime time = FundingTime.Full,
			int capacity = 10
		)
		{
			var timeSplit = time != FundingTime.Split
				? null
				: new FundingTimeSplit
				{
					FullTimeWeeks = 42,
					PartTimeWeeks = 10
				};

			var space = new FundingSpace
			{
				OrganizationId = organizationId,
				Source = source,
				AgeGroup = ageGroup,
				Capacity = capacity,
				Time = time,
				TimeSplit = timeSplit
			};

			context.Add(space);
			context.SaveChanges();
			return space;
		}
コード例 #6
0
        public static Organization CreateOrganization(
            HedwigContext context,
            string name = "Test Organization",
            ICollection <Site> sites = null
            )
        {
            var organization = new Organization {
                Name = name, Sites = sites
            };

            context.Organizations.Add(organization);
            context.SaveChanges();
            return(organization);
        }
コード例 #7
0
        public static Family CreateFamily(
            HedwigContext context,
            Organization organization = null
            )
        {
            organization = organization ?? OrganizationHelper.CreateOrganization(context);

            var family = new Family {
                OrganizationId = organization.Id
            };

            context.Add(family);
            context.SaveChanges();
            return(family);
        }
コード例 #8
0
        public static Site CreateSite(
            HedwigContext context,
            string name = "Test Site",
            Organization organization = null
            )
        {
            organization = organization ?? OrganizationHelper.CreateOrganization(context);
            var site = new Site
            {
                Name           = name,
                OrganizationId = organization.Id
            };

            context.Sites.Add(site);
            context.SaveChanges();
            return(site);
        }
コード例 #9
0
        public static OrganizationPermission CreateOrganizationPermission(
            HedwigContext context,
            User user        = null,
            Organization org = null
            )
        {
            user = user ?? UserHelper.CreateUser(context);
            org  = org ?? OrganizationHelper.CreateOrganization(context);

            var orgPermission = new OrganizationPermission
            {
                OrganizationId = org.Id,
                UserId         = user.Id
            };

            context.Permissions.Add(orgPermission);
            context.SaveChanges();
            return(orgPermission);
        }
コード例 #10
0
        public static SitePermission CreateSitePermission(
            HedwigContext context,
            User user = null,
            Site site = null
            )
        {
            user = user ?? UserHelper.CreateUser(context);
            site = site ?? SiteHelper.CreateSite(context);

            var sitePermission = new SitePermission
            {
                SiteId = site.Id,
                UserId = user.Id
            };

            context.Permissions.Add(sitePermission);
            context.SaveChanges();
            return(sitePermission);
        }
コード例 #11
0
ファイル: UserHelper.cs プロジェクト: ctoec/ecis-experimental
        public static User CreateUser(
            HedwigContext context,
            string firstName  = "Test",
            string lastName   = "User",
            Guid?wingedKeysId = null
            )
        {
            Guid _wingedKeysId = wingedKeysId ?? Guid.NewGuid();

            var user = new User
            {
                FirstName    = firstName,
                LastName     = lastName,
                WingedKeysId = _wingedKeysId
            };

            context.Users.Add(user);
            context.SaveChanges();
            return(user);
        }
コード例 #12
0
        public static ReportingPeriod CreateReportingPeriod(
            HedwigContext context,
            FundingSource type = FundingSource.CDC,
            string period      = "2019-10-01",
            string periodStart = "2019-10-01",
            string periodEnd   = "2019-10-01",
            string dueAt       = "2019-10-01"
            )
        {
            var reportingPeriod = new ReportingPeriod
            {
                Type        = type,
                Period      = DateTime.Parse(period),
                PeriodStart = DateTime.Parse(periodStart),
                PeriodEnd   = DateTime.Parse(periodEnd),
                DueAt       = DateTime.Parse(dueAt)
            };

            context.Add(reportingPeriod);
            context.SaveChanges();
            return(reportingPeriod);
        }
コード例 #13
0
        public static FamilyDetermination CreateDetermination(
            HedwigContext context,
            int numberOfPeople = 3,
            decimal income     = 20000M,
            string determined  = "2000-01-01",
            Family family      = null
            )
        {
            family = family ?? FamilyHelper.CreateFamily(context);

            var determination = new FamilyDetermination
            {
                NumberOfPeople    = numberOfPeople,
                Income            = income,
                DeterminationDate = DateTime.Parse(determined),
                FamilyId          = family.Id
            };

            context.FamilyDeterminations.Add(determination);
            context.SaveChanges();
            return(determination);
        }