コード例 #1
0
        public void GetNumberOfWarrantyOrderByInvoiceIdAndProductId_Success_ReturnInt()
        {
            // Arrange
            var repository = new WarrantyOrderRepository();

            // Act
            var result = repository.GetNumberOfWarrantyOrderByInvoiceIdAndProductId(1, 1);

            // Assert
            Assert.That(result >= 0);
        }
コード例 #2
0
        public WarrantyOrder AddNewWarrantyOrder(ProductForWarrantyDto customerProduct)
        {
            // check if this product has already been add to warranty order? (through InvoiceId, ProductId)
            var noProductsBought = _invoiceProductRepository.GetNumberOfProductByInvoiceId(customerProduct.InvoiceId, customerProduct.Id);

            var noProductsOnWarratyOrders = _warrantyOrderRepository.GetNumberOfWarrantyOrderByInvoiceIdAndProductId(customerProduct.InvoiceId, customerProduct.Id);

            if (noProductsOnWarratyOrders == noProductsBought)
            {
                throw new Exception("Sản phẩm này đang được bảo hành rồi!");
            }

            // now we can actually add it
            var warrantyOrder = Mapper.Map <WarrantyOrder>(customerProduct);

            warrantyOrder.Status       = (int)WarrantyOrderStatus.WaitForSent;
            warrantyOrder.CreationTime = DateTime.Now;
            return(_warrantyOrderRepository.Create(warrantyOrder));
        }