Ejemplo n.º 1
0
 public JsonResult Sell(Array[] data, string discount, string customerId)
 {
     if (Convert.ToInt32(customerId) <= 0)
     {
         return(Json("2"));
     }
     try
     {
         Sales sales = new Sales();
         int   count = 0;
         sales.SalesDate  = DateTime.Now;
         sales.Discount   = Convert.ToDouble(discount) / Convert.ToDouble(data.Length);
         sales.PersonalId = Convert.ToInt32(Request.Cookies["Personal"]["Id"]);
         if (customerId != "-1")
         {
             sales.CustomerId = Convert.ToInt32(customerId);
         }
         for (int i = 0; i < data.Length; i++)
         {
             foreach (var product in data[i])
             {
                 if (count == 0)
                 {
                     sales.ProductId = Convert.ToInt32(product);
                 }
                 else if (count == 1)
                 {
                     sales.Piece = Convert.ToInt32(product);
                 }
                 count++;
             }
             count = 0;
             salesService.Add(sales);
         }
         return(Json("1"));
     }
     catch { return(Json("0")); }
 }
Ejemplo n.º 2
0
        public void Add_Order_No_Error()
        {
            // Arrange
            var salesService = new SalesService(sourceService.Object, iLoggerFactory.Object.CreateLogger <SalesService>());
            var ord          = new Order()
            {
                Id          = -1,
                Amount      = 10,
                DateCreated = DateTime.Now
            };

            sourceService.Setup(nt => nt.Add(ord)).Returns(Task.Run(() => { }));

            // Action
            salesService.Add(ord).Wait();

            // Assert
            sourceService.Verify(x => x.Add(ord), Times.Once);
        }