Esempio n. 1
0
        private void RandomizeOrderHistory()
        {
            var shuffledOrders = OrdersData.GetOrdersRandomized();

            orderList.DataSource = shuffledOrders;
            orderList.DataBind();
        }
Esempio n. 2
0
 public JsonResult DeleteOrder(int id)
 {
     using (OrdersData db = new OrdersData())
     {
         return(Json(db.Delete(_order => _order.Id == id)));
     }
 }
Esempio n. 3
0
        public ActionResult Ajax_Reject_Request_Item(ajax_model ajax_data)
        {
            ajax_model data = new ajax_model
            {
                name      = ajax_data.name,
                main_data = ajax_data.main_data,
            };

            using (var db = new DataBaseContext())
            {
                int temp_id = Int32.Parse(data.main_data[0]);

                orders temp_order = db.orders_repository.Where(o => o.ordersId == temp_id).FirstOrDefault();
                temp_order.order_status = "Reject_by_Head";

                db.SaveChanges();
            }
            object reply_to_client = new
            {
                key_itemname_lis = "SUCCESS",
            };


            //Email Notification
            orders ord      = OrdersData.GetOrderById(Int32.Parse(data.main_data[0]));
            string emailadd = StaffData.GetStaffByName(ord.staff_obj.name).email;
            Task   task     = Task.Run(() => {
                EmailNotification.SendNotificationEmailToEmployee(emailadd, "Requisition Progress Updated", "Your requisition was just rejected by manager, please check.");
            });

            return(Json(reply_to_client, JsonRequestBehavior.AllowGet));
        }
Esempio n. 4
0
        public bool ParseOrdersData(String Message, ref OrdersData Orders)
        {
            String[] SubMessage = Message.Substring(20).Split(new char[] { ',' });

            Orders.TradingTime = SubMessage[0];
            Orders.BidPrice    = (float)Convert.ToDouble(SubMessage[2]);
            Orders.BidVolume   = Convert.ToInt32(SubMessage[3]) / 100;
            Orders.BidNumber   = Convert.ToInt32(SubMessage[4]);
            Orders.AskPrice    = (float)Convert.ToDouble(SubMessage[5]);
            Orders.AskVolume   = Convert.ToInt32(SubMessage[6]) / 100;
            Orders.AskNumber   = Convert.ToInt32(SubMessage[7]);

            String[] BidOrders = SubMessage[8].Split(new char[] { '|' });
            foreach (var ele in BidOrders)
            {
                if (ele == String.Empty)
                {
                    continue;
                }
                Orders.BidOrders.Add(Convert.ToInt32(ele) / 100);
            }

            String[] AskOrders = SubMessage[10].Split(new char[] { '|' });
            foreach (var ele in AskOrders)
            {
                if (ele == String.Empty)
                {
                    continue;
                }
                Orders.AskOrders.Add(Convert.ToInt32(ele) / 100);
            }

            return(true);
        }
        private async void Rectangle_PointerPressed_1(object sender, PointerEventArgs e)
        {
            if (!App.IsUserLoggedIn)
            {
                MessageDialog md = new MessageDialog("You need to be logged in to checkout.");
                await md.ShowAsync();

                return;
            }
            else
            {
                MessageDialog md     = new MessageDialog("Are you sure you want to place this order ?");
                var           cancel = new UICommand("Cancel", (cmd) => {
                    return;
                });
                var placeOrder = new UICommand("Place order", (cmd) =>
                {
                    Order order       = new Order();
                    order.OrderRowKey = Guid.NewGuid().ToString();
                    order.UserRowKey  = "something";

                    OrdersData.InitOrder(order.OrderRowKey, order.UserRowKey);

                    this.Frame.Navigate(typeof(OrderThanks), order);
                });

                md.Commands.Add(cancel);
                md.Commands.Add(placeOrder);

                await md.ShowAsync();
            }
        }
 public JsonResult ReturnCar(int orderId)
 {
     using (OrdersData db = new OrdersData())
     {
         var returned = db.ReturnCar(orderId);
         return(Json(returned));
     }
 }
