Exemplo n.º 1
0
        public IActionResult AddPart(string partID, string customerID)
        {
            if (!isAuthenticated())
            {
                return(RedirectToAction("Login", "Auth"));
            }

            Dictionary <Part, int> parts = PartsProvider.getOrder(customerID);
            bool exists = false;

            if (parts != null)
            {
                foreach (KeyValuePair <Part, int> part in parts)
                {
                    if (part.Key.partID == partID)
                    {
                        PartsProvider.PartOrderAddQuantity(customerID, partID, 1);
                        exists = true;
                    }
                }
            }
            if (!exists)
            {
                PartsProvider.AddPartToOrder(customerID, partID, 1);
                parts.Add(PartsProvider.getPartFromID(partID), 1);
            }
            TempData["ShoppingCart"] = parts;
            ViewData["CustomerID"]   = customerID;
            ViewData["Parts"]        = PartsProvider.getParts();
            return(View("OrderParts"));
        }
Exemplo n.º 2
0
        public IActionResult ReplenishStock()
        {
            if (!isAuthenticated())
            {
                return(RedirectToAction("Login", "Auth"));
            }

            ViewData["Parts"] = PartsProvider.getLowStockParts();
            return(View());
        }
Exemplo n.º 3
0
        public IActionResult ChangePartDetails(string partID)
        {
            if (!isAuthenticated())
            {
                return(RedirectToAction("Login", "Auth"));
            }

            ViewData["Part"] = PartsProvider.getPartFromID(partID);
            return(View());
        }
Exemplo n.º 4
0
        public IActionResult ReplenishStock(string partID, int quantity)
        {
            if (!isAuthenticated())
            {
                return(RedirectToAction("Login", "Auth"));
            }

            PartsProvider.replenishStock(partID, quantity);
            return(RedirectToAction("ReplenishStock"));
        }
Exemplo n.º 5
0
        public IActionResult AssignPart(string jobID, string partID, string quantity)
        {
            if (!isAuthenticated())
            {
                return(RedirectToAction("Login", "Auth"));
            }

            PartsProvider.assignPartToJob(jobID, partID, Int32.Parse(quantity));

            return(RedirectToAction("ViewJob", new { id = jobID }));
        }
Exemplo n.º 6
0
        public async Task <bool> CreatePartProvider(PartsProviderServiceModel partsProviderServiceModel)
        {
            if (_context.PartsProviders.Any(v => v.Name == partsProviderServiceModel.Name))
            {
                return(false);
            }

            PartsProvider provider = AutoMapper.Mapper.Map <PartsProvider>(partsProviderServiceModel);

            _context.PartsProviders.Add(provider);
            var result = await _context.SaveChangesAsync();

            return(result > 0);
        }
Exemplo n.º 7
0
        public IActionResult GenerateInvoice(string customerID)
        {
            if (!isAuthenticated())
            {
                return(RedirectToAction("Login", "Auth"));
            }

            Dictionary <Part, int> parts = PartsProvider.getOrder(customerID);

            ViewData["Parts"] = parts;
            ViewData["Order"] = PartsProvider.getOrderDetails(customerID);
            PartsProvider.clearOrder(customerID);
            return(View("PartInvoice"));
        }
Exemplo n.º 8
0
        public IActionResult AddPart(string jobID, string search)
        {
            if (!isAuthenticated())
            {
                return(RedirectToAction("Login", "Auth"));
            }

            List <Part> parts = new List <Part>();

            Dictionary <Part, int> existing = JobProvider.getPartsForJob(jobID);

            String[] terms = search.Split(" ");

            foreach (String term in terms)
            {
                foreach (Part result in PartsProvider.searchForParts(term))
                {
                    bool contains = false;

                    foreach (Part check in parts)
                    {
                        if (check.partID == result.partID)
                        {
                            contains = true;
                        }
                    }

                    foreach (KeyValuePair <Part, int> existingPart in existing)
                    {
                        if (existingPart.Key.partID == result.partID)
                        {
                            contains = true;
                        }
                    }

                    if (!contains)
                    {
                        parts.Add(result);
                    }
                }
            }

            ViewData["Parts"]   = parts;
            ViewData["Search"]  = search;
            ViewData["JobID"]   = jobID;
            ViewData["Vehicle"] = JobProvider.getVehicleFromJob(jobID);

            return(View("AddPart"));
        }
