private Activity GetFileActivity(FileEntry fileEntry, DateTimeRange range)
        {
            object wrapper;

            if (fileEntry is File)
                wrapper = new FileWrapper((File) fileEntry);
            else
                wrapper = new FolderWrapper((Folder) fileEntry);

            var activity = new Activity(Documents, wrapper)
            {
                Action = (range.In(fileEntry.CreateOn) ? ActivityAction.Created : ActivityAction.Undefined) | (range.In(fileEntry.ModifiedOn) ? ActivityAction.Updated : ActivityAction.Undefined) | (range.In(fileEntry.SharedToMeOn) ? ActivityAction.Shared : ActivityAction.Undefined),
                ItemType = "file",
            };

            if (range.In(fileEntry.CreateOn))
            {
                activity.CreatedBy = fileEntry.CreateBy;
                activity.When = fileEntry.CreateOn;
            }
            else if (range.In(fileEntry.ModifiedOn))
            {
                activity.CreatedBy = fileEntry.ModifiedBy;
                activity.When = fileEntry.ModifiedOn;
            }
            else if (range.In(fileEntry.SharedToMeOn))
            {
                activity.CreatedBy = new Guid(fileEntry.SharedToMeBy);
                activity.When = fileEntry.SharedToMeOn;
            }

            return activity;
        }
Example #2
0
        public void EqualityTest()
        {
            // ReSharper disable SuspiciousTypeConversion.Global
            var time0 = new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc);
            var time1 = new DateTime(2015, 12, 31, 0, 0, 0, DateTimeKind.Utc);
            var range0 = new DateTimeRange(time0, time1);
            var range1 = new DateTimeRange(time0, time1);
            var range2 = new DateTimeRange(new DateTime(1999, 12, 31, 0, 0, 0, DateTimeKind.Utc), time1);
            var range3 = new DateTimeRange(time0, new DateTime(2016, 1, 1, 0, 0, 0, DateTimeKind.Utc));

            // Equals(DateTimeRange)
            Assert.IsTrue(range0.Equals(range0));
            Assert.IsTrue(range0.Equals(range1));
            Assert.IsFalse(range0.Equals(range2));
            Assert.IsFalse(range0.Equals(range3));

            // Equals(object)
            Assert.IsTrue(range0.Equals((object)range0));
            Assert.IsTrue(range0.Equals((object)range1));
            Assert.IsFalse(range0.Equals((object)range2));
            Assert.IsFalse(range0.Equals((object)range3));
            Assert.IsFalse(range0.Equals(null));
            Assert.IsFalse(range0.Equals(range0.ToString()));

            // == operator
            Assert.IsTrue(range0 == range1);
            Assert.IsFalse(range0 == range2);
            Assert.IsFalse(range0 == range3);

            // != operator
            Assert.IsFalse(range0 != range1);
            Assert.IsTrue(range0 != range2);
            Assert.IsTrue(range0 != range3);
            // ReSharper restore SuspiciousTypeConversion.Global
        }
Example #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Visit"/> class.
        /// </summary>
        /// <param name="staff">The staff.</param>
        /// <param name="appointmentDateTimeRange">The appointment date time range.</param>
        /// <param name="clinicalCase">The clinical case.</param>
        /// <param name="visitStatus">The visit status.</param>
        /// <param name="placeOfService">The place of service.</param>
        /// <param name="name">The name.</param>
        /// <param name="cptCode">The CPT code.</param>
        protected internal Visit(Staff staff, 
            DateTimeRange appointmentDateTimeRange,
            ClinicalCase clinicalCase,
            VisitStatus visitStatus,
            Location placeOfService,
            string name,
            string cptCode )
            : base(staff, appointmentDateTimeRange)
        {
            Check.IsNotNull ( clinicalCase, "Clinical case is required." );
            Check.IsNotNull ( visitStatus, "Visit status is required." );
            Check.IsNotNull ( placeOfService, "Location is required." );
            Check.IsNotNull ( name, "Name is required." );
            Check.IsNotNull ( cptCode, "CptCode is required." );

            if ( visitStatus.WellKnownName != WellKnownNames.VisitModule.VisitStatus.Scheduled )
            {
                throw new ArgumentException ( "Visits must always be created as scheduled visits." );
            }

            _clinicalCase = clinicalCase;
            _visitStatus = visitStatus;
            _serviceLocation = placeOfService;
            _name = name;
            _cptCode = cptCode;
            _activities = new List<Activity> ();
            _problems = new List<VisitProblem> ();
        }
