Esempio n. 1
0
        private List <DeveloperPresentation> GetPresentationListStudio(List <Developer> developerList)
        {
            List <DeveloperPresentation> returnList = new List <DeveloperPresentation>();

            foreach (var developer in developerList)
            {
                DeveloperPresentation presentData = new DeveloperPresentation {
                    Id = developer.Id, Name = developer.Name, Role = developer.Role
                };
                returnList.Add(presentData);
            }
            return(returnList);
        }
Esempio n. 2
0
        public async System.Threading.Tasks.Task UppdateGame()
        {
            try
            {
                HttpClient client = new HttpClient();

                DeveloperPresentation selectedDeveloper = (DeveloperPresentation)cmbDeveloper.SelectedItem;
                Developer             gameDeveloper     = new Developer {
                    Id = selectedDeveloper.Id, Name = selectedDeveloper.Name, Role = selectedDeveloper.Role
                };

                Publisher selectedPublisher = (Publisher)cmbPublisher.SelectedItem;

                StudioPresentation selectedStudio = (StudioPresentation)cmbStudio.SelectedItem;
                Studio             gameStudio     = new Studio {
                    Id = selectedStudio.Id, Name = selectedStudio.Name
                };

                Game updatedGame = (Game)cmbGames.SelectedItem;
                updatedGame.Name            = txtName.Text;
                updatedGame.Gener           = txtGener.Text;
                updatedGame.NumberOfPlayers = int.Parse(txtNumPlayers.Text);
                updatedGame.Publisher.Id    = selectedPublisher.Id;
                updatedGame.Studio          = new List <Studio>();
                updatedGame.Studio.Add(gameStudio);
                updatedGame.Developer = new List <Developer>();
                updatedGame.Developer.Add(gameDeveloper);

                string jsonString = JsonConvert.SerializeObject(updatedGame);
                var    content    = new StringContent(jsonString, Encoding.UTF8, "application/json");
                string URL        = BASE_URL + "Games/" + updatedGame.Id;
                var    response   = await client.PutAsync(URL, content);

                var responseString = await response.Content.ReadAsStringAsync();

                System.Diagnostics.Debug.WriteLine(responseString);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
            }
        }