Esempio n. 1
0
        public ActionResult Delete(int id)
        {
            if (id < 1)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DeliveryContainer.DeleteDelivery(id);

            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
        public ActionResult Edit(Delivery delivery)
        {
            if (ModelState.IsValid)
            {
                DeliveryContainer.SaveDelivery(delivery);
                return(RedirectToAction("Index"));
            }

            return(View(delivery));
        }
Esempio n. 3
0
        public ActionResult Create(Delivery delivery)
        {
            if (ModelState.IsValid)
            {
                delivery.Status         = "Initiata";
                delivery.DataSolicitare = DateTime.Now;
                DeliveryContainer.SaveDelivery(delivery);
                return(RedirectToAction("Index"));
            }
            var model = new DeliveryModel();

            model.Delivery = delivery;
            return(View(model));
        }
Esempio n. 4
0
        public ActionResult Index()
        {
            var markets   = MarketContainer.GetMarkets();
            var suppliers = SupplierContainer.GetSuppliers();
            var delivery  = DeliveryContainer.GetDeliveries();

            foreach (var del in delivery)
            {
                del.SupplierName = suppliers.FirstOrDefault(x => x.ID == del.FurnizorID).Nume;
                del.MarketName   = markets.FirstOrDefault(x => x.ID == del.MagazinID).Denumire;
            }

            return(View(delivery));
        }
Esempio n. 5
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var model = new DeliveryModel();

            model.Delivery  = DeliveryContainer.getDeliveryById((int)id);
            model.Markets   = MarketContainer.GetMarkets();
            model.Suppliers = SupplierContainer.GetSuppliers();

            return(View(model));
        }
        public ActionResult Edit(Delivery delivery)
        {
            if (ModelState.IsValid && DeliveriesController.validateStatus((int)Session["role"], delivery.Status))
            {
                DeliveryContainer.SaveDelivery(delivery);
                return(RedirectToAction("Index"));
            }

            var model = new DeliveryModel();

            model.Delivery  = delivery;
            model.Suppliers = SupplierContainer.GetSuppliers();
            model.Markets   = MarketContainer.GetMarkets();
            return(View(model));
        }
        public ActionResult Create(Delivery delivery)
        {
            if (ModelState.IsValid)
            {
                delivery.Status         = delivery.Status != null ? delivery.Status : "Initiata";
                delivery.DataSolicitare = DateTime.Now;
                DeliveryContainer.SaveDelivery(delivery);
                return(RedirectToAction("Index"));
            }
            var model = new DeliveryModel();

            model.Delivery  = delivery;
            model.Suppliers = SupplierContainer.GetSuppliers();
            model.Markets   = MarketContainer.GetMarkets();
            return(View(model));
        }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var model = new DeliveryModel();

            model.Delivery = DeliveryContainer.getDeliveryById((int)id);
            if ((int)Session["role"] != 3)
            {
                model.Statuses.Remove("Refuzata");
            }
            model.Markets   = MarketContainer.GetMarkets();
            model.Suppliers = SupplierContainer.GetSuppliers();

            return(View(model));
        }
Esempio n. 9
0
        static Transport[] PrepareTransports()
        {
            DataProvider dataProvider = new DataProvider();
            // Pack containers
            var c1 = new DeliveryContainer();

            c1.PackContainer(new[] {
                dataProvider.OrderItems[0],
                dataProvider.OrderItems[1],
                dataProvider.OrderItems[2],
                dataProvider.OrderItems[3],
                dataProvider.OrderItems[4]
            });
            var c2 = new DeliveryContainer();

            c2.PackContainer(new[] {
                dataProvider.OrderItems[5],
                dataProvider.OrderItems[6],
                dataProvider.OrderItems[7]
            });
            var c3 = new DeliveryContainer();

            c3.PackContainer(new[] {
                dataProvider.OrderItems[8],
                dataProvider.OrderItems[9],
                dataProvider.OrderItems[10],
                dataProvider.OrderItems[11]
            });
            var c4 = new DeliveryContainer();

            c4.PackContainer(new[] {
                dataProvider.OrderItems[12],
                dataProvider.OrderItems[13]
            });
            var c5 = new DeliveryContainer();

            c5.PackContainer(new[] {
                dataProvider.OrderItems[14],
                dataProvider.OrderItems[15]
            });

            // Set up delivery orders
            var o1 = new DeliveryOrder(
                new[] { c1, c2 },
                dataProvider.Accounts[0],
                dataProvider.Accounts[0].AccountManager,
                dataProvider.Addresses[0]);
            var o2 = new DeliveryOrder(
                new[] { c3, c4 },
                dataProvider.Accounts[1],
                dataProvider.Accounts[1].AccountManager,
                dataProvider.Addresses[1]);
            var o3 = new DeliveryOrder(
                new[] { c5 },
                dataProvider.Accounts[2],
                dataProvider.Accounts[2].AccountManager,
                dataProvider.Addresses[2]);

            // Set up transports
            var t1 = new Transport();
            var t2 = new Transport();

            t1.Load(new[] { o1, o2 });
            t2.Load(new[] { o3 });

            return(new[] { t1, t2 });
        }
