private void btnCreateRaidClick(object sender, EventArgs e) { //CREATE & SAVE NEW RAID string pokemonName = txtPokename.Text.Trim(); int minLevel = Convert.ToInt32(txtMinLevel.Text.Trim()); int startsTime = Convert.ToInt32(txtStartTime.Text.Trim()); long creatorId = Convert.ToInt64(txtId.Text.Trim()); if (pokemonName == "") { MessageBox.Show("You must enter Pokemon Name", "Error"); } RaidDOM raid = new RaidDOM() { MinimalLevel = minLevel, PokemonName = pokemonName, StartsIn = startsTime, CreatorId = creatorId }; HttpClient client = new HttpClient(); client.BaseAddress = new Uri("https://localhost:44390/"); HttpResponseMessage response = client.PostAsJsonAsync("raid/", raid).Result; MessageBox.Show("Raid is created", "Create raid"); new Home().Show(); this.Hide(); }
public RaidModel Save(RaidDOM raidModel) { var pokemon = pokemonRepository.GetByName(raidModel.PokemonName); var creator = userRepository.Get(raidModel.CreatorId); var raid = new RaidDataModel { MinimalLevel = raidModel.MinimalLevel, Pokemon = pokemon, Creator = creator, StartsIn = raidModel.StartsIn }; creator.CreatedRaids.Add(raid); pokemon.Raids.Add(raid); return(new RaidModel(raidRepository.Save(raid))); }
private void btnRaidDetailsClick(object sender, EventArgs e) { //GET RAID BY ID HttpClient client = new HttpClient(); client.BaseAddress = new Uri("https://localhost:44390/"); HttpResponseMessage response = client.GetAsync("raid/all/" + txtId.Text).Result; RaidDOM raid = response.Content.ReadAsAsync <RaidDOM>().Result; List <RaidDOM> raidList = new List <RaidDOM>(); raidList.Add(raid); homeAllRaids.DataSource = raidList; }
public RaidModel Create(RaidDOM model) { return(service.Save(model)); }