Esempio n. 7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         ComboBox1.DataSource = OrdersData.GetOrders();
         ComboBox1.DataBind();
     }
 }
        // GET: Checkout

        //From Products View -> Redirect to checkout controller -> Purchase History View
        public ActionResult Checkout(int Id, string sessionId)
        {
            int date       = GetTodayDate();
            int NewOrderId = OrdersData.NewOrder(Id, date, "NULL");

            List <Order> OrderSummary       = (List <Order>)Session[sessionId + "_Orders"];
            string       OrdersConfirmation = OrdersData.EnterOrderDetails(OrderSummary, NewOrderId);

            return(RedirectToAction("ActivationCode", "Checkout", new { NewOrderId = NewOrderId, Id = Id, sessionId = sessionId }));
        }
Esempio n. 9
0
        public ActionResult RemoveOrder(int id)
        {
            OrdersData Ordermodel = db.Orders.Find(id);

            db.Orders.Remove(Ordermodel);
            db.SaveChanges();
            db.Sales.RemoveRange(db.Sales.Where(x => x.OrderId == Ordermodel.OrderId).ToList());
            db.SaveChanges();
            return(RedirectToAction("DisplaysOrders"));
        }
Esempio n. 10
0
 public JsonResult AddOrder(OrderValidation order)
 {
     if (ModelState.IsValid)
     {
         using (OrdersData db = new OrdersData())
         {
             return(Json(db.Add(order)));
         }
     }
     return(Json(false));
 }
Esempio n. 11
0
        public OrdersData GetOrdersData()
        {
            OrdersData data = new OrdersData();

            data.OrdersList  = _dal.GetOrdersList();
            data.TotalOrders = data.OrdersList.Count;
            //data.TotalShippingCost = data.OrdersList.Sum(l => l.ShippingCost);
            //data.AverageShippingCost = data.OrdersList.Average(l => l.ShippingCost);

            return(data);
        }
Esempio n. 12
0
 public JsonResult UpdateOrder(OrderValidation order, int id)
 {
     if (ModelState.IsValid)
     {
         using (OrdersData db = new OrdersData())
         {
             return(Json(db.Update(_order => _order.Id == id, order)));
         }
     }
     return(Json(false));
 }
        public ActionResult Update(CRUDModel myObject)
        {
            var        ord = myObject.Value;
            OrdersData val = pfGridData.Where(or => or.OrderID == ord.OrderID).FirstOrDefault();

            val.OrderID    = ord.OrderID;
            val.CustomerID = ord.CustomerID;
            val.Freight    = ord.Freight;
            val.ShipCity   = ord.ShipCity;
            return(Json(myObject.Value));
        }
Esempio n. 14
0
 /// <summary>
 /// Verify The Payment And Add The Order To The DataBase
 /// </summary>
 /// <param name="session"></param>
 /// <param name="creditCard"></param>
 /// <returns></returns>
 public static bool SetOrderToDatabase(this HttpSessionStateBase session, int creditCard)
 {
     if (creditCard != null && session["order"] != null) // check credit card
     {
         using (OrdersData db = new OrdersData())
         {
             Order order = (Order)session["order"];
             db.Add(order);
             session.Remove("order");
             return(true);
         }
     }
     return(false);
 }
Esempio n. 15
0
        public ActionResult Index()
        {
            var Order  = OrdersDetails.GetAllRecords();
            var Order1 = OrdersData.GetAllRecords();

            ViewBag.DataSource  = BigData.GetAllRecords();
            ViewBag.DataSource1 = Order;
            ViewBag.DataSource2 = OrdersData.GetAllRecords();
            ViewBag.DataSource3 = from a in Order
                                  join b in Order1 on a.EmployeeID equals b.EmployeeID
                                  select new { a.CustomerID, a.EmployeeID, a.OrderDate, a.OrderID, b.ShipName,
                                               b.ShipAddress };

            return(View());
        }
        public ActionResult ViewPurchaseHistory(int?NewOrderId, int Id, string sessionId)
        {
            List <Order> Orders = OrdersData.GetOrders(Id);

            List <Order> OrderSummary = (List <Order>)Session[sessionId + "_Orders"];

            OrderSummary.Clear();

            //send back to view
            ViewData["PurchaseHistory"] = Orders;
            ViewData["sessionId"]       = sessionId;
            ViewData["Id"] = Id;

            //Return View Purchase History View
            return(View());
        }
