public async Task <IActionResult> GetSubRegions([FromRoute] string region)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            List <string> stringList = new List <string>();

            stringList = await _context.Countries.Where(r => r.Region == region).Select(c => c.Subregion).Distinct().OrderBy(r => 1).ToListAsync();

            List <SubRegions> subregionList = new List <SubRegions>();

            foreach (string s in stringList)
            {
                SubRegions r = new SubRegions();
                r.SubRegionName = s;
                subregionList.Add(r);
            }

            if (subregionList == null)
            {
                return(NotFound());
            }

            return(Ok(subregionList));
        }
Ejemplo n.º 2
0
 public void AddSubRegion(Region subRegion)
 {
     if (!SubRegions.Contains(subRegion))
     {
         SubRegions.Add(subRegion);
     }
 }
Ejemplo n.º 3
0
        public override void GetReferences(Dictionary <ModelCode, List <long> > references, TypeOfReference refType)
        {
            if (SubRegions != null && SubRegions.Count > 0 &&
                (refType == TypeOfReference.Target || refType == TypeOfReference.Both))
            {
                references[ModelCode.REGION_SUBREGIONS] = SubRegions.GetRange(0, SubRegions.Count);
            }

            base.GetReferences(references, refType);
        }
Ejemplo n.º 4
0
        public override void AddReference(ModelCode referenceId, long globalId)
        {
            switch (referenceId)
            {
            case ModelCode.SUBREGION_REGION:
                SubRegions.Add(globalId);
                break;

            default:
                base.AddReference(referenceId, globalId);
                break;
            }
        }
Ejemplo n.º 5
0
        /**
         * @return A string with the name of the player that fully owns this SuperRegion
         */
        public string OwnedByPlayer()
        {
            String playerName = SubRegions.First().PlayerName;

            foreach (Region region in SubRegions)
            {
                if (playerName != region.PlayerName)
                {
                    return(null);
                }
            }
            return(playerName);
        }
        public IEnumerable <SubRegions> GetSubRegions()
        {
            List <string> stringList = new List <string>();

            stringList = _context.Countries.Select(c => c.Subregion).Distinct().OrderBy(r => 1).ToList();
            List <SubRegions> subregionList = new List <SubRegions>();

            foreach (string s in stringList)
            {
                SubRegions r = new SubRegions();
                r.SubRegionName = s;
                subregionList.Add(r);
            }
            return(subregionList);
        }
Ejemplo n.º 7
0
        public override void RemoveReference(ModelCode referenceId, long globalId)
        {
            switch (referenceId)
            {
            case ModelCode.SUBREGION_REGION:

                if (SubRegions.Contains(globalId))
                {
                    SubRegions.Remove(globalId);
                }
                else
                {
                    CommonTrace.WriteTrace(CommonTrace.TraceWarning, "Entity (GID = 0x{0:x16}) doesn't contain reference 0x{1:x16}.", this.GlobalId, globalId);
                }

                break;

            default:
                base.RemoveReference(referenceId, globalId);
                break;
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Dumps to XML.
 /// </summary>
 /// <param name="zone">The zone.</param>
 public void DumpToXml(int zone)
 {
     try
     {
         var path = ($@"{AppDomain.CurrentDomain.BaseDirectory}Sub Region Info");
         if (!Directory.Exists(path))
         {
             Directory.CreateDirectory(path);
         }
         if (!Directory.Exists(path))
         {
             return;
         }
         var outFile   = File.Create($@"{path}\\ZoneID_{zone}_SubRegions.xml");
         var formatter = new XmlSerializer(SubRegions.GetType());
         formatter.Serialize(outFile, SubRegions);
         outFile.Close();
     }
     catch (Exception ex)
     {
         Log.LogFile(ex.ToString(), nameof(ParseZoneModelDat));
         Log.AddDebugText(Main.RtbDebug, $@"{ex} > {nameof(ParseZoneModelDat)}");
     }
 }