Esempio n. 1
0
        public async Task <IActionResult> PutOrderItemData(int id, OrderItemData orderItemData)
        {
            if (id != orderItemData.OrderItemId)
            {
                return(BadRequest());
            }

            _context.Entry(orderItemData).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();

                return(Ok(orderItemData));
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!OrderItemDataExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Purpose: Grabs all order items
        /// Accepts: Nothing
        /// Returns: List<OrderItem>
        /// </summary>
        public List <OrderItem> GetAllOrderItems()
        {
            List <OrderItem> orderitems = new List <OrderItem>();

            try
            {
                OrderItemData data = new OrderItemData();
                List <QSRDataObjects.OrderItem> dataOrderItems = data.GetAllOrderItems();

                foreach (QSRDataObjects.OrderItem oi in dataOrderItems)
                {
                    OrderItem order = new OrderItem();
                    order.OrderItemID = oi.OrderItemID;
                    order.OrderID     = oi.OrderID;
                    order.ProductCode = oi.ProductCode;
                    order.Created     = oi.Created;
                    order.Modified    = oi.Modified;
                    orderitems.Add(order);
                }
            }
            catch (Exception ex)
            {
                ErrorRoutine(ex, "OrderItem", "GetAllOrderItems");
            }
            return(orderitems);
        }
        public void GetOrderByCodeTest()
        {
            //Arrange
            var test_order = new Order()
            {
                OrderKey = 1, AccountKey = 1, OrderNumber = "TSTORDER0001"
            };

            test_order.OrderItems.Add(new OrderItem()
            {
                OrderItemKey = 1, OrderKey = 1, OrderItemQuantity = 1, OrderItemLineSum = 30M
            });
            var test_order_data = new OrderHeaderData()
            {
                OrderKey = 1, AccountKey = 1, OrderNum = "TSTORDER0001"
            };
            var test_order_item_data = new OrderItemData()
            {
                OrderKey = 1, OrderItemLineSum = 30M, OrderItemPricePer = 30M, OrderItemQuantity = 1
            };
            Mock <IOrderHeaderRepository> order_repo      = new Mock <IOrderHeaderRepository>();
            Mock <IOrderItemRepository>   order_item_repo = new Mock <IOrderItemRepository>();
            Mock <IOrderEntityService>    order_es        = new Mock <IOrderEntityService>();

            Mock <IOrderBusinessEngine>   order_be     = new Mock <IOrderBusinessEngine>();
            Mock <IDataRepositoryFactory> repo_factory = new Mock <IDataRepositoryFactory>();
            Mock <IBusinessEngineFactory> be_factory   = new Mock <IBusinessEngineFactory>();
            Mock <IEntityServiceFactory>  es_factory   = new Mock <IEntityServiceFactory>();

            Mock <IEmployeeBusinessEngine>    emp_be        = new Mock <IEmployeeBusinessEngine>();
            Mock <IOrderStatusBusinessEngine> ord_status_be = new Mock <IOrderStatusBusinessEngine>();

            order_repo.Setup(mock => mock.GetByCode(It.IsAny <string>(), It.IsAny <string>())).Returns(test_order_data);
            order_be.Setup(mock => mock.GetOrderByCode(It.IsAny <string>(), It.IsAny <string>())).Returns(test_order);
            order_es.Setup(mock => mock.Map(It.IsAny <OrderHeaderData>())).Returns(test_order);
            //order_es.Setup(mock => mock.Map(It.IsAny<OrderItem>())).Returns(test_order_item_data);
            repo_factory.Setup(mock => mock.GetDataRepository <IOrderHeaderRepository>()).Returns(order_repo.Object);
            repo_factory.Setup(mock => mock.GetDataRepository <IOrderItemRepository>()).Returns(order_item_repo.Object);
            be_factory.Setup(mock => mock.GetBusinessEngine <IOrderBusinessEngine>()).Returns(order_be.Object);
            be_factory.Setup(mock => mock.GetBusinessEngine <IEmployeeBusinessEngine>()).Returns(emp_be.Object);
            be_factory.Setup(mock => mock.GetBusinessEngine <IOrderStatusBusinessEngine>()).Returns(ord_status_be.Object);
            es_factory.Setup(mock => mock.GetEntityService <IOrderEntityService>()).Returns(order_es.Object);

            OrderBusinessEngine order_business_engine = new OrderBusinessEngine(repo_factory.Object, be_factory.Object, es_factory.Object);

            //Act
            Order ret_val = order_business_engine.GetOrderByCode("TSTORDER0001", "TEST");

            //Assert
            Assert.IsTrue(ret_val.OrderNumber == test_order.OrderNumber);
        }
        public void OrderSaveTest()
        {
            //Arrange
            var test_order = new Order()
            {
                OrderKey = 1, AccountKey = 1, OrderNumber = "TSTORDER0001"
            };

            test_order.OrderItems.Add(new OrderItem()
            {
                OrderItemKey = 1, OrderKey = 1, OrderItemQuantity = 1, OrderItemLineSum = 30M
            });
            var test_order_data = new OrderHeaderData()
            {
                OrderKey = 1, AccountKey = 1, OrderNum = "TSTORDER0001"
            };
            var test_order_item_data = new OrderItemData()
            {
                OrderKey = 1, OrderItemLineSum = 30M, OrderItemPricePer = 30M, OrderItemQuantity = 1
            };
            var order_repo      = new Mock <IOrderHeaderRepository>();
            var order_item_repo = new Mock <IOrderItemRepository>();
            var order_es        = new Mock <IOrderEntityService>();
            var order_item_es   = new Mock <IOrderItemEntityService>();
            var comment_be      = new Mock <ICommentBusinessEngine>();

            var order_be     = new Mock <IOrderBusinessEngine>();
            var repo_factory = new Mock <IDataRepositoryFactory>();
            var be_factory   = new Mock <IBusinessEngineFactory>();
            var es_factory   = new Mock <IEntityServiceFactory>();

            order_repo.Setup(mock => mock.Save(It.IsAny <OrderHeaderData>())).Returns(1);
            order_be.Setup(mock => mock.OrderSave(It.IsAny <Order>())).Returns(1);
            order_es.Setup(mock => mock.Map(It.IsAny <Order>())).Returns(test_order_data);
            order_es.Setup(mock => mock.Map(It.IsAny <Order>())).Returns(test_order_data);
            order_item_es.Setup(mock => mock.Map(It.IsAny <OrderItem>())).Returns(test_order_item_data);
            repo_factory.Setup(mock => mock.GetDataRepository <IOrderHeaderRepository>()).Returns(order_repo.Object);
            repo_factory.Setup(mock => mock.GetDataRepository <IOrderItemRepository>()).Returns(order_item_repo.Object);
            be_factory.Setup(mock => mock.GetBusinessEngine <IOrderBusinessEngine>()).Returns(order_be.Object);
            be_factory.Setup(mock => mock.GetBusinessEngine <ICommentBusinessEngine>()).Returns(comment_be.Object);
            es_factory.Setup(mock => mock.GetEntityService <IOrderEntityService>()).Returns(order_es.Object);
            es_factory.Setup(mock => mock.GetEntityService <IOrderItemEntityService>()).Returns(order_item_es.Object);

            OrderBusinessEngine account_business_engine = new OrderBusinessEngine(repo_factory.Object, be_factory.Object, es_factory.Object);

            //Act
            int ret_val = account_business_engine.OrderSave(test_order);

            //Assert
            Assert.IsTrue(ret_val == 1);
        }
Esempio n. 5
0
        static void Buying()
        {
            Console.WriteLine("Please choose the clothes type : [T-Shirst: press 1, DressShirt press 2. To make Order: press 9 , Press 0 to exit] :");
            var type = Console.ReadLine();
            List <OrderItemData> items = new List <OrderItemData>();

            while (type != "0")
            {
                if (type == "9")
                {
                    storeService.MakeOrder(items);
                    Console.WriteLine("Order successfull");
                    break;
                }

                Console.Write("Please choose a price to buy:");
                var price = Console.ReadLine();

                Console.Write("Please choose amount:");
                var amount = Console.ReadLine();

                Console.Write("Please choose a Supplier: [Input supplier Id in [1-9]]");
                var supplier = Console.ReadLine();

                var item = new OrderItemData
                {
                    Amount = Convert.ToInt32(amount),
                    Price  = Convert.ToDecimal(price),
                };

                if (int.TryParse(supplier, out int result))
                {
                    item.SupplierId = result;
                }

                if (type == "1")
                {
                    item.Type = Store.Common.Enums.ClothesType.TShirt;
                }
                else if (type == "2")
                {
                    item.Type = Store.Common.Enums.ClothesType.DressShirt;
                }

                items.Add(item);

                Console.WriteLine("================================");
                type = Console.ReadLine();
            }
        }
 private OrderItem MapOrderItemDataToOrderItem(OrderItemData order_item_data)
 {
     return(ExecuteFaultHandledOperation(() =>
     {
         var orderItem = _order_item_se.Map(order_item_data);
         orderItem.OrderItemShipToAddress = _address_be.GetAddressByID(order_item_data.ShiptoAddrKey);
         orderItem.OrderItemBillToAddress = _address_be.GetAddressByID(order_item_data.BilltoAddrKey);
         orderItem.OrderItemStatusData = _order_item_status_be.GetStatusByID(order_item_data.OrderItemStatusKey);
         orderItem.OrderItemProduct = _product_be.GetProductByID(order_item_data.ProductKey);
         orderItem.AccountRep = _employee_be.GetAccountRepByKey(order_item_data.OrderItemAccountRepKey);
         orderItem.SalesRep = _employee_be.GetSalesRepByKey(order_item_data.OrderItemSalesRepKey);
         return orderItem;
     }));
 }
Esempio n. 7
0
        public async Task <ActionResult <OrderItemData> > PostOrderItemData(OrderItemData orderItemData)
        {
            try
            {
                _context.orderItemData.Add(orderItemData);
                await _context.SaveChangesAsync();

                return(CreatedAtAction("GetOrderItemData", new { id = orderItemData.OrderItemId }, orderItemData));
            }
            catch
            {
                return(BadRequest());
            }
        }
 public OrderItem(OrderItemData orderItemData)
 {
     OrderItemKey          = orderItemData.OrderItemKey;
     OrderKey              = orderItemData.OrderKey;
     OrderItemSeq          = orderItemData.OrderItemSeq;
     ProductKey            = orderItemData.ProductKey;
     ProductName           = orderItemData.ProductName;
     ProductDesc           = orderItemData.ProductDesc;
     OrderItemQuantity     = orderItemData.OrderItemQuantity;
     OrderItemShipDate     = orderItemData.OrderItemShipDate;
     OrderItemCompleteDate = orderItemData.OrderItemCompleteDate;
     ItemPricePer          = orderItemData.OrderItemPricePer;
     OrderItemLineSum      = orderItemData.OrderItemLineSum;
     AddedUserID           = orderItemData.AuditAddUserId;
     AddedDateTime         = orderItemData.AuditAddDatetime;
     UpdateUserID          = orderItemData.AuditUpdateUserId;
     UpdateDateTime        = orderItemData.AuditUpdateDatetime;
     OrderItemStatus       = (QIQOOrderItemStatus)orderItemData.OrderItemStatusKey;
 }
Esempio n. 9
0
        /// <summary>
        /// Purpose: Grabs order item information based on ID
        /// Accepts: Int
        /// Returns: Nothing
        /// </summary>
        public void GetOrderItemByID(int id)
        {
            try
            {
                OrderItemData data = new OrderItemData();
                Hashtable     hsh  = new Hashtable();

                hsh = data.GetOrderItemByID(id);

                OrderItemID = id;
                OrderID     = hsh["orderid"];
                ProductCode = hsh["productcode"];
                Created     = hsh["created"];
                Modified    = hsh["modified"];
            }
            catch (Exception ex)
            {
                ErrorRoutine(ex, "OrderItem", "GetOrderItemByID");
            }
        }
 public OrderItem Map(OrderItemData order_item_data)
 {
     return(new OrderItem()
     {
         OrderItemKey = order_item_data.OrderItemKey,
         OrderKey = order_item_data.OrderKey,
         OrderItemSeq = order_item_data.OrderItemSeq,
         ProductKey = order_item_data.ProductKey,
         ProductName = order_item_data.ProductName,
         ProductDesc = order_item_data.ProductDesc,
         OrderItemQuantity = order_item_data.OrderItemQuantity,
         OrderItemShipDate = order_item_data.OrderItemShipDate,
         OrderItemCompleteDate = order_item_data.OrderItemCompleteDate,
         ItemPricePer = order_item_data.OrderItemPricePer,
         OrderItemLineSum = order_item_data.OrderItemLineSum,
         AddedUserID = order_item_data.AuditAddUserId,
         AddedDateTime = order_item_data.AuditAddDatetime,
         UpdateUserID = order_item_data.AuditUpdateUserId,
         UpdateDateTime = order_item_data.AuditUpdateDatetime,
         OrderItemStatus = (QIQOOrderItemStatus)order_item_data.OrderItemStatusKey
     });
 }
Esempio n. 11
0
        } // Map function closer

        public List <SqlParameter> MapParamsForUpsert(OrderItemData entity)
        {
            var sql_params = new List <SqlParameter>();

            sql_params.Add(new SqlParameter("@order_item_key", entity.OrderItemKey));
            sql_params.Add(new SqlParameter("@order_key", entity.OrderKey));
            sql_params.Add(new SqlParameter("@order_item_seq", entity.OrderItemSeq));
            sql_params.Add(new SqlParameter("@product_key", entity.ProductKey));
            sql_params.Add(new SqlParameter("@product_name", entity.ProductName));
            sql_params.Add(new SqlParameter("@product_desc", entity.ProductDesc));
            sql_params.Add(new SqlParameter("@order_item_quantity", entity.OrderItemQuantity));
            sql_params.Add(new SqlParameter("@shipto_addr_key", entity.ShiptoAddrKey));
            sql_params.Add(new SqlParameter("@billto_addr_key", entity.BilltoAddrKey));
            sql_params.Add(new SqlParameter("@order_item_ship_date", entity.OrderItemShipDate));
            sql_params.Add(new SqlParameter("@order_item_complete_date", entity.OrderItemCompleteDate));
            sql_params.Add(new SqlParameter("@order_item_price_per", entity.OrderItemPricePer));
            sql_params.Add(new SqlParameter("@order_item_line_sum", entity.OrderItemLineSum));
            sql_params.Add(new SqlParameter("@order_item_acct_rep_key", entity.OrderItemAccountRepKey));
            sql_params.Add(new SqlParameter("@order_item_sales_rep_key", entity.OrderItemSalesRepKey));
            sql_params.Add(new SqlParameter("@order_item_status_key", entity.OrderItemStatusKey));
            sql_params.Add(GetOutParam());
            return(sql_params);
        }
 public OrderItem Map(OrderItemData ent) => new OrderItem(ent);
Esempio n. 13
0
 public List <OrderItem> GetOrderItemByOrderId(Guid orderId)
 {
     return(OrderItemData.GetByOrderId(orderId));
 }
Esempio n. 14
0
 public List <SqlParameter> MapParamsForDelete(OrderItemData entity)
 {
     return(MapParamsForDelete(entity.OrderItemKey));
 }