Esempio n. 17
0
 public JsonResult GetOrder(string search)
 {
     using (OrdersData db = new OrdersData())
     {
         var orders = db.GetFromSearch(search, order => new
         {
             id         = order.Id,
             carid      = order.carid,
             userid     = order.userid,
             startdate  = order.startdate,
             enddate    = order.enddate,
             returndate = order.returndate
         });
         return(Json(orders));
     }
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        ListBox1                = new Obout.ListBox.ListBox();
        ListBox1.ID             = "ListBox1";
        ListBox1.Width          = Unit.Pixel(225);
        ListBox1.Height         = Unit.Pixel(200);
        ListBox1.DataTextField  = "ShipName";
        ListBox1.DataValueField = "OrderID";

        ListBox1Container.Controls.Add(ListBox1);

        if (!Page.IsPostBack)
        {
            ListBox1.DataSource = OrdersData.GetOrders();
            ListBox1.DataBind();
        }
    }
        public IActionResult UrlDatasource([FromBody] DataManagerRequest dm)
        {
            var         Order      = OrdersDetails.GetAllRecords();
            var         Order1     = OrdersData.GetAllRecords();
            IEnumerable DataSource = (from a in Order
                                      join b in Order1 on a.EmployeeID equals b.EmployeeID
                                      select new
            {
                a.CustomerID,
                a.EmployeeID,
                a.OrderDate,
                a.OrderID,
                b.ShipName,
                b.ShipAddress
            }).ToList();
            //IEnumerable DataSource = OrdersDetails.GetAllRecords();
            DataOperations operation = new DataOperations();

            if (dm.Search != null && dm.Search.Count > 0)
            {
                DataSource = operation.PerformSearching(DataSource, dm.Search); //Search
            }
            if (dm.Sorted != null && dm.Sorted.Count > 0)                       //Sorting
            {
                DataSource = operation.PerformSorting(DataSource, dm.Sorted);
            }
            if (dm.Where != null && dm.Where.Count > 0) //Filtering
            {
                DataSource = operation.PerformFiltering(DataSource, dm.Where, dm.Where[0].Operator);
            }
            var MergeListData = DataSource.Cast <object>().ToList();
            int count         = MergeListData.Count();

            if (dm.Skip != 0)
            {
                DataSource = operation.PerformSkip(DataSource, dm.Skip);   //Paging
            }
            if (dm.Take != 0)
            {
                DataSource = operation.PerformTake(DataSource, dm.Take);
            }
            return(dm.RequiresCounts ? Json(new { result = DataSource, count = count }) : Json(DataSource));
        }
Esempio n. 20
0
        public ActionResult AdminDeleteOrder(int id)
        {
            if (id == 0)
            {
                HttpNotFound();
            }
            {
                OrdersData model = db.Orders.Find(id);
                if (model != null)
                {
                    db.Sales.RemoveRange(db.Sales.Where(m => m.OrderId == model.OrderId).ToList());
                    db.SaveChanges();
                    db.Orders.Remove(model);
                    db.SaveChanges();
                }
            }

            return(RedirectToAction("AllOrdersList"));
        }
