Exemplo n.º 1
0
 public IActionResult Create(PackageCreateViewModel vm)
 {
     if (ModelState.IsValid)
     {
         Package package = new Package
         {
             Type   = vm.Type,
             Amount = vm.Amount,
             Price  = vm.Price
         };
         _packageManager.CreatePackage(package);
         return(RedirectToAction(nameof(Index)));
     }
     return(View(vm));
 }
 /// <summary>
 /// Robert Forbes
 /// 2017/02/02
 ///
 /// When the add package button is clicked this method calls the createPackage method
 /// and checks to see if the package was created successfully
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnAddPackage_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (_packageManager.CreatePackage(_orderId, null) == true)
         {
             loadPackages();
         }
         else
         {
             MessageBox.Show("The package could not be added, please try again");
         }
     }
     catch (Exception)
     {
         MessageBox.Show("There was a problem adding the package to the database, please try again");
     }
 }
Exemplo n.º 3
0
        private void PublishPackage()
        {
            var gameData = _gameManager.GameData;

            var dialogParameters = new DialogParameters();

            dialogParameters.Add("Message", "Enter your packagename");

            _dialogService.ShowDialog(DialogNames.TEXT_INPUT_DIALOG, dialogParameters, async(dialogResult) =>
            {
                string userInput = dialogResult.Parameters.GetValue <string>("UserInput");

                if (string.IsNullOrEmpty(userInput))
                {
                    return;
                }

                gameData.PackageName = userInput;
                _packageManager.CreatePackage(gameData.PackageName, gameData.SavefilePath);

                var result = await _packageManager.UploadPackageAsync(gameData.PackageName, gameData.SavefilePath);

                var dialogParam = new DialogParameters();

                if (result.IsSuccess)
                {
                    dialogParam.Add("Message", "Succesfully uploaded!");
                    _dialogService.ShowDialog(DialogNames.MESSAGE_DIALOG, dialogParam, null);

                    return;
                }

                dialogParam.Add("Message", result.ErrorMessage);
                _dialogService.ShowDialog(DialogNames.MESSAGE_DIALOG, dialogParam, null);
            });
        }
 public Package CreateConditions([FromBody] Package newPackage)
 {
     return(_packageManager.CreatePackage(newPackage));
 }