Esempio n. 10
0
        public ActionResult Home()
        {
            if (SessionAccessor.LoggedUser == null)
            {
                return(RedirectToAction("Login"));
            }

            var model = new HomeModel();

            switch (SessionAccessor.getUserRole())
            {
            case 0:      // Funizor
                var pendingDeliveries = DeliveryContainer.getNrOfPendingDeliveries();
                model.dashboardMessage1 = "Aveti de făcut " + pendingDeliveries + (pendingDeliveries > 1 ? " livrari" : " livrare");
                var initiatedDeliveries = DeliveryContainer.getNrOfInitiatedDeliveries();
                var deliveredDeliveries = DeliveryContainer.getNrOfDeliveredDeliveries();
                var refusedDeliveries   = DeliveryContainer.getNrOfRefusedDeliveries();
                model.chart = "" + initiatedDeliveries + "," + pendingDeliveries + "," + deliveredDeliveries + "," + refusedDeliveries;
                break;

            case 1:      // Angajat
                var totalCategories = CategoryContainer.getNrOfCategories();
                model.dashboardMessage1 = "Gestionaţi " + totalCategories + (totalCategories > 1 ? " categorii" : " categorie");
                var primaryCategories = CategoryContainer.getNrOfPrimaryCategories();
                model.chart = "" + primaryCategories + "," + (totalCategories - primaryCategories);

                var totalProducts = ProductsContainer.getNrOfProducts();
                model.dashboardMessage2 = "Gestionaţi " + totalProducts + (totalProducts > 1 ? " produse" : " produs");

                var products3  = ProductsContainer.getNrOfProductsExpiredDays(3);
                var products7  = ProductsContainer.getNrOfProductsExpiredDays(7);
                var products30 = ProductsContainer.getNrOfProductsExpiredDays(30);
                var products0  = ProductsContainer.getNrOfProductsExpired();
                model.chart2 = "" + products3 + "," + products7 + "," + products30 + "," + products0;
                break;

            case 2:      // Manager
                var pendingDeliveries2   = DeliveryContainer.getNrOfPendingDeliveries();
                var initiatedDeliveries2 = DeliveryContainer.getNrOfInitiatedDeliveries();
                var deliveredDeliveries2 = DeliveryContainer.getNrOfDeliveredDeliveries();
                var refusedDeliveries2   = DeliveryContainer.getNrOfRefusedDeliveries();
                model.dashboardMessage1 = "Aveti " + deliveredDeliveries2 + (deliveredDeliveries2 > 1 ? " livrari" : " livrare") + " efectuate";
                model.chart             = "" + initiatedDeliveries2 + "," + pendingDeliveries2 + "," + deliveredDeliveries2 + "," + refusedDeliveries2;

                var nrEmployees = EmployeeContainer.getNrOfEmployees();
                var nrManagers  = EmployeeContainer.getNrOfEmployees();
                var nrBosses    = EmployeeContainer.getNrOfBosses();
                var nrSuppliers = EmployeeContainer.getNrOfEmployees();
                model.dashboardMessage2 = "Sunteţi manager pentru " + nrEmployees + (nrEmployees > 1 ? " angajaţi" : " angajat");
                model.chart2            = "" + nrEmployees + "," + nrManagers + "," + nrBosses + "," + nrSuppliers;
                break;

            case 3:      // sef
                var suppliers = SupplierContainer.getNrOfSuppliers();
                var cities    = SupplierContainer.getTopSuppliersCities(5);

                model.chart  = "";
                model.cities = "";
                foreach (var city in cities)
                {
                    model.cities += city + ',';
                    model.chart  += SupplierContainer.getNrOfSupplierByCity(city).ToString() + ",";
                }
                if (model.cities.Length > 1)
                {
                    model.cities = model.cities.Substring(0, model.cities.Length - 1);
                }
                if (model.chart.Length > 1)
                {
                    model.chart = model.chart.Substring(0, model.chart.Length - 1);
                }
                model.dashboardMessage1 = "Aveti " + suppliers + (suppliers > 1 ? " furnizori" : " furnizor");

                var markets       = MarketContainer.getNrOfMarkets();
                var marketsCities = MarketContainer.getTopMarketsCities(5);
                model.chart2  = "";
                model.cities2 = "";
                foreach (var city in marketsCities)
                {
                    model.cities2 += city + ',';
                    model.chart2  += MarketContainer.getNrOfMarketsByCity(city).ToString() + ",";
                }
                model.cities2 = model.cities2.Substring(0, model.cities2.Length - 1);
                model.chart2  = model.chart2.Substring(0, model.chart2.Length - 1);

                model.dashboardMessage2 = "Aveti " + markets + (markets > 1 ? " magazine" : " magazin");
                break;
            }

            return(View(model));
        }