Esempio n. 21
0
        public ActionResult PlaceOrder(Cart Cart)
        {
            for (int i = 1; i <= 12; i++)
            {
                if (Cart.Lines.Count() > 0)
                {
                    string     UserId      = User.Identity.GetUserId();
                    OrdersData Ordersmodel = new OrdersData();
                    Ordersmodel.UserId        = User.Identity.GetUserId();
                    Ordersmodel.Email         = User.Identity.GetUserName();
                    Ordersmodel.OrderId       = (User.Identity.GetUserId() + DateTime.Now.AddMonths(-i)).Replace(@":", "");
                    Ordersmodel.CurrentDate   = DateTime.Now.AddMonths(-i);
                    Ordersmodel.TotalPurchase = Cart.CompleteTotalValue();
                    Ordersmodel.ProductsCount = Cart.Lines.Count();
                    Ordersmodel.OrderId       = Ordersmodel.OrderId.Replace(@"/", "");
                    db.Orders.Add(Ordersmodel);
                    db.SaveChanges();

                    SalesModel Sales = new SalesModel();

                    foreach (var item in Cart.Lines)
                    {
                        Sales.OrderId      = Ordersmodel.OrderId;
                        Sales.Catagory     = item.Products.Catagory;
                        Sales.Description  = item.Products.Description;
                        Sales.ProductId    = item.Products.ID;
                        Sales.Name         = item.Products.Name;
                        Sales.Price        = item.Products.Price;
                        Sales.Quantity     = item.Quantity;
                        Sales.UserId       = db.Users.Where(m => m.Id == UserId).SingleOrDefault();
                        Sales.ProductTotal = item.Products.Price * item.Quantity;
                        db.Sales.Add(Sales);
                        db.SaveChanges();
                        Product product = db.Products.Where(m => m.ID == item.Products.ID).SingleOrDefault();
                        product.ProductSaleCount = product.ProductSaleCount + item.Quantity;
                        db.SaveChanges();
                    }
                }
            }
            Cart.Clear();
            return(RedirectToAction("OrderMessage", "Cart"));
        }
Esempio n. 22
0
        public IHttpActionResult GetByType(string userId = "1")
        {
            int id = Convert.ToInt32(userId);
            List <OrdersGetVM> vm     = new List <OrdersGetVM>();
            List <Orders>      orders = dm.Orders.Where(x => x.UserID == id).OrderByDescending(x => x.OrderDate).ToList();

            foreach (var item in orders)
            {
                OrdersGetVM orderVM = new OrdersGetVM();

                OrdersData orderData = dm.OrdersData.Where(x => x.OrderDataID == item.OrderDataID).FirstOrDefault();

                orderVM.OrderID    = item.OrderID;
                orderVM.Date       = Convert.ToDateTime(item.OrderDate).ToShortDateString() + Convert.ToDateTime(item.OrderDate).ToShortTimeString();
                orderVM.TotalPrice = item.TotalPrice;
                orderVM.OrderData  = new OrderDataVM()
                {
                    City            = orderData.City,
                    Company         = orderData.Company,
                    DeliveryAddress = orderData.DeliveryAddress,
                    DeliveryMethod  = dm.DeliveryMethods.Where(x => x.DeliveryMethodID == orderData.DeliveryMethodID).FirstOrDefault().MethodName,
                    FullName        = orderData.FullName
                };


                orderVM.Items = new List <ItemsVM>();
                foreach (var orderitem in dm.OrdersItems.Where(x => x.OrderID == item.OrderID))
                {
                    orderVM.Items.Add(new ItemsVM()
                    {
                        Name   = dm.Items.Where(x => x.ItemID == orderitem.ItemID).FirstOrDefault().ItemName,
                        Price  = dm.Items.Where(x => x.ItemID == orderitem.ItemID).FirstOrDefault().Price,
                        Amount = orderitem.Amount
                    });
                }

                vm.Add(orderVM);
            }


            return(Ok(vm));
        }
Esempio n. 23
0
 private void ExecuteReverseOrder(object obj)
 {
     try
     {
         var        client = obj as ClientModel;
         OrdersData data   = new OrdersData();
         var        orders = data.GetOrderByClientId(new
         {
             ClientId = client.Id
         });
         orders.ForEach(x => data.ReverseOrders(x));
         RefreshView();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Message: \n" + ex.Message + '\n' +
                         "StackTrase: \n" + ex.StackTrace + '\n' +
                         "InnerException: \n" + ex.InnerException);
     }
 }
