示例#1
0
        public ActionResult DisplayOrders(FormCollection fc)
        {
            int orderID = 0;

            try
            {
                orderID = Convert.ToInt32(fc["OrderId"]);
            }
            catch (FormatException)
            {
                return(Content("<html></html>"));
            }

            int?currentCustomerId = (int)Session["AccountId"];

            if (currentCustomerId == null)
            {
                return(Content("<html></html>"));
            }

            Client       currentCustomer = _clientProfileControl.GetClient((int)currentCustomerId);
            ClientOrders order           = currentCustomer.ClientOrders.FirstOrDefault(o => o.Id == orderID);

            ViewBag.OrderId = order.Id;
            OrderModel um = new OrderModel {
                ClientOrders = order
            };

            return(View(um));
        }
示例#2
0
        public ActionResult RepeatTheOrder(int orderId)
        {
            var          customer     = _clientProfileControl.GetClient((int)Session["AccountId"]);
            ClientOrders cleintOrders = customer.ClientOrders.FirstOrDefault(o => o.Id == orderId);

            if (cleintOrders == null)
            {
                return(View("Cart", (Cart)Session["Cart"]));
            }

            Item newItem;

            foreach (var item in cleintOrders.Cart.ItemsInCart)
            {
                newItem = _itemDistributionControl.GetItem(item.Item.Id);
                if (newItem != null)
                {
                    FormCollection fc = new FormCollection
                    {
                        ["itemId"]   = Convert.ToString(newItem.Id),
                        ["quantity"] = Convert.ToString(item.Quantity)
                    };
                    AddItemToCart(fc);
                }
            }

            return(View("Cart", (Cart)Session["Cart"]));
        }
