Exemplo n.º 1
0
        public IActionResult ViewJobs(string filter, string start, string end)
        {
            if (!isAuthenticated())
            {
                return(RedirectToAction("Login", "Auth"));
            }

            ViewData["Filter"] = filter;
            ViewData["Start"]  = DateTime.ParseExact(start, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            ViewData["End"]    = DateTime.ParseExact(end, "dd/MM/yyyy", CultureInfo.InvariantCulture);

            ViewData["Jobs"] = JobProvider.getAllJobs(filter, start, end);

            return(View("View"));
        }
Exemplo n.º 2
0
        // GET
        public IActionResult ViewStockReport(string start, string end)
        {
            if (!isAuthenticated())
            {
                return(RedirectToAction("Login", "Auth"));
            }

            List <Job> jobs = JobProvider.getAllJobs("COMPLETE", start, end);

            List <Part> parts = PartsProvider.getParts();

            Dictionary <Part, int> orders = PartsProvider.getAllOrders();

            Dictionary <string, int> used = new Dictionary <string, int>();

            foreach (Part part in parts)
            {
                foreach (Job job in jobs)
                {
                    foreach (KeyValuePair <Part, int> allocation in job.parts)
                    {
                        if (part.partID == allocation.Key.partID)
                        {
                            if (!used.ContainsKey(part.partID))
                            {
                                used.Add(part.partID, allocation.Value);
                            }
                            else
                            {
                                used[part.partID] = used[part.partID] + allocation.Value;
                            }
                        }
                    }
                }
            }

            ViewData["Start"] = DateTime.ParseExact(start, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            ViewData["End"]   = DateTime.ParseExact(end, "dd/MM/yyyy", CultureInfo.InvariantCulture);

            ViewData["Parts"] = parts;
            ViewData["Used"]  = used;

            return(View("ViewStockReport"));
        }