Esempio n. 24
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Don't forget to create the 'rewards' database and execute the sql ..\SQLScripts\CreateTablesAndPopulate.sql script
            // to make the initial migration and seeding



            string yolo = Request.QueryString["yolo"];

            if (yolo == "hi")
            {
                throw new Exception();
            }

            var cid = -1;

            if (Page.IsPostBack)
            {
                cid = int.Parse(CustomerId.Value);
            }

            var orders = OrdersData.GetOrders(5);

            orderList.DataSource = orders;
            orderList.DataBind();

            if (cid == -1)
            {
                var defaultCustomer = CustomerData.GetDefaultCustomer();
                MapCustomer(defaultCustomer);
            }
            else
            {
                var customer = CustomerData.GetCustomerById(cid);
                MapCustomer(customer);
            }


            lblCheckbox.Attributes.Add("for", EnrollCheckbox.ClientID);
        }
Esempio n. 25
0
        public IHttpActionResult PostOrders([FromBody] OrdersPostVM obj)
        {
            OrdersData ordersData = new OrdersData()
            {
                City             = obj.orderData.city,
                Company          = obj.orderData.company,
                DeliveryAddress  = obj.orderData.address,
                DeliveryMethodID = Convert.ToInt32(obj.orderData.deliveryMethod),
                FullName         = obj.orderData.name
            };

            ordersData = dm.OrdersData.Add(ordersData);
            dm.SaveChanges();

            Orders order = new Orders()
            {
                OrderDate   = obj.date,
                OrderDataID = ordersData.OrderDataID,
                TotalPrice  = obj.price,
                UserID      = Convert.ToInt32(obj.userId)
            };

            order = dm.Orders.Add(order);
            dm.SaveChanges();

            foreach (var item in obj.orderItems)
            {
                dm.OrdersItems.Add(new OrdersItems()
                {
                    OrderID = order.OrderID,
                    ItemID  = Convert.ToInt32(item.itemId),
                    Amount  = item.value
                });
            }
            dm.SaveChanges();

            return(Ok(obj));
        }