Example #4
0
			public FileTime()
			{
				var MinDateTime = new DateTime(1970, 1, 1, 0, 0, 0);
				_CreationTime = MinDateTime;
				_LastAccessTime = MinDateTime;
				_LastWriteTime = MinDateTime;
			}
        public void DateTimeRangeShouldReturnCorrectDuration()
        {
            var thirtyMinutes = new TimeSpan(0, 0, 30, 0);

            var range = new DateTimeRange(DateTime.Now, thirtyMinutes);
            Assert.AreEqual(thirtyMinutes.Minutes, range.DurationInMinutes());
        }
 public ContractorContractRenewed(Guid id, DateTime eventTime, string einNumber, DateTimeRange oldDuration, DateTimeRange newDuration )
     : base(id, eventTime)
 {
     EinNumber = einNumber;
     OldDuration = oldDuration;
     NewDuration = newDuration;
 }
Example #7
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;
        }
 /// <summary>
 /// Deeps the copy.
 /// </summary>
 /// <param name="x">The x.</param>
 /// <returns></returns>
 public Object DeepCopy(Object x)
 {
     if (x == null) return null;
     DateTimeRange dr = (DateTimeRange)x;
     DateTimeRange result = new DateTimeRange(dr.Start, dr.End);
     return result;
 }
 /// <summary>
 /// Note that the end date will actually be the start second of the next date
 /// so there is always an at least 24 hours TimeSpan for a DateTimeRange.
 /// </summary>
 /// <param name="end">the last day that should be included in the range</param>
 /// <param name="start">the first day that should be inlcuded in the range</param>
 /// <remarks>
 /// the timespan of the last 1/100 second of the end date is not included in the range.
 /// It is 1/100 particularly because of the accuracy of datetime data stored in database
 /// </remarks>
 public SpecificDateRangeWrapper(DateTime? start, DateTime? end)
 {
     if(start != null )
         start = start.Value.Date;
     if(end != null)
         end = end.Value.AddDays(1).Date.AddSeconds(-0.01);
     range = new DateTimeRange(start, end);
 }
 public void CanCreateDateTimeRange()
 {
     var date1 = new DateTime(2016,02,01);
     var date2 = new DateTime(2016, 02, 15);
     var dateTimeRange = new DateTimeRange(date1, date2);
     dateTimeRange.From.Should().Be.EqualTo(date1);
     dateTimeRange.To.Should().Be.EqualTo(date2);
 }
Example #11
0
        public void ConstructorTest()
        {
            var time0 = new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc);
            var time1 = new DateTime(2015, 12, 31, 0, 0, 0, DateTimeKind.Utc);
            var range = new DateTimeRange(time0, time1);

            Assert.AreEqual(time0, range.Min);
            Assert.AreEqual(time1, range.Max);
        }
Example #12
0
			protected static DateTimeRange Normalize(DateTimeRange value)
			{
				var MinDateTime = new DateTime(1970, 1, 1, 0, 0, 0);
				if (value < MinDateTime)
				{
					return MinDateTime;
				}
				return value;
			}
        /// <summary>
        /// Return recent blog activities
        /// </summary>
        /// <param name="range"></param>
        /// <param name="relativeTo"></param>
        /// <param name="actions"></param>
        /// <returns></returns>
        public IEnumerable<Activity> GetActivities(DateTimeRange range, object relativeTo, ActivityAction? actions)
        {
            var activities = new List<Activity>();
            //Get blog posts in range
            activities.AddRange(_engine.GetPosts(range.From, range.To).Select(x => new Activity(BlogsSource, new BlogPostWrapperSummary(x), x.Author.ID, x.Updated, (range.In(x.Updated) ? ActivityAction.Updated : ActivityAction.Undefined) | (range.In(x.Datetime) ? ActivityAction.Created : ActivityAction.Undefined)) { ItemType = "post" }));
            //Get post comments in range
            activities.AddRange(_engine.GetComments(range.From, range.To, SecurityContext.CurrentAccount.ID).Select(x => new Activity(BlogsSource, new BlogPostCommentWrapper(x), x.UserID, x.Datetime, ActivityAction.Commented | (x.Inactive ? ActivityAction.Undefined : ActivityAction.Deleted) | (x.ParentId==Guid.Empty ? ActivityAction.Undefined : ActivityAction.Reply)) { ItemType = "comment", IsNew = !x.IsReaded, RelativeTo = x.PostId}));

            return activities;
        }
        /// <summary>
        /// </summary>
        /// <param name="range"></param>
        /// <param name="relativeTo"></param>
        /// <param name="actions"></param>
        /// <returns></returns>
        public IEnumerable<Activity> GetActivities(DateTimeRange range, object relativeTo, ActivityAction? actions)
        {
            var files = FileStorage.GetFileUpdates(range.From, range.To);
            var folders = FileStorage.GetFolderUpdates(range.From, range.To);

            var activities = new List<Activity>(files.Select(x => GetFileActivity(x, range)));
            activities.AddRange(folders.Select(x => GetFileActivity(x, range)));

            return activities;
        }
        public void CanAddAndSubtract() {
            var range1 = new DateTimeRange(_now, _now.AddMinutes(1));
            var utcRange =  range1.Add(TimeSpan.FromHours(6));
            Assert.Equal(_now.AddHours(6), utcRange.Start);
            Assert.Equal(_now.AddHours(6).AddMinutes(1), utcRange.End);

            var localRange = utcRange.Subtract(TimeSpan.FromHours(6));
            Assert.Equal(_now, localRange.Start);
            Assert.Equal(_now.AddMinutes(1), localRange.End);
        }
