Пример #1
0
        public ActionResult Home()
        {
            #region Prep Utilities

            myHandler = new BusinessLogicHandler();
            Supplier supplier = new Supplier();
            RangeViewModel model = new RangeViewModel();

            #endregion

            #region Get User(Supplier)

            string userName = User.Identity.GetUserName();
            ApplicationDbContext dataSocket = new ApplicationDbContext();
            UserStore<ApplicationUser> myStore = new UserStore<ApplicationUser>(dataSocket);
            _userManager = new ApplicationUserManager(myStore);
            var user = _userManager.FindByEmail(userName);

            #endregion

            #region Get Supplier Details

            supplier = myHandler.GetSupplier(user.Id);

            #endregion

            #region Get Orders For Supplier

            model.Orders = myHandler.GetSupplierOrders(supplier.SupplierID);
            if(model.Orders != null)
            { model.Orders.OrderBy(m => m.DateCreated); }
            #endregion

            return View(model);
        }
Пример #2
0
        public ActionResult Details(int OrderNumber)
        {
            #region Prep Utilities

            myHandler = new BusinessLogicHandler();
            OrderLineModel model = new OrderLineModel();

            #endregion

            #region Get Order Details

            model.OrderLineDetails = myHandler.GetOrderItemsList(OrderNumber);
            model.OrderDetails = myHandler.GetOrder(OrderNumber);
            model.SupplierDetails = myHandler.GetSupplier(model.OrderDetails.SupplierID);

            #endregion

            #region Get Order Total
            model.totally = 0;
            foreach(var item in model.OrderLineDetails)
            {
                if(myHandler.CheckProductType(item.ProductID))
                {
                    Book myBook = new Book();
                    myBook = myHandler.GetBook(item.ProductID);
                    model.totally += (myBook.SellingPrice*item.Quantity);
                }
                else
                {
                    Technology device = new Technology();
                    device = myHandler.GetTechnologyDetails(item.ProductID);
                    model.totally += (device.SellingPrice * item.Quantity);
                }
            }
            #endregion

            return PartialView(model);
        }
Пример #3
0
        public ActionResult RangeSearch(RangeViewModel model)
        {
            if(ModelState.IsValid)
            {

                #region Prep Utilities

                myHandler = new BusinessLogicHandler();
                Supplier supplier = new Supplier();
                #endregion

                #region Get User(Supplier)

                 string userName = User.Identity.GetUserName();
                 ApplicationDbContext dataSocket = new ApplicationDbContext();
                 UserStore<ApplicationUser> myStore = new UserStore<ApplicationUser>(dataSocket);
                 _userManager = new ApplicationUserManager(myStore);
                  var user = _userManager.FindByEmail(userName);

                #endregion

                #region Get Supplier Details

                     supplier = myHandler.GetSupplier(user.Id);

                #endregion

               #region Get the Data

                     string dateFrom = model.myRange.From.ToString("yyyMMdd");
                     string dateTo = model.myRange.To.ToString("yyyMMdd");
                     model.Orders = myHandler.GetOrderByRange(dateFrom, dateTo, supplier.SupplierID);

                #endregion

                     return View(model);
            }
            return View();
        }
Пример #4
0
        public ActionResult Invoice(int OrderNumber, int InvoiceID)
        {
            #region Prep Utilities

            myHandler = new BusinessLogicHandler();
            InvoiceModel model = new InvoiceModel();

            #endregion

            #region Get Invoice Data
            model.myInvoice = new Invoice();
            model.myInvoice = myHandler.GetInvoice(InvoiceID);
            #endregion

            #region Get Invoice Lines
            model.InvoiceLine = new List<InvoiceItem>();
            model.InvoiceLine = myHandler.GetInvoiceItems(InvoiceID);
            if(model.InvoiceLine != null)
            {
                model.totally = 0;
                foreach(var item in model.InvoiceLine)
                { model.totally += item.Price; }
            }
            #endregion

            #region Get Order

            model.Orders = new List<Order>();
            model.Orders = myHandler.GetAllOrdersForInvoice(InvoiceID);

            #endregion

            #region Get Order Lines

            model.OrderLine = new List<OrderItem>();

            foreach (var item in model.Orders)
            {
                model.OrderLine.AddRange(myHandler.GetOrderItemsList(item.OrderNo));
            }

            #endregion

            #region View Supplier Involved

            model.Suppliers = new List<urbanbooks.Supplier>();

            foreach (var item in model.Orders)
            {
                model.Suppliers.Add(myHandler.GetSupplier(item.SupplierID));
            }

            #endregion

            return View(model);
        }
Пример #5
0
        public ActionResult Edit(int SupplierID)
        {
            #region Prep Utilities
            myHandler = new BusinessLogicHandler();
            SupplierViewModel model = new SupplierViewModel();
            #endregion

            #region Get the Data
            model.supplier = myHandler.GetSupplier(SupplierID);
            #endregion

            #region Dropdown data
            model.SupplierType = new List<SelectListItem>();
            if (model.supplier.IsBookSupplier)
            {
                model.SupplierType.Add(
                    new SelectListItem { Text = "Book Supplier", Value = "true", Selected=true}
                    );
                model.SupplierType.Add(
                    new SelectListItem { Text = "Technology Supplier", Value = "false", Selected = false }
                    );
            }
            else
            {
                model.SupplierType.Add(
                    new SelectListItem { Text = "Technology Supplier", Value = "false", Selected = true }
                    );
                model.SupplierType.Add(
                    new SelectListItem { Text = "Book Supplier", Value = "true", Selected = false }
                    );
            }
            ViewData["SupplierType"] = model.SupplierType;
            #endregion
            return View(model);
        }
Пример #6
0
        public ActionResult Search(FormCollection collector)
        {
            #region Prep Utilities

            string Query = collector.GetValue("query").AttemptedValue;
            myHandler = new BusinessLogicHandler();
            Supplier supplier = new Supplier();
            InvoiceModel model = new InvoiceModel();

            #endregion

            #region Get User(Supplier)

            string userName = User.Identity.GetUserName();
            ApplicationDbContext dataSocket = new ApplicationDbContext();
            UserStore<ApplicationUser> myStore = new UserStore<ApplicationUser>(dataSocket);
            _userManager = new ApplicationUserManager(myStore);
            var user = _userManager.FindByEmail(userName);

            #endregion

            #region Get Supplier Details

            supplier = myHandler.GetSupplier(user.Id);

            #endregion


            #region Get the data

            model.Order = new Order();
            model.Invoice = new Invoice();
            try
            {
                model.Order = myHandler.GetOrder(Convert.ToInt32(Query));
            }
            catch
            { model.Order = null; }
            try
            {
                model.Invoice = myHandler.GetInvoice(Convert.ToInt32(Query));
            }
            catch
            { model.Invoice = null; }
            ///get product
            #endregion


            return View(model);
        }