Пример #1
0
 internal bool UpdateRank(Rank rank)
 {
     return AddRank(rank);
 }
Пример #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);
                        }
                    }
                }
            }
        }
Пример #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;
        }
Пример #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;
        }
Пример #5
0
 public bool UpdateRank(Rank rank)
 {
     return _fileData.UpdateRank(rank);
 }
Пример #6
0
 public bool DeleteRank(Rank rank)
 {
     return _fileData.RemoveRank(rank);
 }
Пример #7
0
 public bool AddRank(Rank rank)
 {
     return _fileData.AddRank(rank);
 }