Example #16
0
        /// <summary>
        /// Constructor for creating a new patient note.
        /// </summary>
        /// <param name="author"></param>
        /// <param name="category"></param>
        /// <param name="comment"></param>
        public PatientNote(Staff author, PatientNoteCategory category, string comment)
        {
            _author = author;
            _category = category;
            _comment = comment;

            // valid from now indefinitely
            _creationTime = Platform.Time;
            _validRange = new DateTimeRange(_creationTime, null);
        }
Example #17
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Activity"/> class.
        /// </summary>
        /// <param name="visit">The visit.</param>
        /// <param name="activityType">Type of the activity.</param>
        protected internal Activity( Visit visit, ActivityType activityType )
        {
            Check.IsNotNull ( visit, "Visit is required." );
            Check.IsNotNull ( activityType, "Activity Type is required." );

            _visit = visit;
            _clinicalCase = visit.ClinicalCase;
            _activityType = activityType;
            _activityDateTimeRange = visit.AppointmentDateTimeRange;
        }
Example #18
0
        public void DateTimeRangeTest_Ctor()
        {
            DateTimeRange range = new DateTimeRange();
            Assert.Equal(range.StartTime, DateTime.MinValue);
            Assert.Equal(range.EndTime, DateTime.MaxValue);

            DateTime now = new DateTime(2015, 8, 7, 11, 15, 22);
            range = new DateTimeRange(now.Date.AddDays(-1), now.Date.AddDays(2));
            Assert.Equal(range.StartTime.Day, 6);
            Assert.Equal(range.EndTime.Day, 9);
        }
 public IEnumerable<Activity> GetActivities(DateTimeRange range, object relativeTo, ActivityAction? actions)
 {
     return
         CoreContext.UserManager.GetUsers().Where(x => x.WorkFromDate.HasValue && range.In(x.WorkFromDate.Value)).
             Select(x => new Activity(NewEmployes, null, x.WorkFromDate)
             {
                 RelativeTo = x.ID,
                 Action = ActivityAction.Created
             }
         );
 }
 public IEnumerable<Activity> GetActivities(DateTimeRange range, object relativeTo, ActivityAction? actions)
 {
     //Return birthdays
     return
         CoreContext.UserManager.GetUsers().Where(x => x.BirthDate.HasValue && range.In(x.BirthDate.Value)).
             Select(x => new Activity(Birthday, null, x.BirthDate)
                             {
                                 RelativeTo = x.ID, 
                                 Action = ActivityAction.Periodic
                             }
         );
 }
