コード例 #1
0
        private async void GetSoftwares()
        {
            using (var client = new SoftwaresClient(GlobalProperties.BaseUrl))
            {
                var softwares = await client.GetSoftwares();

                foreach (var item in softwares)
                {
                    var tr = new TableRow();
                    tr.Cells.Add(new TableCell()
                    {
                        Text = item.Id.ToString()
                    });
                    tr.Cells.Add(new TableCell()
                    {
                        Text = item.ManufacturerName
                    });
                    tr.Cells.Add(new TableCell()
                    {
                        Text = item.Name
                    });
                    tr.Cells.Add(new TableCell()
                    {
                        Text = item.GenreName
                    });
                    tr.Cells.Add(CreateLinks(item));
                    tblSoftwares.Rows.Add(tr);
                }
            }
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        private async void btnDeleteSoftware_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult result = MessageBox.Show(
                "Do you really want to delete this software? \n All licenses of this software will deleted too.",
                "Are you sure?", MessageBoxButton.YesNo
                );

            if (result == MessageBoxResult.No)
            {
                return;
            }
            bool success = false;

            using (var client = new SoftwaresClient(Global.Properties.BaseUrl))
            {
                // TODO get software id from anywhere else
                success = await client.DeleteSoftware(((SoftwareDto)lst1.SelectedItem).Id);
            }

            if (!success)
            {
                return;
            }
            Thread.Sleep(1000);
            RefreshData();
        }
コード例 #4
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;
        }
コード例 #5
0
        private async Task LoadContent()
        {
            using (var client = new ManufacturersClient(Global.Properties.BaseUrl))
            {
                Global.Content.Manufacturers = await client.GetManufacturers();
            }

            using (var client = new SoftwaresClient(Global.Properties.BaseUrl))
            {
                Global.Content.Softwares = await client.GetSoftwares();
            }
        }
コード例 #6
0
 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();
 }