예제 #1
0
        internal Site(SiteState siteState/*, IBus bus*/)
            : base(siteState.Id/*, bus*/)
        {
            SiteName = siteState.SiteName;
            SiteNumber = siteState.SiteNumber;
            Id = siteState.Id;
            Address = new VO.Address(siteState.AddressLine1, siteState.AddressLine2, siteState.City, siteState.StateCode, siteState.ZipCode);
            ContactDetails = new Contact(new Name(siteState.ContactFirstName, siteState.ContactLastName), siteState.ContactPhoneNumber, siteState.ContactAlternatePhoneNumber, siteState.ContactEmail);
            ContractDuration = new DateTimeRange(siteState.ContractStartDate, siteState.ContractEndDate);
            CountyCode = siteState.CountyCode;
            CountyServedCode = siteState.CountyServedCode;
            Email = siteState.Email;
            LicencingStatus = siteState.LicencingStatusCode;
            PrimaryPhoneNumber = siteState.PhoneNumber;
            SiteFacitlityType = siteState.SiteFacilityTypeCode;
            SiteType = siteState.SiteTypeCode;
            Status = siteState.StatusCode;
            _holidays = siteState.SiteHoliday.Select(x => new SiteHoliday(x.HolidayDate, x.HolidayName)).ToList();
            _rates =
                siteState.SiteRate.Select(
                    x =>
                        new SiteRate(x.AgeCode, x.RegularCareDailyRate.GetValueOrDefault(),
                            x.RegularCareWeeklyRate.GetValueOrDefault(), x.EffectiveDate/*, bus*/)).ToList();

            DbState = siteState;
        }
예제 #2
0
        private void UpdateHolidays(Site site, SiteState dbSiteState)
        {
            var datesToBeRemoved = new List<SiteHolidayState>();
            foreach (var hol in dbSiteState.SiteHoliday)
            {
                if (dbSiteState.SiteHoliday.All(x => x.HolidayDate.Date != hol.HolidayDate.Date))
                    datesToBeRemoved.Add(hol);
            }
            foreach (var removedHol in datesToBeRemoved)
            {
                dbSiteState.SiteHoliday.Remove(removedHol);
                //TODO: Raise an Domain event about the change of holidays or should these be raised by SiteState Aggregate root?
            }

            foreach(var item in site.Holidays)
            {
                var existingHoliday = dbSiteState.SiteHoliday.FirstOrDefault(x => x.HolidayDate.Date == item.HolidayDate.Date);
                if (existingHoliday == null)
                {
                    dbSiteState.SiteHoliday.Add(new SiteHolidayState
                    {
                        Id = GuidHelper.NewSequentialGuid(),
                        CalendarYearDate = item.HolidayDate.Year.ToString(),
                        HolidayDate = item.HolidayDate,
                        HolidayName = item.Name,
                        FirstInsertedById = "TODO",
                        FirstInsertedDateTime = DateTime.UtcNow,
                        LastSavedById = "TODO",
                        LastSavedDateTime = DateTime.UtcNow
                    });
                }
                else
                {
                    existingHoliday.LastSavedDateTime = DateTime.UtcNow;
                    existingHoliday.HolidayName = item.Name;
                }

            }
        }
예제 #3
0
 private void InitializeDbState()
 {
     DbState = new SiteState
     {
         Id = Id,
         AddressLine1 = Address.AddressLine1,
         AddressLine2 = Address.AddressLine2,
         AlternatePhoneNumber = null,
         City = Address.City,
         ContactAlternatePhoneNumber = ContactDetails.AlternatePhoneNumber,
         ContactEmail = ContactDetails.Email,
         ContactFirstName = ContactDetails.Name.FirstName,
         ContactLastName = ContactDetails.Name.LastName,
         ContactPhoneNumber = ContactDetails.PhoneNumber,
         SiteFacilityTypeCode = SiteFacitlityType.Value.ToString(),
         LicencingStatusCode = LicencingStatus.Value,
         SiteName = SiteName,
         SiteNumber = SiteNumber,
         SiteTypeCode = SiteType.Value,
         StateCode = Address.StateCode,
         ZipCode = Address.ZipCode,
         CountyCode = CountyCode,
         CountyServedCode = CountyServedCode,
         Email = Email,
         PhoneNumber = PrimaryPhoneNumber,
         ContractStartDate = ContractDuration.Start,
         ContractEndDate = ContractDuration.End,
         FirstInsertedBy = "TODO",
         FirstInsertedDateTime = DateTime.UtcNow,
         LastSavedBy = "TODO",
         LastSavedDateTime = DateTime.UtcNow,
         StatusCode = Status.Value
     };
 }