private async void btnSave_Click(object sender, RoutedEventArgs e)
        {
            SoftwareDetailDto software = new SoftwareDetailDto()
            {
                Name           = txtName.Text,
                ManufacturerId = ((ManufacturerDto)cmbManufacturer.SelectedItem).Id,
                GenreId        = (int)cmbGenre.SelectedItem,
                Description    = null
            };

            bool?success;

            using (var client = new SoftwaresClient(Global.Properties.BaseUrl))
            {
                success = await client.PostSoftware(software);
            }
            if (success == null)
            {
                throw new NotImplementedException();
            }
            if (!success.HasValue)
            {
                throw new NotImplementedException();
            }
            if (!success.Value)
            {
                throw new NotImplementedException();
            }
            this.Close();
        }
예제 #2
0
        private async void ShowSoftwareDetails(SoftwareDto sw)
        {
            if (!UserLoggedIn())
            {
                if (!Login())
                {
                    return;
                }
            }
            SoftwareDetailDto software = null;

            using (var client = new SoftwaresClient(Global.Properties.BaseUrl))
            {
                software = await client.GetSoftware(sw.Id);
            }
            if (software == null)
            {
                return;
            }

            SoftwareDetailGrid.Visibility = System.Windows.Visibility.Visible;
            lblTitle.Content                 = sw.ToString();
            txtManufacturer.Text             = software.ManufacturerName;
            txtName.Text                     = software.Name;
            txtGenre.Text                    = software.GenreName;
            txtDescription.Text              = software.Description;
            DataGrid1.ItemsSource            = software.Licenses;
            menuSoftwareNewLicense.IsEnabled = true;
            menuSoftwareDelete.IsEnabled     = true;
        }
예제 #3
0
        public async Task <SoftwareDetailDto> GetSoftware(int id)
        {
            if (!CheckAuthorization())
            {
                throw new NotLoggedInException();
            }
            HttpResponseMessage response = await _client.GetAsync("api/Softwares/" + id);

            SoftwareDetailDto software = await response.Content.ReadAsAsync <SoftwareDetailDto>();

            return(software);
        }
예제 #4
0
        public async Task <bool> PostSoftware(SoftwareDetailDto software)
        {
            HttpResponseMessage response = await _client.PostAsJsonAsync <SoftwareDetailDto>("api/Softwares", software);

            if (!response.IsSuccessStatusCode)
            {
                string responseMessage = await response.Content.ReadAsStringAsync();

                return(false);
            }
            return(true);
        }
 private async Task GetSoftwareDetails(int id)
 {
     if (Session["Token"] == null)
     {
         Session["IsLoggedIn"] = false;
         Response.Redirect("~/Default.aspx");
     }
     using (var client = new SoftwaresClient(GlobalProperties.BaseUrl,
                                             (TokenModel)Session["Token"]))
     {
         _software = await client.GetSoftware(id);
     }
     if (_software == null)
     {
         return;
     }
     lblSoftwareTitle.Text = _software.ToString();
 }