public void OnGet() { optimalPlacements = new List <OptimalPlacement>(); List <Commercial> commercials = commercialAdOptimiser.GetAllCommercialsList().ToList(); var BreakGroupsPlanned = commercialAdOptimiser.GetAllBreakLists(). OrderByDescending(c => c.Rating). OrderBy(c => c.BreakGroup). GroupBy(b => b.BreakGroup).ToList(); CommercialType comType = CommercialType.Default; foreach (var breakGroup in BreakGroupsPlanned) { foreach (var item in breakGroup) { var demoType = item.DemogrphicType; Commercial plaementFinder = null; if (breakGroup.Key.ToString() == "BreakGroup2") { plaementFinder = commercials .Where(x => x.Type != comType && x.Type != CommercialType.Finance) .FirstOrDefault(x => x.DemographicClass == demoType); comType = plaementFinder.Type; } else { plaementFinder = commercials .Where(x => x.Type != comType) .FirstOrDefault(x => x.DemographicClass == demoType); comType = plaementFinder.Type; } OptimalPlacement opt = new OptimalPlacement { CommercialName = plaementFinder.Name, CommercialType = plaementFinder.Type, DemographicType = plaementFinder.DemographicClass, BreakGroup = item.BreakGroup, Rating = item.Rating }; optimalPlacements.Add(opt); commercials.Remove(plaementFinder); } } sumQuery = optimalPlacements.GroupBy(x => x.BreakGroup) .Select(CS => new CommercialSum { BreakGroupName = CS.First().BreakGroup.ToString(), SumOfBreakGroupViews = CS.Sum(cs => cs.Rating) }).ToList(); }
// Add building Component to the gameObject public static Commercial CreateComponent(GameObject where, CommercialType parameter1, CommercialSize parameter2, CommercialVariation parameter3) { Commercial myC = where.AddComponent <Commercial>(); myC.commercial_type = parameter1; myC.commercial_size = parameter2; myC.commercial_variation = parameter3; return(myC); }
private string DefaultCommercialIMagePath(CommercialType type) { switch (type) { case CommercialType.OfficeSpace: return("https://media.baitkm.com/api/Image/Resize/AnnouncementBasePhoto/office.png/1500/1500/False/0"); case CommercialType.Shop: return("https://media.baitkm.com/api/Image/Resize/AnnouncementBasePhoto/shop.png/1500/1500/False/0"); case CommercialType.Showroom: return("https://media.baitkm.com/api/Image/Resize/AnnouncementBasePhoto/showroom.png/1500/1500/False/0"); case CommercialType.WereHouse: return("https://media.baitkm.com/api/Image/Resize/AnnouncementBasePhoto/werehouse.png/1500/1500/False/0"); default: return("https://media.baitkm.com/api/Image/Resize/AnnouncementBasePhoto/office.png/1500/1500/False/0"); } }