Example #1
0
        public void AddRole(Role role)
        {
            ValidatorHelper.EnsureIsNotNull(role, ErrorMessages.UserHasANullRole);
            ValidatorHelper.EnsureIsNotNull(_roles, ErrorMessages.UserHasANullRoleList);

            this._roles.Add(role);
        }
Example #2
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;
        }
Example #3
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;
        }