コード例 #1
0
        public ActionResult showReceipt(int id)
        {

            if (!isAdmin())
                return RedirectToAction("LogIn", "Main");
          
            Order allOrders = _orderbll.getAllOrders(id)[0];
            BillingViewModel b = null;
        
               List<int> s = new List<int>();
               foreach(var i in allOrders.orderLine)
               {
                   
                     s.Add(i.quantity * i.product.price);
                }
               
               b = new BillingViewModel() 
               {
                    customer = allOrders.customer,
                    order = allOrders,
                    ordreid = allOrders.id,  
                    orderdate = allOrders.orderdate,
                    shoppingcart = allOrders.orderLine,
                    totsum = _orderbll.getSum(allOrders),
                    mva = _orderbll.getMva(_orderbll.getSum(allOrders)), 
                    exmva = _orderbll.getExmva(_orderbll.getSum(allOrders)),
                    sum = s
                    
               };
              
            return View(b);
        }
コード例 #2
0
        public void order_showReciept_not_null()
        {
            TestControllerBuilder builder = new TestControllerBuilder();
            //Arrange
            var controller = new OrderController(new OrderBLL(new OrderDALStub()));
            builder.InitializeController(controller);
            builder.HttpContext.Session["loggedInUser"] = new Customer() { admin = true };
            BillingViewModel expected = new BillingViewModel()
            { 
                ordreid = 12345,
                orderdate =DateTime.Now,
                totsum = 30,
                mva = 8,
                exmva = 28,
                
            };

            //Act
            var action = (ViewResult)controller.showReceipt(12345);
            var result = (BillingViewModel)action.Model;

            //Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(result.sum.Count, result.shoppingcart.Count); 
            
        }