Exemplo n.º 9
0
        public IActionResult OrderParts(string customerID)
        {
            if (!isAuthenticated())
            {
                return(RedirectToAction("Login", "Auth"));
            }

            ViewData["CustomerID"] = customerID;
            ViewData["Parts"]      = PartsProvider.getParts();

            Dictionary <Part, int> cart = new Dictionary <Part, int>();

            TempData["ShoppingCart"] = cart;
            return(View());
        }
Exemplo n.º 10
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"));
        }
Exemplo n.º 11
0
        public IActionResult OrderNewCustomer(string customerID, string email, DateTime registered, string title, string firstname, string lastname, string addressline1, string addressline2, string county, string postcode, string phone)
        {
            if (!isAuthenticated())
            {
                return(RedirectToAction("Login", "Auth"));
            }

            Customer customer = new Customer
            {
                customerID   = customerID,
                email        = email,
                registered   = registered,
                title        = title,
                firstname    = firstname,
                lastname     = lastname,
                addressline1 = addressline1,
                addressline2 = addressline2,
                county       = county,
                postcode     = postcode,
                phone        = phone
            };

            CustomerProvider.addCustomer(customer);

            Order order = new Order
            {
                orderID      = customerID,
                date         = registered,
                addressline1 = addressline1,
                addressline2 = addressline2,
                town         = addressline2,
                county       = county,
                postcode     = postcode,
                username     = HttpContext.Session.GetString("user"),
            };

            PartsProvider.partsOrder(order);

            ViewData["Customer"] = customer;
            return(RedirectToAction("OrderParts", new { customerID = customerID }));
        }
Exemplo n.º 12
0
        public IActionResult ChangePartDetails(string partID, string name, string manufacturer, string vehicle, string years, float price, int quantity, int threshold)
        {
            if (!isAuthenticated())
            {
                return(RedirectToAction("Login", "Auth"));
            }

            Part part = new Part
            {
                partID       = partID,
                name         = name,
                manufacturer = manufacturer,
                vehicle      = vehicle,
                years        = years,
                price        = price,
                quantity     = quantity,
                threshold    = threshold
            };

            PartsProvider.editPartDetails(part);
            return(RedirectToAction("Parts"));
        }
Exemplo n.º 13
0
        public IActionResult OrderAddCustomer(string customerID)
        {
            if (!isAuthenticated())
            {
                return(RedirectToAction("Login", "Auth"));
            }

            Customer customer = CustomerProvider.getCustomerFromID(customerID);

            TempData ["customerID"] = customerID;
            if (customer.customerID == null)
            {
                return(RedirectToAction("OrderNewCustomer", "Part"));
            }

            ViewData["Customer"] = customer;

            PartsProvider.clearOrder(customer.customerID);
            PartsProvider.RemovePartsOrders(customer.customerID);
            Order order = new Order
            {
                orderID      = customer.customerID,
                date         = customer.registered,
                addressline1 = customer.addressline1,
                addressline2 = customer.addressline2,
                town         = customer.addressline2,
                county       = customer.county,
                postcode     = customer.postcode,
                username     = HttpContext.Session.GetString("user"),
            };

            PartsProvider.partsOrder(order);


            return(RedirectToAction("OrderParts", new { customerID = customerID }));
        }
