예제 #1
0
        public RoomViewModel([NotNull] ProjectAccommodation entity, RoomTypeViewModel owner)
        {
            if (entity.ProjectId == 0 || entity.Id == 0)
            {
                throw new ArgumentException("Entity must be valid object");
            }

            Id         = entity.Id;
            Name       = entity.Name;
            ProjectId  = entity.ProjectId;
            RoomTypeId = entity.AccommodationTypeId;
            Capacity   = entity.ProjectAccommodationType?.Capacity ?? 0;

            // Extracting list of requests associated with this room
            Requests = owner.Requests.Where(r =>
            {
                var result = r.RoomId == Id;
                if (result)
                {
                    Occupancy += r.Persons;
                    r.Room     = this;
                }
                return(result);
            }).ToList();

            CanManageRooms = owner.CanManageRooms;
            CanAssignRooms = owner.CanAssignRooms;
        }
 public RoomTypeRoomsListViewModel(RoomTypeViewModel roomType)
 {
     ProjectId      = roomType.ProjectId;
     RoomTypeId     = roomType.Id;
     Rooms          = roomType.Rooms;
     RoomsCount     = roomType.RoomsCount;
     RoomCapacity   = roomType.Capacity;
     CanManageRooms = roomType.CanManageRooms;
     CanAssignRooms = roomType.CanAssignRooms;
 }