Example #21
0
        public void GetHashCodeTest()
        {
            var time0 = new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc);
            var time1 = new DateTime(2015, 12, 31, 0, 0, 0, DateTimeKind.Utc);
            var range0 = new DateTimeRange(time0, time1);
            var range1 = new DateTimeRange(time0, time1);
            var range2 = new DateTimeRange(time0, new DateTime(2016, 1, 1, 0, 0, 0, DateTimeKind.Utc));

            Assert.AreNotEqual(0.0, range0.GetHashCode());
            Assert.AreEqual(range0.GetHashCode(), range1.GetHashCode());
            Assert.AreNotEqual(range0.GetHashCode(), range2.GetHashCode());
        }
        public void SetUp()
        {
            DomainEvents.ClearCallbacks();

            testDateTimeRange = new DateTimeRange(new DateTime(2014, 6, 9), new DateTime(2014, 6, 16));

            testAppointment1 = Appointment.Create(testScheduleId,
                testClientId, testPatientId, testRoomId, testStartTime, testEndTime,
                testAppointmentTypeId, testDoctorId, "testAppointment1");

            testAppointment2 = Appointment.Create(testScheduleId,
                testClientId, testPatientId, testRoomId, testStartTime, testEndTime,
                testAppointmentTypeId, testDoctorId, "testAppointment2");
        }
        public IEnumerable<Activity> GetActivities(DateTimeRange range, object relativeTo, ActivityAction? actions)
        {
            var milestones = EngineFactory.GetMilestoneEngine().GetUpdates(range.From, range.To);
            var projects = EngineFactory.GetProjectEngine().GetUpdates(range.From, range.To);
            var tasks = EngineFactory.GetTaskEngine().GetUpdates(range.From, range.To);
            var comments = EngineFactory.GetCommentEngine().GetUpdates(range.From, range.To);
            var messages = EngineFactory.GetMessageEngine().GetUpdates(range.From, range.To);
            var participants = EngineFactory.GetProjectEngine().GetTeamUpdates(range.From, range.To);
            var timeTracking = EngineFactory.GetTimeTrackingEngine().GetUpdates(range.From, range.To);
            var subtasks = EngineFactory.GetTaskEngine().GetSubtaskUpdates(range.From, range.To);

            var activities = new List<Activity>(milestones
                .Select(x => new Activity(Projects, new MilestoneWrapper(x), (range.In(x.CreateOn) ? x.CreateBy : x.LastModifiedBy), (range.In(x.CreateOn) ? x.CreateOn : x.LastModifiedOn),
                    (range.In(x.CreateOn) ? ActivityAction.Created : ActivityAction.Undefined) | (range.In(x.LastModifiedOn) ? ActivityAction.Updated : ActivityAction.Undefined) | (range.In(x.StatusChangedOn) && x.Status == MilestoneStatus.Closed ? ActivityAction.Closed : ActivityAction.Opened))
                    { ItemType = "milestone"}));
            activities.AddRange(projects
                .Select(x => new Activity(Projects, new ProjectWrapper(x), (range.In(x.CreateOn) ? x.CreateBy : x.LastModifiedBy), (range.In(x.CreateOn) ? x.CreateOn : x.LastModifiedOn),
                    (range.In(x.CreateOn) ? ActivityAction.Created : ActivityAction.Undefined) | (range.In(x.LastModifiedOn) ? ActivityAction.Updated : ActivityAction.Undefined) | (range.In(x.StatusChangedOn) && x.Status == ProjectStatus.Closed ? ActivityAction.Closed : ActivityAction.Opened)) 
                    { ItemType = "project" }));
            activities.AddRange(tasks
                .Select(x => new Activity(Projects, new TaskWrapper(x), (range.In(x.CreateOn) ? x.CreateBy : x.LastModifiedBy), (range.In(x.CreateOn) ? x.CreateOn : x.LastModifiedOn),
                    (range.In(x.CreateOn) ? ActivityAction.Created : ActivityAction.Undefined) | (range.In(x.LastModifiedOn) ? ActivityAction.Updated : ActivityAction.Undefined) | (range.In(x.StatusChangedOn) && x.Status == TaskStatus.Closed ? ActivityAction.Closed : ActivityAction.Opened))
                    { ItemType = "task"}));
            activities.AddRange(messages
                .Select(x=>new Activity(Projects, new MessageWrapper(x), range.In(x.CreateOn) ? x.CreateBy : x.LastModifiedBy, range.In(x.CreateOn) ? x.CreateOn : x.LastModifiedOn,
                    (range.In(x.CreateOn) ? ActivityAction.Created : ActivityAction.Undefined) | (range.In(x.LastModifiedOn) ? ActivityAction.Updated : ActivityAction.Undefined))
                    { ItemType = "message"}));
            activities.AddRange(comments
                .Select(x=>new Activity(Projects,new { Comment = new CommentWrapper(x.Comment), CommentedType = x.CommentedType, CommentedTitle = x.CommentedTitle, CommentedId = x.CommentedId }, x.Comment.CreateBy, x.Comment.CreateOn,
                    (range.In(x.Comment.CreateOn) ? ActivityAction.Created : ActivityAction.Undefined) | (x.Comment.Inactive ? ActivityAction.Deleted : ActivityAction.Undefined) | (x.Comment.Parent == Guid.Empty ? ActivityAction.Commented : ActivityAction.Reply))
                    { ItemType = "comment"}));
            activities.AddRange(participants
                .Select(x => new Activity(Projects, new ParticipantFullWrapper(x), x.ID, range.In(x.Created) ? x.Created : x.Updated,
                    (range.In(x.Created) ? ActivityAction.Created : ActivityAction.Undefined) | (range.In(x.Updated) ? ActivityAction.Updated : ActivityAction.Undefined) | (x.Removed ? ActivityAction.Deleted : ActivityAction.Undefined)) 
                    { ItemType = "participant" }));
            activities.AddRange(timeTracking
                .Select(x => new Activity(Projects, new TimeWrapper(x), x.Person, x.Date, ActivityAction.Updated)
                    {ItemType = "time"}));
            foreach (var task in subtasks)
            {
                var group = task.SubTasks;
                task.SubTasks = null;
                activities.AddRange(group
                    .Select(x => new Activity(Projects, new {Task = new TaskWrapper(task), Subtask = new SubtaskWrapper(x, task)}, range.In(x.CreateOn) ? x.CreateBy : x.LastModifiedBy, range.In(x.CreateOn) ? x.CreateOn : x.LastModifiedOn,
                        (range.In(x.CreateOn) ? ActivityAction.Created : ActivityAction.Undefined) | (range.In(x.LastModifiedOn) ? ActivityAction.Updated : ActivityAction.Undefined) | (range.In(x.StatusChangedOn) && x.Status == TaskStatus.Open ? ActivityAction.Opened : ActivityAction.Closed))
                        {ItemType = "subtask"}));
            }

            return activities;
        }