Exemplo n.º 14
0
        public void UpdateUIRepresentation()
        {
            if (updateUIRfrozen || ConvertToDouble == null || Transform == null || PartsProvider == null || LabelProvider == null || TicksProvider == null)
            {
                return;
            }
            if (DesiredSize.Height == 0 && DesiredSize.Width == 0)
            {
                return;
            }

            double NewAxesLength = Math.Abs(GetCoordinate(CreateDataPoint(ConvertToDouble(Range.Min)).DataToScreen(Transform)) - GetCoordinate(CreateDataPoint(ConvertToDouble(Range.Max)).DataToScreen(Transform)));

            if (Math.Abs(axeslength - NewAxesLength) > (axeslength / 1000))
            {
                axeslength = NewAxesLength;
                CleanPartsCach();
            }


            //has the scale changed?
            if (Math.Abs(activeScale - (ConvertToDouble(Range.Max) - ConvertToDouble(Range.Min))) > (activeScale / 100))
            {
                activeScale = ConvertToDouble(Range.Max) - ConvertToDouble(Range.Min);
                CleanPartsCach();
            }

            Range <T>[] partsSizes = PartsProvider.GetPartsSizes(Range);

            builder = new StringBuilder();

            //Let's calculate what parts do we need, and position them
            foreach (Range <T> r in partsSizes)
            {
                double left              = GetCoordinate(CreateDataPoint(ConvertToDouble(r.Min)).DataToScreen(Transform));
                double right             = GetCoordinate(CreateDataPoint(ConvertToDouble(r.Max)).DataToScreen(Transform));
                AxisPartControl <T> part = PartsProvider.GetPart(r);
                //shall we add the part
                if (!partsPresentOnScreen.Contains(part))
                {
                    layoutStackCanvas.Children.Add(part);
                    switch (Placement)
                    {
                    case AxisPlacement.Left:
                    case AxisPlacement.Right:
                        part.Height = Math.Abs(right - left);
                        part.Clip   = new RectangleGeometry()
                        {
                            Rect = new Rect(new Point(), new Size(100, part.Height))
                        };
                        break;

                    case AxisPlacement.Top:
                    case AxisPlacement.Bottom:
                        part.Width = Math.Abs(right - left);
                        part.Clip  = new RectangleGeometry()
                        {
                            Rect = new Rect(new Point(), new Size(part.Width, 100))
                        };
                        break;
                    }
                    partsPresentOnScreen.Add(part);
                    part.SizeChanged += new SizeChangedEventHandler(part_SizeChanged);
                    RaiseLoadedPartsChanged();
                }

                //just move the part
                switch (Placement)
                {
                case AxisPlacement.Left:
                case AxisPlacement.Right:
                    StackCanvas.SetCoordinate(part, right);
                    break;

                case AxisPlacement.Bottom:
                case AxisPlacement.Top:
                    StackCanvas.SetCoordinate(part, left);
                    break;
                }

                builder.AppendLine(Placement + ":" + r.ToString());// + " converted: (" + left + "," + right + ")");
                //" act size: ("+part.ActualWidth+", "+part.ActualHeight+") "+
                //"rand size: ("+part.DesiredSize+")");
            }

            //Parts to be removed from the screen
            List <AxisPartControl <T> > toRemove = new List <AxisPartControl <T> >();

            //if we have unnessesery parts, remove them
            foreach (AxisPartControl <T> part in partsPresentOnScreen)
            {
                if (partsProvider.ShouldRemoveFromScreen(part, Range))
                {
                    toRemove.Add(part);
                }
            }

            foreach (AxisPartControl <T> p in toRemove)
            {
                partsPresentOnScreen.Remove(p);
                layoutStackCanvas.Children.Remove(p);
                p.SizeChanged -= part_SizeChanged;
            }
            if (toRemove.Count > 0)
            {
                RaiseLoadedPartsChanged();
            }

            if (!isMinorTicksSyned)
            {
                CheckPartsMinorTicksCount();
            }

#if DEBUG
            DebugString = "Axis rander size: " + DesiredSize +
                          "\nAvl size: " + availableSize +
                          "\n"
                          + builder.ToString();
#endif
        }