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;
        }
        private TableCell CreateLinks(SoftwareDto software)
        {
            var tc        = new TableCell();
            var btnDetail = new Button
            {
                Text        = "Details",
                CssClass    = "btn btn-info",
                ID          = "btnDetail_" + software.Id,
                PostBackUrl = "SoftwareDetails.aspx?id=" + software.Id
            };

            var btnEdit = new Button
            {
                ID          = "btnEdit_" + software.Id,
                Text        = "Edit",
                CssClass    = "btn btn-warning",
                PostBackUrl = "SoftwareEdit.aspx?id=" + software.Id
            };
            var btnDelete = new Button {
                Text = "Delete", CssClass = "btn btn-danger"
            };

            tc.Controls.Add(btnDetail);
            tc.Controls.Add(new Label()
            {
                Text = " "
            });
            tc.Controls.Add(btnEdit);
            tc.Controls.Add(new Label()
            {
                Text = " "
            });
            tc.Controls.Add(btnDelete);
            return(tc);
        }
        private void btnNewLicense_Click(object sender, RoutedEventArgs e)
        {
            SoftwareDto      sw     = (SoftwareDto)lst1.SelectedItem;
            NewLicenseDialog dialog = new NewLicenseDialog(sw.Id);

            dialog.ShowDialog();
            Thread.Sleep(2000);
            ShowSoftwareDetails(sw);
        }
        public void AddNewSoftwareThrowExceptionWhenDataIsInvalid()
        {
            //Arrange
            var customerRepository = new StubICustomerRepository();
            var productRepository  = new StubIProductRepository();
            var orderRepository    = new StubIOrderRepository();

            var salesManagement = new SalesAppService(productRepository, orderRepository, customerRepository);

            var dto = new SoftwareDto()
            {
                Title         = "The title",
                Description   = "the description",
                LicenseCode   = "license",
                AmountInStock = 10,
                UnitPrice     = -1 //this is a not valid value
            };

            //Act
            var result = salesManagement.AddNewSoftware(dto);
        }
        public void AddNewSoftwareReturnAddedSoftware()
        {
            //Arrange
            var customerRepository = new StubICustomerRepository();
            var orderRepository    = new StubIOrderRepository();
            var productRepository  = new StubIProductRepository();

            productRepository.UnitOfWorkGet = () =>
            {
                var uow = new StubIUnitOfWork();
                uow.Commit = () => { };

                return(uow);
            };

            productRepository.AddProduct = (product) => { };

            var salesManagement = new SalesAppService(productRepository, orderRepository, customerRepository);

            var dto = new SoftwareDto()
            {
                Title         = "The title",
                Description   = "description",
                LicenseCode   = "license code",
                AmountInStock = 10,
                UnitPrice     = 10
            };

            //Act
            var result = salesManagement.AddNewSoftware(dto);

            //Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Id != Guid.Empty);
            Assert.AreEqual(result.Title, dto.Title);
            Assert.AreEqual(result.Description, dto.Description);
            Assert.AreEqual(result.LicenseCode, dto.LicenseCode);
            Assert.AreEqual(result.AmountInStock, dto.AmountInStock);
            Assert.AreEqual(result.UnitPrice, dto.UnitPrice);
        }
Beispiel #6
0
        /// <summary>
        ///    <see cref="Microsoft.Samples.NLayerApp.Application.MainBoundedContext.ERPModule.Services.ISalesAppService" />
        /// </summary>
        /// <param name="softwareDto">
        ///    <see cref="Microsoft.Samples.NLayerApp.Application.MainBoundedContext.ERPModule.Services.ISalesAppService" />
        /// </param>
        public SoftwareDto AddNewSoftware(SoftwareDto softwareDto)
        {
            if (softwareDto == null)
            {
                throw new ArgumentException(Messages.warning_CannotAddSoftwareWithNullInformation);
            }

            //Create the softare entity
            var newSoftware = new Software(softwareDto.Title, softwareDto.Description, softwareDto.LicenseCode);

            //set unit price and stock
            newSoftware.ChangeUnitPrice(softwareDto.UnitPrice);
            newSoftware.IncrementStock(softwareDto.AmountInStock);

            //Assign the poid
            newSoftware.GenerateNewIdentity();

            //save software
            SaveProduct(newSoftware);

            //return software dto
            return(newSoftware.ProjectedAs <SoftwareDto>());
        }
Beispiel #7
0
 /// <summary>
 ///    <see
 ///       cref="Microsoft.Samples.NLayerApp.Application.MainBoundedContext.BankingModule.Services.IMainBoundedContextService" />
 /// </summary>
 /// <param name="software">
 ///    <see
 ///       cref="Microsoft.Samples.NLayerApp.Application.MainBoundedContext.BankingModule.Services.IMainBoundedContextService" />
 /// </param>
 /// <returns>
 ///    <see
 ///       cref="Microsoft.Samples.NLayerApp.Application.MainBoundedContext.BankingModule.Services.IMainBoundedContextService" />
 /// </returns>
 public SoftwareDto AddNewSoftware(SoftwareDto software)
 {
     return(_salesAppService.AddNewSoftware(software));
 }