Exemplo n.º 1
0
        public Book(Room room, DateTime startTime, DateTime endDate)
        {
            ValidatorHelper.EnsureIsNotNull(room, "");
            ValidatorHelper.EnsureTimeIsGreaterOrEqualThan(startTime, room.StartTime, "");
            ValidatorHelper.EnsureTotalHourIsLessThan(startTime.Hour, endDate.Hour, 2, "");
            ValidatorHelper.EnsureDateIsGreaterOrEqualThan(startTime, DateTime.Now, "");
            ValidatorHelper.EnsureTimeIsLessOrEqualThan(endDate, room.EndTime, "");
            ValidatorHelper.EnsureDayOfWeekIsNotWeekend(startTime, "");

            this.Id        = Guid.NewGuid();
            this.Room      = room;
            this.Status    = EBookStatus.InProgress;
            this.StartTime = startTime;
            this.EndTime   = endDate;
        }
Exemplo n.º 2
0
        public Book(Room room, DateTime startTime, DateTime endDate, User user)
        {
            ValidatorHelper.EnsureIsNotNull(room, ErrorMessages.BookHasANullRoom);
            ValidatorHelper.EnsureIsNotNull(user, ErrorMessages.BookHasANullUser);
            ValidatorHelper.EnsureTimeIsGreaterOrEqualThan(startTime, room.StartTime, String.Format(ErrorMessages.BookStartTimeMustBeGreaterThanRoomStartTime, startTime, room.StartTime));
            ValidatorHelper.EnsureTotalHourIsLessThan(startTime.Hour, endDate.Hour, 2, String.Format(ErrorMessages.BookTimeTotalShouldBeLessThan, 2));
            ValidatorHelper.EnsureDateIsGreaterOrEqualThan(startTime, DateTime.Now, String.Format(ErrorMessages.BookStartTimeMustBeInFuture));
            ValidatorHelper.EnsureTimeIsLessOrEqualThan(endDate, room.EndTime, String.Format(ErrorMessages.BookEndTimeMustBeLessThanRoomEndTime, startTime, room.EndTime));
            ValidatorHelper.EnsureDayOfWeekIsNotWeekend(startTime, ErrorMessages.BookDateIsWeekend);

            this.Id        = Guid.NewGuid();
            this.Room      = room;
            this.Status    = EBookStatus.InProgress;
            this.StartTime = startTime;
            this.EndTime   = endDate;
            this.User      = user;
        }
Exemplo n.º 3
0
 public void EnsureDateIsGreaterOrEqualThan()
 {
     ValidatorHelper.EnsureDateIsGreaterOrEqualThan(DateTime.Now.AddHours(1), DateTime.Now, "Greater");
     ValidatorHelper.EnsureDateIsGreaterOrEqualThan(DateTime.Now, DateTime.Now, "Equals");
 }