public AccommodationListViewModel(Project project, IReadOnlyCollection <RoomTypeInfoRow> roomTypes, int userId) { ProjectId = project.ProjectId; ProjectName = project.ProjectName; CanManageRooms = project.HasMasterAccess(userId, acl => acl.CanManageAccommodation); CanAssignRooms = project.HasMasterAccess(userId, acl => acl.CanSetPlayersAccommodations); RoomTypes = roomTypes.Select(rt => new RoomTypeListItemViewModel(rt, userId)).ToList(); IsInfinite = RoomTypes.Any(rt => rt.IsInfinite); var allInfinite = RoomTypes.All(rt => rt.IsInfinite); TotalCapacity = allInfinite ? (int?)null : RoomTypes.Sum(rt => rt.TotalCapacity); FreeCapacity = allInfinite ? (int?)null : RoomTypes.Sum(rt => rt.FreeCapacity); TotalOccupied = RoomTypes.Sum(x => x.Occupied); TotalPending = RoomTypes.Sum(x => x.PendingRequests); }