// 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)); } }
// 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)); }
public void Reset() { User = new Data.User(); Review = new Data.PartialDeck(); Create = new Data.DeckFull(); }
public void ResetCreate() { Create = new Data.DeckFull(); }