Example #24
0
        static void Main()
        {
            var dates = new DateTimeRange(SampleData.Start, SampleData.End);

            var query = from date in dates
                        join defect in SampleData.AllDefects
                             on date equals defect.Created.Date
                             into joined
                        select new { Date=date, Count=joined.Count() };

            foreach (var grouped in query)
            {
                Console.WriteLine("{0:d}: {1}", grouped.Date, grouped.Count);
            }
        }
        public IEnumerable<Activity> GetActivities(DateTimeRange range, object relativeTo, ActivityAction? actions)
        {
            var events = FeedStorage.GetFeedByDate(range.From, range.To, SecurityContext.CurrentAccount.ID);
            var comments = FeedStorage.GetCommentsByDate(range.From, range.To);
            
            var activities = new List<Activity>((events
                .Select(x => new Activity(Events, new EventWrapper(x), new Guid(x.Creator), x.Date,
                    (range.In(x.Date) ? ActivityAction.Created : ActivityAction.Undefined))
                {ItemType = "event"})));
            activities.AddRange(comments
                .Select(x => new Activity(Events, new EventCommentWrapper(x), new Guid(x.Creator), x.Date,
                    (range.In(x.Date) ? ActivityAction.Created : ActivityAction.Undefined) | (x.ParentId == 0 ? ActivityAction.Commented : ActivityAction.Reply) | (x.Inactive ? ActivityAction.Deleted : ActivityAction.Undefined))
                {ItemType = "comment"}));

            return activities;
        }
Example #26
0
        internal Contractor(ContractorState contDbState/*, IBus bus*/)
            : base(contDbState.Id/*, bus*/)
        {
            DbState = contDbState;

            Contact = new Contact(new Name(contDbState.ContactFirstName, contDbState.ContactLastName), contDbState.ContactPhoneNumber, contDbState.ContactAlternatePhoneNumber, contDbState.ContactEmail);
            Address = new VO.Address(contDbState.AddressLine1, contDbState.AddressLine2, contDbState.City, contDbState.StateCode, contDbState.ZipCode);
            EinNumber = contDbState.EinNumber;
            ContractorName = contDbState.ContractorName;
            DoingBusinessAs =  contDbState.DoingBusinessAs; ContractorType =  contDbState.Type;
            ContractDuration = new DateTimeRange(contDbState.ContractStartDate, contDbState.ContractEndDate);
            PhoneNumber =   contDbState.PhoneNumber;
            Email = contDbState.Email;
            ContractorAlternatePhoneNumber = contDbState.AlternatePhoneNumber;
            Status = contDbState.Status;
            ContractorSuffixCode = contDbState.EinNumber.Substring(9, 2);
        }
