/// <summary>
        /// <see cref="Microsoft.Samples.NLayerApp.Application.MainBoundedContext.ERPModule.Services.ISalesAppService"/>
        /// </summary>
        /// <param name="software"><see cref="Microsoft.Samples.NLayerApp.Application.MainBoundedContext.ERPModule.Services.ISalesAppService"/></param>
        public SoftwareDTO AddNewSoftware(SoftwareDTO software)
        {
            if (software == null)
            {
                LoggerFactory.CreateLog().LogWarning(Messages.warning_CannotAddSoftwareWithNullInformation);
                return null;
            }

            //Create the softare entity
            var newSoftware = ProductFactory.CreateProduct<Software>(software.Title, software.Description,0,0);

            newSoftware.LicenseCode = software.LicenseCode;
            newSoftware.UnitPrice = software.UnitPrice;
            newSoftware.AmountInStock = software.AmountInStock;

            //Assign the poid
            newSoftware.Id = IdentityGenerator.NewSequentialGuid();

            //save software
            SaveProduct(newSoftware);

            //return software dto
            return _typeAdapter.Adapt<Software, SoftwareDTO>(newSoftware);
        }
        public void AddNewSoftwareThrowExceptionWhenDataIsInvalid()
        {
            //Arrange
            var adapter = PrepareTypeAdapter();
            var customerRepository = new SICustomerRepository();
            var productRepository = new SIProductRepository();
            var orderRepository = new SIOrderRepository();

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

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

            //Act
            var result = salesManagement.AddNewSoftware(dto);
        }
 /// <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);
 }
        public void AddNewSoftwareReturnAddedSoftware()
        {
            //Arrange
            var adapter = PrepareTypeAdapter();
            var customerRepository = new SICustomerRepository();
            var orderRepository = new SIOrderRepository();
            var productRepository = new SIProductRepository();

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

                return uow;
            };

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

            var salesManagement = new SalesAppService(adapter, 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);
        }