示例#1
0
        public ActionResult Create(HttpPostedFileBase postedFile, Market market)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (postedFile != null && ProductsContainer.validateImage(postedFile.FileName))
                    {
                        var filename = "img_" + market.Denumire.ToLower() + ".png";
                        var path     = Path.Combine(Server.MapPath("~/Content/ProductsImages/"), filename);
                        postedFile.SaveAs(path);
                        market.Imagine = "img_" + market.Denumire.ToLower();
                    }

                    MarketContainer.SaveMarket(market);

                    return(RedirectToAction("Index"));
                }
                var model = new MarketModel();
                model.Market = market;

                return(View(model));
            }catch (Exception ex)
            {
                return(View());
            }
        }
示例#2
0
        // GET: Deliveries/Create
        public ActionResult Create()
        {
            var model = new EmployeeModel();

            model.Markets = MarketContainer.GetMarkets();

            return(View(model));
        }
示例#3
0
        public ActionResult Create()
        {
            var model = new ProductModel();

            model.Categories = CategoryContainer.GetCategories();
            model.Markets    = MarketContainer.GetMarkets();
            return(View(model));
        }
示例#4
0
        public ActionResult Create()
        {
            var model = new DeliveryModel();

            model.Markets   = MarketContainer.GetMarkets();
            model.Suppliers = SupplierContainer.GetSuppliers();

            return(View(model));
        }
示例#5
0
        // GET: Suppliers
        public ActionResult Index()
        {
            var employees = EmployeeContainer.GetEmployees();
            var markets   = MarketContainer.GetMarkets();

            foreach (var emp in employees)
            {
                emp.MarketName = markets.FirstOrDefault(x => x.ID == emp.MagazinID).Denumire;
            }

            return(View(employees));
        }
示例#6
0
        // GET: Deliveries/Delete/5
        public ActionResult Delete(int id)
        {
            if (id < 1)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            string serverpath = Server.MapPath("~/Content/ProductsImages/");

            MarketContainer.DeleteMatket(id, serverpath);

            return(RedirectToAction("Index"));
        }
示例#7
0
        // GET: Deliveries/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var model = new MarketModel();

            model.Market = MarketContainer.getMarketById((int)id);

            return(View(model));
        }
示例#8
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));
        }
示例#9
0
        public ActionResult Index()
        {
            var products   = ProductsContainer.GetProducts();
            var categories = CategoryContainer.GetCategories();
            var markets    = MarketContainer.GetMarkets();

            foreach (var prod in products)
            {
                prod.CategoryName = categories.Where(el => el.ID == prod.CategorieID).FirstOrDefault().Nume;
                prod.MarketName   = markets.Where(el => el.ID == prod.MagazinID).FirstOrDefault().Denumire;
            }

            return(View(products));
        }
示例#10
0
        public ActionResult Create(Employee employee)
        {
            if (ModelState.IsValid)
            {
                EmployeeContainer.SaveEmployee(employee);
                return(RedirectToAction("Index"));
            }
            var model = new EmployeeModel();

            model.Employee = employee;
            model.Markets  = MarketContainer.GetMarkets();

            return(View(model));
        }
示例#11
0
        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));
        }
示例#12
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));
        }
示例#13
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var model = new ProductModel();

            model.Product    = ProductsContainer.getProductById((int)id);
            model.Categories = CategoryContainer.GetCategories();
            model.Markets    = MarketContainer.GetMarkets();

            return(View(model));
        }
示例#14
0
        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));
        }
示例#15
0
        public ActionResult Create(Employee employee)
        {
            if (ModelState.IsValid)
            {
                if ((int)Session["role"] > SessionAccessor.getUserRole(employee.Functie))
                {
                    EmployeeContainer.SaveEmployee(employee);
                    return(RedirectToAction("Index"));
                }
            }
            var model = new EmployeeModel();

            model.Employee = employee;
            model.Markets  = MarketContainer.GetMarkets();

            return(View(model));
        }
示例#16
0
        public ActionResult Edit(HttpPostedFileBase postedFile, Market market)
        {
            if (ModelState.IsValid)
            {
                if (postedFile != null)
                {
                    var filename = "img_" + market.Denumire.ToLower() + ".png";
                    var path     = Path.Combine(Server.MapPath("~/Content/ProductsImages/"), filename);
                    postedFile.SaveAs(path);
                    market.Imagine = "img_" + market.Denumire.ToLower();
                }

                MarketContainer.SaveMarket(market);
                return(RedirectToAction("Index"));
            }

            return(View(market));
        }
示例#17
0
        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));
        }
示例#18
0
 public ActionResult Edit(HttpPostedFileBase postedFile, ProductModel model)
 {
     if (ModelState.IsValid)
     {
         if (postedFile != null)
         {
             var filename = "img_" + model.Product.Denumire.ToLower().Replace(' ', '_') + ".png";
             var path     = Path.Combine(Server.MapPath("~/Content/ProductsImages/"), filename);
             postedFile.SaveAs(path);
             model.Product.Imagine = "img_" + model.Product.Denumire.ToLower().Replace(' ', '_');
         }
         if (model.Product.Pret > 0 && model.Product.Cantitate > 0)
         {
             ProductsContainer.SaveProduct(model.Product);
             return(RedirectToAction("Index"));
         }
     }
     model.Categories = CategoryContainer.GetCategories();
     model.Markets    = MarketContainer.GetMarkets();
     return(View(model));
 }
示例#19
0
        // GET: Suppliers
        public ActionResult Index()
        {
            var markets = MarketContainer.GetMarkets();

            return(View(markets));
        }
示例#20
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));
        }