Example #1
0
 internal bool UpdateRank(Rank rank)
 {
     return AddRank(rank);
 }
Example #2
0
        private void LoadRanks()
        {
            if (!File.Exists(_rankPath))
            {
                throw new ArgumentException("Missing Season and/or Rank file(s).");
            }

            using (StreamReader rankStream = new StreamReader(_rankPath))
            {
                string rankLine;
                while ((rankLine = rankStream.ReadLine()) != null)
                {
                    if (rankLine.StartsWith("#"))
                    {
                        continue;
                    }

                    string[] rankData = rankLine.Split('\t');
                    if (rankData.Length >= 4)
                    {
                        Rank thisRank = new Rank();
                        thisRank.ID = int.Parse(rankData[0]);
                        thisRank.Number = int.Parse(rankData[1]);
                        thisRank.Name = rankData[2];
                        thisRank.ImageLink = rankData[3].ToLower() == "null" ? "" : rankData[3];
                        if (rankData.Length >= 5 && rankData[4].ToLower() != "null")
                        {
                            thisRank.ExpirationDate = DateTime.Parse(rankData[4]);
                        }
                        else
                        {
                            thisRank.ExpirationDate = DateTime.MaxValue;
                        }
                        if (!AllRanks.Any(r => r.ID == thisRank.ID))
                        {
                            AllRanks.Add(thisRank);
                        }
                    }
                }
            }
        }
Example #3
0
        internal bool RemoveRank(Rank rank)
        {
            if (AllRanks.Any(r => r.ID == rank.ID))
            {
                AllRanks.Remove(AllRanks.First(r => r.ID == rank.ID));
                return RemoveRank(rank);
            }

            return true;
        }
Example #4
0
        internal bool AddRank(Rank rank)
        {
            if (!RemoveRank(rank))
            {
                return false;
            }

            using (StreamWriter rankFile = new StreamWriter(_rankPath,false))
            {
                rankFile.WriteLine("#Ranks");
                rankFile.WriteLine("#ID\tNumber\tName\tImageLink\tExpirationDate");

                foreach (Rank thisRank in AllRanks.OrderBy(r => r.ID))
                {
                    rankFile.WriteLine(thisRank.ToString());
                }

                rankFile.Flush();
            }

            return true;
        }
Example #5
0
 public bool UpdateRank(Rank rank)
 {
     return _fileData.UpdateRank(rank);
 }
Example #6
0
 public bool DeleteRank(Rank rank)
 {
     return _fileData.RemoveRank(rank);
 }
Example #7
0
 public bool AddRank(Rank rank)
 {
     return _fileData.AddRank(rank);
 }