Exemplo n.º 1
0
        public ActionResult CreateOrder(SalesOrders order)
        {
            // 產品選擇是否重複  true:有重複
            bool isProductDuplicate = order.Details.Select(x => x.ProductID).Distinct().Count() != order.Details.Count;

            if (!ModelState.IsValid || isProductDuplicate)
            {
                ViewBag.ErrorMessage = isProductDuplicate ? "商品重複!" : "驗證失敗!";
                // 準備 [客戶名稱] 下拉選單
                ViewBag.CustomerList = GetCustomerList();

                // 準備 [負責員工] 下拉選單資料
                ViewBag.EmployeeList = GetEmployeeList();

                // 準備 [出貨公司名稱] 下拉選單資料
                ViewBag.ShipperList = GetShipperList();

                return(View(order));
            }
            ModelState.Clear();

            SalesOrdersService orderService = new SalesOrdersService();

            orderService.InsOrder(order);

            return(RedirectToAction("Query", "Order"));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 刪除訂單功能
        /// </summary>
        /// <param name="orderID">訂單編號</param>
        /// <returns></returns>
        public JsonResult DeleteOrder(int OrderID)
        {
            SalesOrdersService orderService = new SalesOrdersService();

            orderService.DelOrder(OrderID);

            return(Json("", JsonRequestBehavior.AllowGet));
        }
        public SalesOrdersModel[] Retorno([FromQuery(Name = "parametro")] string parametro)
        {
            List <SalesOrdersModel> listaJson = JsonConvert.DeserializeObject <List <SalesOrdersModel> >(System.IO.File.ReadAllText("C:/Users/vitor/source/repos/WebApplication3/data/sales_orders.json"));



            return(SalesOrdersService.ConstrutorArray(listaJson, parametro));
        }
Exemplo n.º 4
0
        private void GivenSalesOrdersService()
        {
            // Look to this class for the mockup of sales orders. We still need the mock objects, which is why the local fields are
            // passed by ref.

            new SalesOrdersMock(ref salesOrders, ref salesOrderItems, ref moqDbContext, ref moqSalesOrdersSet, ref moqSalesOrderItemsSet);

            salesOrdersService = new SalesOrdersService(moqDbContext.Object);
        }
Exemplo n.º 5
0
        public ActionResult UpdateOrder(int orderID)
        {
            SalesOrdersService orderService = new SalesOrdersService();

            SalesOrders order = orderService.GetOrder(orderID);

            // 準備下拉選單
            PrepareDDLSource();

            return(View(order));
        }
Exemplo n.º 6
0
        public ActionResult OrderList(OrderQueryArg arg)
        {
            SalesOrdersService orderService    = new SalesOrdersService();
            CustomerService    customerService = new CustomerService();

            // 過濾後訂單資料
            IList <SalesOrders> orders = orderService.GetOrders(arg);

            // 所有客戶資料
            ViewBag.Customers = customerService.GetCustomers();

            return(View(orders));
        }
        private void GivenSalesOrderControllerWithInMemoryDatabase()
        {
            // Follow this method into the factory to see how it sets up the in-memory database.

            InMemoryDatabaseFactory       factory = new InMemoryDatabaseFactory();
            DbContextOptions <TC3Context> options = new DbContextOptionsBuilder <TC3Context>().UseSqlite(factory.Instance.Connection).Options;

            dbContext = new TC3Context(options);
            dbContext.Database.EnsureCreated();

            salesOrdersService = new SalesOrdersService(dbContext);
            controller         = new SalesOrdersController(salesOrdersService);
        }
Exemplo n.º 8
0
        public ActionResult UpdateOrder(SalesOrders order)
        {
            // 產品選擇是否重複  true:有重複
            bool isProductDuplicate = order.Details.Select(x => x.ProductID).Distinct().Count() != order.Details.Count;

            if (!ModelState.IsValid || isProductDuplicate)
            {
                // 準備下拉選單
                PrepareDDLSource();
                ViewBag.ErrorMessage = isProductDuplicate ? "商品重複!" : "驗證失敗!";
                return(View(order));
            }
            ModelState.Clear();

            SalesOrdersService orderService = new SalesOrdersService();

            orderService.UpdOrder(order);

            return(RedirectToAction("Query", "Order"));
        }