Пример #1
0
        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();
        }
Пример #2
0
        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)));
        }
Пример #3
0
        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;
        }
Пример #4
0
 public RaidModel Create(RaidDOM model)
 {
     return(service.Save(model));
 }