Example #27
0
 public Contractor(Guid id, string einNumber, string contractorName, string doingBusinessAs, ContractorStatus status, ContractorType type, DateTimeRange contractDuration,
     PhoneNumber primaryPhoneNumber, Contact contactDetails,VO.Address address, string email)
     : base(id)
 {
     //TODO: Implement guard conditions
     Id = id;
     EinNumber = einNumber;
     ContractorName = contractorName;
     DoingBusinessAs = doingBusinessAs;
     Status = status;
     ContractorType = type;
     ContractDuration = contractDuration;
     PhoneNumber = primaryPhoneNumber;
     Contact = contactDetails;
     Address = address;
     Email = email;
     InitializeState();
 }
        public void GetRandomDate_GivenDateOnlyIsTrue_ShouldReturnDateTimeWithNoTimeComponent(int minYear, int minMonth, int minDay, int maxYear, int maxMonth, int maxDay)
        {
            //---------------Set up test pack-------------------
            var results = new List<DateTime>();
            var range = new DateTimeRange(minYear, minMonth, minDay, maxYear, maxMonth, maxDay);

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            RunCycles(() => results.Add(RandomValueGen.GetRandomDate(range.MinDate, range.MaxDate, dateOnly:true)));

            //---------------Test Result -----------------------
            Assert.AreEqual(RANDOM_TEST_CYCLES, results.Count);
            Assert.IsTrue(results.All(range.InRange), "One or more generated value is out of range");
            Assert.IsTrue(results.All(d => d.Hour == 0), "Hours are not all zeroed");
            Assert.IsTrue(results.All(d => d.Minute == 0), "Minutes are not all zeroed");
            Assert.IsTrue(results.All(d => d.Second == 0), "Seconds are not all zeroed");
            Assert.IsTrue(results.All(d => d.Millisecond == 0), "Seconds are not all zeroed");
        }
        public IEnumerable<Activity> GetActivities(DateTimeRange range, object relativeTo, ActivityAction? actions)
        {
            var comments = ImageStorage.GetComments(range.From, range.To);
            var albums = ImageStorage.GetPhotos(range.From, range.To)
                .GroupBy(x => x.UserID)
                .ToDictionary(x => x.Key, y => y.GroupBy(z => z.Album));

            var activities = new List<Activity>(comments
                .Select(x => new Activity(Images, new { Comment = new PhotoAlbumItemCommentWrapper(x.Comment), Image = new PhotoAlbumItemWrapper(x.Image) }, new Guid(x.Comment.UserID), x.Comment.Timestamp,
                    (range.In(x.Comment.Timestamp) ? ActivityAction.Created : ActivityAction.Undefined) | (x.Comment.ParentId == 0 ? ActivityAction.Commented : ActivityAction.Reply))
                {ItemType = "comment"}));
            foreach (var album in albums)
            {
                activities.AddRange(album.Value
                    .Select(x => new Activity(Images, new { Album = new PhotoAlbumWrapper(x.Key), Uploaded = x.Select(y => new PhotoAlbumItemWrapper(y)) }, new Guid(album.Key), null,
                        (range.In(x.Key.LastUpdate) ? ActivityAction.Created : ActivityAction.Undefined))
                    {ItemType = "album"}));
            }

            return activities;
        }
Example #30
0
 //TODO: See how we can avoid injecting EventBus into the Domain entities
 public Site(Guid id, int siteNumber, string siteName, SiteStatus status, SiteFacilityType siteFacitlityType, SiteType siteType,
     DateTimeRange contractDuration, PhoneNumber primaryPhoneNumber, Contact contactDetails, VO.Address address, string email,
     string countyCode, string countyServedCode, LicenceStatus licenceStatus, IEnumerable<SiteHoliday> holidays, IEnumerable<SiteRate> rates/*, IBus bus*/)
     : base(id/*, bus*/)
 {
     SiteNumber = siteNumber;
     SiteName = siteName;
     Status = status;
     SiteFacitlityType = siteFacitlityType;
     SiteType = siteType;
     ContractDuration = contractDuration;
     PrimaryPhoneNumber = primaryPhoneNumber;
     ContactDetails = contactDetails;
     Address = address;
     Email = email;
     CountyCode = countyCode;
     CountyServedCode = countyServedCode;
     LicencingStatus = licenceStatus;
     InitializeDbState();
     holidays.ForEach(AddNewHoliday);
     rates.ForEach(AddNewSiteRate);
 }