Esempio n. 26
0
        private Task OnReceive(string message)
        {
            var         jObject    = JObject.Parse(message);
            string      stream     = jObject.Value <string>("stream");
            IStreamData streamData = null;

            if (stream == websocket.stream.Topic.ToTopic(ETopic.Orders))
            {
                streamData = new OrdersData {
                    Orders = JsonConvert.DeserializeObject <Payload <List <Order> > >(message).Data
                };
            }
            else if (stream == websocket.stream.Topic.ToTopic(ETopic.Accounts))
            {
                streamData = new AccountsData {
                    Accounts = JsonConvert.DeserializeObject <Payload <List <Account> > >(message).Data
                };
            }
            else if (stream == websocket.stream.Topic.ToTopic(ETopic.Transfers))
            {
                streamData = JsonConvert.DeserializeObject <Payload <TransfersData> >(message).Data;
            }
            else if (stream == websocket.stream.Topic.ToTopic(ETopic.Trades))
            {
                streamData = new TradesData {
                    Trades = JsonConvert.DeserializeObject <Payload <List <Trade> > >(message).Data
                };
            }
            else if (stream == websocket.stream.Topic.ToTopic(ETopic.MarketDiff))
            {
                streamData = JsonConvert.DeserializeObject <Payload <MarketDiff> >(message).Data;
            }
            else if (stream == websocket.stream.Topic.ToTopic(ETopic.MarketDepth))
            {
                streamData = JsonConvert.DeserializeObject <Payload <MarketDepth> >(message).Data;
            }
            else if (stream == websocket.stream.Topic.ToTopic(ETopic.KLine))
            {
                streamData = JsonConvert.DeserializeObject <Payload <KLine> >(message).Data;
            }
            else if (stream == websocket.stream.Topic.ToTopic(ETopic.Ticker))
            {
                streamData = JsonConvert.DeserializeObject <Payload <Ticker> >(message).Data;
            }
            else if (stream == websocket.stream.Topic.ToTopic(ETopic.AllTickers))
            {
                streamData = new AllTickersData {
                    AllTickers = JsonConvert.DeserializeObject <Payload <List <Ticker> > >(message).Data
                };
            }
            else if (stream == websocket.stream.Topic.ToTopic(ETopic.MiniTicker))
            {
                streamData = JsonConvert.DeserializeObject <Payload <MiniTicker> >(message).Data;
            }
            else if (stream == websocket.stream.Topic.ToTopic(ETopic.AllMiniTickers))
            {
                streamData = new AllMiniTickersData {
                    AllMiniTickers = JsonConvert.DeserializeObject <Payload <List <MiniTicker> > >(message).Data
                };
            }
            else if (stream == websocket.stream.Topic.ToTopic(ETopic.Blockheight))
            {
                streamData = JsonConvert.DeserializeObject <Payload <Blockheight> >(message).Data;
            }
            else
            {
                throw new WebSocketException($"Unhandled topic stream: {stream}");
            }
            StreamData(this, streamData);
            return(Task.CompletedTask);
        }
        public ActionResult View_Trend_Analysis(string searchStr, int?page, int?depId)
        {
            Dictionary <int, Dictionary <string, int> > trendlist = new Dictionary <int, Dictionary <string, int> >();


            List <string> monlist = new List <string>();

            for (int i = 11; i >= 0; i--)
            {
                //string dt = string.Format("{0}/{1}", DateTime.Today.AddMonths(-i).Month, DateTime.Today.AddMonths(-i).Year);
                string dt = DateTime.Today.AddMonths(-i).ToString("MM/yyyy");
                monlist.Add(dt);
            }


            List <item> listitem   = ItemData.FindAll(); //get all items
            List <item> resultlist = new List <item>();



            IPagedList <item> resultlist1;
            bool match = false;

            if (searchStr == null || searchStr == "")
            {
                searchStr   = "";
                resultlist1 = listitem.ToPagedList(page ?? 1, 7);
            }
            else
            {
                foreach (item Pro in listitem)
                {
                    bool fit = false;
                    if (Search.Found(Pro.item_description, searchStr).fit)
                    {
                        fit = true;
                        Pro.item_description = Search.Found(Pro.item_description, searchStr).str;
                    }

                    if (fit)
                    {
                        match = true; resultlist.Add(Pro);
                    }
                }
                resultlist1 = resultlist.ToPagedList(page ?? 1, 7);
            }

            ViewBag.listitem = resultlist1;

            ViewData["searchStr"] = searchStr;
            ViewData["match"]     = match;

            /////////////////////////////////////////////////////////////



            /////////////////////////////////////////////////////////////////////////////////////////////////////////////
            //get the consumed quant of last 12 months in searched list, put in a dictionary, key is month, value is quant.
            /////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            List <orders> listorders = new List <orders>();

            listorders = OrdersData.GetAllDeliveredOrders();

            int           dId         = depId ?? 0;
            List <orders> listorders1 = new List <orders>();

            if (dId != 0)
            {
                listorders1    = listorders.Where(x => x.staff_obj.department_obj.departmentId == dId).ToList();
                ViewBag.depart = DepartmentData.GetDepartmentById(dId);
            }
            else
            {
                listorders1 = listorders;
            }

            foreach (item item in resultlist1)
            {
                Dictionary <string, int> itemsbtrend = new Dictionary <string, int>();
                Dictionary <string, int> itemtrend   = new Dictionary <string, int>();

                foreach (string m in monlist)
                {
                    char[]   separator   = { '/', ' ' };
                    string[] dtmonthyear = m.Split(separator);
                    //Get monthly consumption quant on given month
                    int consumedquant = listorders1.Where(x => x.delivered_order_date.Split(separator)[0].Equals(dtmonthyear[0]) && x.delivered_order_date.Split(separator)[2].Equals(dtmonthyear[1])).Select(x => x.actual_received_quantity_by_representative).Sum();//Get correct value here
                    itemtrend.Add(m, consumedquant);
                }
                trendlist.Add(item.itemId, itemtrend);
            }


            ViewBag.departList   = DepartmentData.GetAllDep();
            ViewBag.trendlist    = trendlist;
            ViewBag.monthslist   = monlist;
            Session["trendlist"] = trendlist;

            return(View());
        }
        /////////////////////////////////////////////////////////Trend Report
        public async Task <ActionResult> View_Trend_Analysis_Detail(int itemId, int?depId)
        {
            List <orders> listorders = new List <orders>();

            listorders = OrdersData.GetAllDeliveredOrders();

            int           dId         = depId ?? 0;
            List <orders> listorders1 = new List <orders>();

            if (dId != 0)
            {
                listorders1    = listorders.Where(x => x.staff_obj.department_obj.departmentId == dId).ToList();
                ViewBag.depart = DepartmentData.GetDepartmentById(dId);
            }
            else
            {
                listorders1 = listorders;
            }


            Dictionary <string, int> itemsbtrend = new Dictionary <string, int>();
            Dictionary <string, int> itemtrend   = new Dictionary <string, int>();



            Dictionary <int, Dictionary <string, int> > trendlist = (Dictionary <int, Dictionary <string, int> >)Session["trendlist"];
            item          item    = ItemData.GetItemById(itemId); // get the item by given itemId
            List <string> monlist = new List <string>();


            for (int i = 11; i >= 0; i--)
            {
                //string dt = string.Format("{0}/{1}", DateTime.Today.AddMonths(-i).Month, DateTime.Today.AddMonths(-i).Year);
                string dt = DateTime.Today.AddMonths(-i).ToString("MM/yyyy");
                monlist.Add(dt);//list of last 12 months
                /////////////////////////////////////////////////////////////////////////
                //Get stockbalance on given month, put in dictionary "itemsbtrend", key is month string, value is stockbalance of the month.
                //////////////////////////////////////////////////////////////////

                char[] separator = { '/', ' ' };



                List <stock_card> list = StockcardData.GetStockCardByItemId(itemId);//give proper value here.


                List <stock_card> mlist = list.Where(x => x.Arrival_Date.Split(separator)[0].Equals(dt.Split(separator)[0]) && x.Arrival_Date.Split(separator)[2].Equals(dt.Split(separator)[1])).ToList();
                int stockbalance        = mlist[mlist.Count - 1].stockbalance;
                itemsbtrend.Add(dt, stockbalance);
            }

            int[] cons = trendlist[itemId].Values.ToArray();


            foreach (string m in monlist)
            {
                char[]   separator   = { '/', ' ' };
                string[] dtmonthyear = m.Split(separator);
                //Get monthly consumption quant on given month
                int consumedquant = listorders1.Where(x => x.delivered_order_date.Split(separator)[0].Equals(dtmonthyear[0]) && x.delivered_order_date.Split(separator)[2].Equals(dtmonthyear[1])).Select(x => x.actual_received_quantity_by_representative).Sum();//Get correct value here
                itemtrend.Add(m, consumedquant);
            }


            // send request and get response from python server
            int[] prelist  = new int[4];
            int[] paralist = new int[13];
            paralist[0] = itemId;
            for (int i = 1; i < 13; i++)
            {
                paralist[i] = cons[i - 1];
            }
            string conshist = string.Join(", ", paralist);


            using (var client = new HttpClient())
            {
                string xValue = conshist;


                // send a GET request to the server uri with the data and get the response as HttpResponseMessage object
                HttpResponseMessage res = await client.GetAsync("http://127.0.0.1:5000/model1?x=" + xValue);

                // Return the result from the server if the status code is 200 (everything is OK)
                // should raise exception or error if it's not
                if (res.IsSuccessStatusCode)
                {
                    // pass the result to update the user preference
                    // have to read as string for the data in response.body
                    //pre = Convert.ToInt32(res.Content.ReadAsStringAsync().Result); //if only display one month prediction.
                    string arr = res.Content.ReadAsStringAsync().Result;
                    prelist = arr.Split(',').Select(str => int.Parse(str)).ToArray();
                }
                else
                {
                    prelist = new int[4] {
                        0, 0, 0, 0
                    }
                };
            }

            items_warehouse iwh = ItemWarehouseData.FindByItemId(itemId);

            ViewBag.departList    = DepartmentData.GetAllDep();
            ViewBag.cons          = itemtrend.Values.ToArray();
            ViewBag.months        = monlist.ToArray();
            ViewBag.Item          = item;
            ViewBag.sbalance      = itemsbtrend.Values.ToArray();
            ViewBag.prediction    = prelist;
            ViewBag.itemwarehouse = iwh;
            return(View());
        }
Esempio n. 29
0
 public static void PushOrdersDataInHub(int Symbol, OrdersData Orders)
 {
 }