示例#3
0
        public async Task <IActionResult> Edit(Guid id, [Bind("Id,IdClient,IdOrder")] ClientOrders clientOrders)
        {
            if (id != clientOrders.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(clientOrders);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClientOrdersExists(clientOrders.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdClient"] = new SelectList(_context.Clients, "Id", "Id", clientOrders.IdClient);
            ViewData["IdOrder"]  = new SelectList(_context.Orders, "Id", "Id", clientOrders.IdOrder);
            return(View(clientOrders));
        }
示例#4
0
        public List <ILimitOrder> GetClientLimitOrders(int clientId)
        {
            if (!ClientOrders.ContainsKey(clientId))
            {
                return(new List <ILimitOrder>());
            }

            return(ClientOrders[clientId]);
        }
示例#5
0
        private void refreshItem(Models.Models.ClientOrder clientOrder)
        {
            int index = ClientOrders.IndexOf(clientOrder);

            if (index > 0)
            {
                ClientOrders.RemoveAt(index);
                ClientOrders.Insert(index, clientOrder);
            }
        }
示例#6
0
        public OperationResponse <List <ClientOrders> > GetHistoryOrders(decimal delivertClientID)
        {
            OperationResponse <List <ClientOrders> > or = new OperationResponse <List <ClientOrders> >();

            try
            {
                //get headers with client id  and details with headerID
                // get customer headers of orders
                var result = context.PoscurrentDailyTransHeader.Where(h => h.ClientId == delivertClientID && h.FkInvoiceStatusId == 4 /*old*/).Select(h => new PoscurrentDailyTransHeader()
                {
                    HeaderId           = h.HeaderId,
                    InsDate            = h.InsDate,
                    Total              = h.Total,
                    SubTotal           = h.SubTotal,
                    Discount           = h.Discount,
                    DeliveryAmount     = h.DeliveryAmount,
                    Notes              = h.Notes,
                    ClientId           = h.ClientId,
                    SalesRepId         = h.SalesRepId,
                    SalesRepName       = h.SalesRepName,
                    FkInvoiceStatusId  = h.FkInvoiceStatusId,
                    FkDeliveryStatusId = h.FkDeliveryStatusId,

                    PoscurrentDailyTransDetails = h.PoscurrentDailyTransDetails.ToList()
                }).OrderByDescending(a => a.InsDate);
                List <ClientOrders> clientOrders = new List <ClientOrders>();
                foreach (var item in result)
                {
                    ClientOrders curOrder = new ClientOrders();
                    curOrder.Total                       = item.Total + (item.DeliveryAmount == null?0: item.DeliveryAmount);
                    curOrder.DeliveryFees                = (item.DeliveryAmount == null ? 0 : item.DeliveryAmount);
                    curOrder.HeaderId                    = item.HeaderId;
                    curOrder.ClientId                    = item.ClientId;
                    curOrder.InsDate                     = item.InsDate;
                    curOrder.SalesRepId                  = item.SalesRepId;
                    curOrder.SalesRepName                = item.SalesRepName;
                    curOrder.FkDeliveryStatusId          = item.FkDeliveryStatusId;
                    curOrder.Notes                       = item.Notes;
                    curOrder.POSCurrentDailyTransDetails = new List <CategoryItemWithQnty>();
                    curOrder.POSCurrentDailyTransDetails = context.OrderProducts.AsNoTracking().FromSql($"getOrderDetailsByHeaderID {item.HeaderId}").ToList();
                    clientOrders.Add(curOrder);
                }



                or.Data = clientOrders;
            }
            catch (Exception ex)
            {
                or.HasErrors = true;
                or.Message   = ex.Message;
            }
            return(or);
        }
示例#7
0
        public async Task <IActionResult> Create([Bind("Id,IdClient,IdOrder")] ClientOrders clientOrders)
        {
            if (ModelState.IsValid)
            {
                clientOrders.Id = Guid.NewGuid();
                _context.Add(clientOrders);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdClient"] = new SelectList(_context.Clients, "Id", "Id", clientOrders.IdClient);
            ViewData["IdOrder"]  = new SelectList(_context.Orders, "Id", "Id", clientOrders.IdOrder);
            return(View(clientOrders));
        }
        //[UserAuthorization(ConnectionPage = "~/Admin/Login", Roles = "Admin")]
        public ActionResult ModifyOrderStatus(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ClientOrders order = _orderControl.GetClientOrder(id.Value);

            if (order == null)
            {
                return(HttpNotFound());
            }
            return(View(order));
        }
示例#9
0
        public ActionResult DetailsClient(int id)
        {
            ClientOrders ClientOrders = new ClientOrders();

            try
            {
                ClientOrders.Client = GetClient(id);
                ClientOrders.Orders = OrdersController.GetOrders(id);
                ViewBag.Edit        = false;
            }
            catch (Exception ex)
            {
                ViewBag.Error = ex.Message;
            }
            return(View(ClientOrders));
        }
示例#10
0
 public void CancelAllOrdersMethod()
 {
     Task.Run(() =>
     {
         var orders = ClientOrders.ToArray();
         foreach (var order in orders)
         {
             if (order.Status != "matched")
             {
                 TXmlConnector.ConnectorSendCommand(
                     $"<command id=\"cancelorder\"><transactionid>{order.Transactionid}</transactionid></command>");
             }
         }
         Thread.Sleep(250);
     });
 }
示例#11
0
        private void XmlConnector_OnSendNewOrders(string data)
        {
            var orders =
                (Orders)
                new XmlSerializer(typeof(Orders)).Deserialize(
                    new StringReader(data));

            try
            {
                orders.Order = orders.Order.OrderBy(item => DateTime.Parse(item.Time)).ToList();
            }
            catch
            {
            }
            _dispatcher.Invoke(() => {
                foreach (var order in orders.Order)
                {
                    var found = ClientOrders.FirstOrDefault(item => item.Transactionid == order.Transactionid);

                    if (found == null)
                    {
                        ClientOrders.Insert(0, order);
                    }
                    else
                    {
                        ClientOrders[ClientOrders.IndexOf(found)] = order;
                    }
                }
                foreach (var stoporder in orders.Stoporder)
                {
                    var found = ClientStoporders.FirstOrDefault(item => item.Transactionid == stoporder.Transactionid);
                    if (found == null)
                    {
                        ClientStoporders.Insert(0, stoporder);
                    }
                    else
                    {
                        ClientStoporders[ClientStoporders.IndexOf(found)] = stoporder;
                    }
                }
            });

            ActiveOrders     = ClientOrders.Count(o => o.Status == "active");
            ActiveStoporders = ClientStoporders.Count(o => o.Status == "watching");
        }
示例#12
0
        public ActionResult Save(ClientOrders clientOrders)
        {
            var itemInDb = _context.TableItems.Single(c => c.id == clientOrders.ItemsId);

            if (!ModelState.IsValid)
            {
                var clientOrder = new ClientOrderViewModel()
                {
                    ClientOrders = clientOrders,
                    Client       = _context.TableClients.ToList(),
                    Item         = _context.TableItems.ToList()
                };
                return(View("ClientOrderForm", clientOrder));
            }
            var clientInDb = _context.TableClients.Single(c => c.id == clientOrders.ClientsId);

            if (clientOrders.id == 0)
            {
                clientOrders.bill = clientOrders.quantity * itemInDb.sellingPrice;
                _context.TableClientOrders.Add(clientOrders);
            }

            else
            {
                var clientOrderInDb = _context.TableClientOrders.Single(c => c.id == clientOrders.id);
                itemInDb.quantity         = itemInDb.quantity + clientOrderInDb.quantity;
                clientOrderInDb.ClientsId = clientOrders.ClientsId;
                clientOrderInDb.ItemsId   = clientOrders.ItemsId;
                clientOrderInDb.quantity  = clientOrders.quantity;
                clientOrderInDb.date      = clientOrders.date;
                clientOrderInDb.status    = clientOrders.status;
                clientOrderInDb.bill      = clientOrders.quantity * itemInDb.sellingPrice;
            }
            if (clientOrders.status.Equals("2"))
            {
                clientInDb.balance = clientInDb.balance - clientOrders.bill;
            }
            if (!clientOrders.status.Equals("3"))
            {
                itemInDb.quantity = itemInDb.quantity - clientOrders.quantity;
            }
            _context.SaveChanges();
            return(RedirectToAction("Index", "ClientOrders"));
        }
示例#13
0
        public ILimitOrder NewLimitOrder(string symbol, int clientId, double price, int quantity, WayEnum way)
        {
            if (!ClientOrders.ContainsKey(clientId))
            {
                ClientOrders.Add(clientId, new EditableList <ILimitOrder>());
            }

            ILimitOrder toReturn = new LimitOrder(symbol, quantity, price, way, clientId);

            toReturn.SetExchangeOrderId(globalItemCounter);

            LimitOrders.Add(toReturn.ExchangeOrderId, toReturn);
            ClientOrders[clientId].Add(toReturn);
            toReturn.RegisterDeleteNotificationHandler(HandleDeletedLimitOrder);
            toReturn.RegisterFilledNotification(HandleDeletedLimitOrder);

            globalItemCounter++;
            return(toReturn);
        }
示例#14
0
        public void AddClients(List <Client> clients, int orderId)
        {
            var order = GetById(orderId);

            foreach (var client in clients)
            {
                var clientOrder = new ClientOrders()
                {
                    ClientId = client.Id,
                    Client   = client,
                    OrderId  = orderId,
                    Order    = order
                };

                client.ClientsOrders.Add(clientOrder);
                order.ClientsOrders.Add(clientOrder);
            }

            this.dbContext.SaveChanges();
        }
        public PaymentInformation ConfirmedPresetOrder(
            int clientId,
            Cart cart,
            string cardNumber,
            int expirationYear,
            int expirationMonth,
            string cardHolder,
            string cvv)
        {
            using (var dbContextScope = _dbContextScopeFactory.Create())
            {
                var foundClientObject = _clientRepository.GetClient(clientId);
                if (foundClientObject == null)
                {
                    throw new Exception($"There was no client found with the {clientId} id");
                }

                // Cia irgi reiks prideti likusius duomenis
                foundClientObject.Card.CardNumber          = cardNumber;
                foundClientObject.Card.CardExpirationYear  = expirationYear;
                foundClientObject.Card.CardExpirationMonth = expirationMonth;
                foundClientObject.Card.CardHolder          = cardHolder;
                foundClientObject.Card.CVV = cvv;

                var paymentInformation = _httpPaymentControl.InitializePayment(foundClientObject.Card, cart.CartsPrice);

                ClientOrders order = foundClientObject.ClientOrders.FirstOrDefault(o => o.Cart.Id == cart.Id);
                order.OrderStatus = paymentInformation.OrderStatus;
                _clientRepository.EditClient(foundClientObject);

                // Making card object data default (for now)
                foundClientObject.Card.CardNumber          = "4111111111111111";
                foundClientObject.Card.CardExpirationYear  = 2021;
                foundClientObject.Card.CardExpirationMonth = 1;
                foundClientObject.Card.CardHolder          = "Vardenis Pavardenis";
                foundClientObject.Card.CVV = "111";
                dbContextScope.SaveChanges();
                return(paymentInformation);
            }
        }
        public PaymentInformation ConfirmPayment(int clientId, Cart cart, string cardNumber, int expirationYear, int expirationMonth, string cardHolder, string cvv)
        {
            using (var dbContextScope = _dbContextScopeFactory.Create())
            {
                var foundClientObject = _clientRepository.GetClient(clientId);
                if (foundClientObject == null)
                {
                    throw new Exception($"There was no client found with the {clientId} id");
                }

                // Assigning the values to the required fields of the card
                foundClientObject.Card.CardNumber          = cardNumber;
                foundClientObject.Card.CardExpirationYear  = expirationYear;
                foundClientObject.Card.CardExpirationMonth = expirationMonth;
                foundClientObject.Card.CardHolder          = cardHolder;
                foundClientObject.Card.CVV = cvv;


                var paymentInformation = _httpPaymentControl.InitializePayment(foundClientObject.Card, cart.CartsPrice);

                cart.ItemsInCart.ToList().ForEach(x => x.Item = _itemDistributionControl.GetItem(x.Item.Id));

                var order = new ClientOrders {
                    Cart = cart, OrderDate = DateTime.Now, OrderStatus = paymentInformation.OrderStatus
                };
                foundClientObject.ClientOrders.Add(order);
                _clientRepository.EditClient(foundClientObject);

                // Making cards information default or blank (for now)
                foundClientObject.Card.CardNumber          = "4111111111111111";
                foundClientObject.Card.CardExpirationYear  = 2021;
                foundClientObject.Card.CardExpirationMonth = 1;
                foundClientObject.Card.CardHolder          = "Vardenis Pavardenis";
                foundClientObject.Card.CVV = "111";
                dbContextScope.SaveChanges();
                return(paymentInformation);
            }
        }
 public void EditOrder(ClientOrders clientOrder)
 {
     DbContext.Entry(clientOrder).State = EntityState.Modified;
 }
 public ActionResult ModifyOrderStatus([Bind(Include = "Id, OrderStatus")] ClientOrders order)
 {
     _orderControl.UpdateOrderStatus(order.Id, order.OrderStatus);
     return(RedirectToAction("HandleOrders"));
 }