Exemplo n.º 1
0
 public async Task<string> CreatePlayerList(JSONPlayerList model)
 {
     var user = await GetUserAsync();
     var result = await model.GeneratePlayerListAsync(db, user);
     if (result == null) return null;
     db.PlayerLists.Add(result);
     await db.SaveChangesAsync();
     return JsonConvert.SerializeObject(result.GetJSONPlayerList(), Formatting.None);
 }
Exemplo n.º 2
0
 public async Task<string> EditPlayerList(JSONPlayerList model)
 {
     var user = await GetUserAsync();
     var org = await db.PlayerLists.FindAsync(model.ID);
     if (org.ClubID != user.Club.ID) return null;
     org.SetPlayers(await model.GetPlayersAsync(db));
     org.Name = model.Name;
     await db.SaveChangesAsync();
     return JsonConvert.SerializeObject(org.GetJSONPlayerList(), Formatting.None);
 }
Exemplo n.º 3
0
 public async Task<string> DeletePlayerList(JSONPlayerList model)
 {
     var user = await GetUserAsync();
     var result = await db.PlayerLists.FindAsync(model.ID);
     if (result.ClubID != user.Club.ID) return null;
     result.Delete();
     await db.SaveChangesAsync();
     return JsonConvert.SerializeObject(result.GetJSONPlayerList(), Formatting.None);
 }