示例#1
0
        // Populate InfoList
        public async void InitializeInfo()
        {
            if (!Directory.Exists("Db/decks/"))
            {
                return;
            }
            InfoList = new Dictionary <string, Data.DeckInfo>();
            string[] filePaths = Directory.GetFiles("Db/decks/", "*.*");

            foreach (string path in filePaths)
            {
                string fromFile = await File.ReadAllTextAsync(path);

                Data.DeckFull fromText = JsonConvert.DeserializeObject <Data.DeckFull>(fromFile);
                InfoList.Add(fromText.Name, CreateDeckInfo(fromText));
            }
        }
示例#2
0
 // Select modify deck
 public Task <Data.ReturnInfo> SelectModifyDeckAsync(ServiceData origin)
 {
     Data.ReturnInfo returnInfo;
     Data.DeckFull   deckFull = DeckCache.Current.LoadDeck(origin.Create.Name);
     if (deckFull.Author != origin.User.Name)
     {
         returnInfo = CreateReturn(false, "Modify", "Could not validate user", "danger");
     }
     else if (origin.Create.Name == "")
     {
         returnInfo = CreateReturn(false, "Modify", "Deck could not be found", "danger");
     }
     else if (!Access.Current.ValidateOrigin(origin))
     {
         origin = new ServiceData(); returnInfo = CreateReturn(false, "Modify", "Could not validate user", "danger");
     }
     else
     {
         origin.Create = deckFull; origin.Create.Old = deckFull.Name; returnInfo = CreateReturn(true, "Modify", "Success", "success");
     }
     return(Task.FromResult(returnInfo));
 }
示例#3
0
 public void Reset()
 {
     User = new Data.User(); Review = new Data.PartialDeck(); Create = new Data.DeckFull();
 }
示例#4
0
 public void ResetCreate()
 {
     Create = new Data.DeckFull();
 }