Exemplo n.º 1
0
        public List <OrdersViewModel> getOrdersViewModel()
        {
            var list = ordersList.Select(s => new { s.id, s.address, s.country, s.ordered, s.qteOfProduct, s.shipped, s.status, s.totalPrice, s.Admin, s.Stock, s.Provider }).ToList();

            List <OrdersViewModel> orders = new List <OrdersViewModel>();
            int pending = 0;
            int recived = 0;

            foreach (var s in list)
            {
                //Console.WriteLine(s.Admin1.firstName);
                GestionUser     gu = new GestionUser();
                GestionStock    gs = new GestionStock();
                GestionProvider gp = new GestionProvider();

                commande cm = new commande {
                    id = s.id, Admin = s.Admin, Stock = s.Stock, Provider = s.Provider, address = s.address, country = s.country, ordered = s.ordered, qteOfProduct = s.qteOfProduct, shipped = s.shipped, status = s.status, totalPrice = s.totalPrice
                };
                if (cm.status == 0)
                {
                    pending++;
                }
                else
                {
                    recived++;
                }
                user     a  = gu.FindById(cm.Admin.GetValueOrDefault());
                stock    st = gs.FindById(cm.Stock.GetValueOrDefault());
                provider p  = gp.FindById(cm.Provider.GetValueOrDefault());

                orders.Add(new OrdersViewModel {
                    Cmd = cm, AdminName = a.FullName, ProviderName = p.nom, StockType = st.stockType
                });
            }
            OrdersViewModel.pending = pending;
            OrdersViewModel.recived = recived;
            return(orders);
        }
Exemplo n.º 2
0
        public ActionResult Login(AccountViewModel avm)
        {
            if (string.IsNullOrEmpty(avm.Username) || string.IsNullOrEmpty(avm.Password))
            {
                ViewBag.Error = "Invalid Account";
                return(View("Index"));
            }

            string token = gu.callLogin(avm.Username, avm.Password).Result;

            if (token == null)
            {
                ViewBag.Error = "Invalid Account";
                return(View("Index"));
            }
            SessionPersister.User  = gu.GetUserByToken(token);
            SessionPersister.Token = token;

            ViewBag.test = JsonConvert.SerializeObject(gu.FindById(1), Formatting.Indented);
            user u = SessionPersister.User;

            return(View("Success"));
        }