示例#1
0
        /**
         * Purpose: Populates the User dropdown and the Cart product count in the nav bar
         * Arguments:
         *      ctx - Database context reference
         */
        public BaseViewModel(BangazonContext ctx)
        {
            context = ctx;

            this.Users = context.User
                         .OrderBy(l => l.LastName)
                         .AsEnumerable()
                         .Select(li => new SelectListItem {
                Text  = $"{li.FirstName} {li.LastName}",
                Value = li.UserId.ToString()
            });

            // For help with this LINQ query, refer to
            // https://stackoverflow.com/questions/373541/how-to-do-joins-in-linq-on-multiple-fields-in-single-join
            this.CartProducts = (
                from product in context.Product
                from lineItem in context.LineItem
                .Where(lineItem => lineItem.OrderId == context.Order.SingleOrDefault(o => o.DateCompleted == null && o.User == ChosenUser).OrderId&& lineItem.ProductId == product.ProductId)
                select product).ToList();

            foreach (Product product in this.CartProducts)
            {
                if (product.IsActive)
                {
                    this.TotalCount += 1;
                }
            }
        }
示例#2
0
        //Create custom constructor that accepts current BangazonContext as argument and passes it up inheritance chain to BaseViewModel. Includes the logic necessary to populate the product type (aka category) and product type subcategory drop down menus
        public CreateProductViewModel(BangazonContext ctx) : base(ctx)
        {
            var context = ctx;

            this.ProductTypeId = context.ProductType
                                 .OrderBy(l => l.Label)
                                 .AsEnumerable()
                                 .Select(li => new SelectListItem
            {
                Text  = li.Label,
                Value = li.ProductTypeId.ToString()
            }).ToList();

            this.ProductTypeId.Insert(0, new SelectListItem
            {
                Text  = "Please Select a Category",
                Value = "0"
            });

            this.ProductTypeSubCategoryId = new List <SelectListItem>();

            this.ProductTypeSubCategoryId.Insert(0, new SelectListItem
            {
                Text  = "Choose a Product Category to See Sub-Categories",
                Value = ""
            });
        }
示例#3
0
 /**
  * Purpose: Saves the reference to the database to display information about the user
  * Arguments:
  *      ctx - Database context reference
  */
 public ProductCreate(BangazonContext ctx) : base(ctx)
 {
     this.ProductTypes = context.ProductType
                         .OrderBy(l => l.Label)
                         .AsEnumerable()
                         .Select(li => new SelectListItem {
         Text  = li.Label,
         Value = li.ProductTypeId.ToString()
     });
 }
        public CustomerFormViewModel(BangazonContext ctx) : base(ctx)
        {
            this.ProductTypeId = ctx.ProductType
                                 .OrderBy(l => l.Label)
                                 .AsEnumerable()
                                 .Select(li => new SelectListItem {
                Text  = li.Label,
                Value = li.ProductTypeId.ToString()
            }).ToList();

            this.ProductTypeId.Insert(0, new SelectListItem {
                Text  = "Choose category...",
                Value = "0"
            });
        }
示例#5
0
        //This is a custom constructor for BaseViewModel. We need BaseViewModel to be able to access the customer dropdown on all of our pages. It takes an argument of BangazonContext which represents a session with the database.
        public BaseViewModel(BangazonContext ctx)
        {
            context         = ctx;
            this.CustomerId = context.Customer
                              .OrderBy(l => l.LastName)
                              .AsEnumerable()
                              .Select(li => new SelectListItem {
                Text  = $"{li.FirstName} {li.LastName}",
                Value = li.CustomerId.ToString()
            }).ToList();

            this.CustomerId.Insert(0, new SelectListItem {
                Text  = "Choose customer...",
                Value = "0"
            });
        }
示例#6
0
        //Method Name: OrderViewModel custom contructor
        //Purpose of the Method: Upon construction this should take the context and send a list of select items of the type PaymentType to the View. They should be the paymentTypes of the active customer.
        //Arguments in Method: BangazonWebContext
        public OrderViewModel(BangazonContext ctx) : base(ctx)
        {
            var customer = ActiveCustomer.instance.Customer;
            var context  = ctx;

            this.PaymentTypeId = context.PaymentType
                                 .Where(pt => pt.CustomerId == customer.CustomerId)
                                 .AsEnumerable()
                                 .Select(li => new SelectListItem {
                Text  = li.Description,
                Value = li.PaymentTypeId.ToString()
            }).ToList();

            this.PaymentTypeId.Insert(0, new SelectListItem {
                Text  = "Choose Payment Type",
                Value = ""
            });
        }
示例#7
0
 /**
  * Purpose: Saves the reference to the database to be used to display the list of products on the active order
  * Arguments:
  *      ctx - Database context reference
  */
 public OrderView(BangazonContext ctx) : base(ctx)
 {
 }
示例#8
0
 public MenuViewModel(BangazonContext ctx) : base(ctx)
 {
 }
示例#9
0
        /**
         * Purpose: load the content of BangazonContext into the context variable for further use
         * Arguments:
         *      ctx - current database connection
         * Return:
         *      CartsController
         */

        public CartController(BangazonContext ctx)
        {
            context = ctx;
        }
 //Create custom constructor that accepts current BangazonContext as argument and passes it up inheritance chain to BaseViewModel
 public ProductDetailViewModel(BangazonContext ctx) : base(ctx)
 {
 }
示例#11
0
 public ComputerController(BangazonContext context)
 {
     _context = context;
 }
示例#12
0
 // Constructor method to create an instance of context to communicate with our database.
 public TrainingProgramController(BangazonContext ctx)
 {
     _context = ctx;
 }
示例#13
0
 /**
  * Purpose: Saves the reference to the database to display information about the active order
  * Arguments:
  *      ctx - Database context reference
  */
 public PaymentTypeView(BangazonContext ctx) : base(ctx)
 {
 }
示例#14
0
 public EmployeeController(BangazonContext ctx)
 {
     _context = ctx;
 }
示例#15
0
 public CustomerPaymentController(BangazonContext ctx)
 {
     _context = ctx;
 }
 //Create a custom constructor that accepts BangazonContext as an argument and passes that context (session with db) up to the methods on BaseViewModel
 public ProductListViewModel(BangazonContext ctx) : base(ctx)
 {
 }
 public DepartmentController(BangazonContext context)
 {
     _context = context;
 }
示例#18
0
 public ProductTypeController(BangazonContext context)
 {
     _context = context;
 }
示例#19
0
 public CustomersController(BangazonContext ctx)
 {
     //a controller will have the context which is the database you're hitting
     context = ctx;
 }
示例#20
0
 public LineItemsController(BangazonContext ctx)
 {
     context = ctx;
 }
 public PaymentTypeController(BangazonContext ctx)
 {
     _context = ctx;
 }
示例#22
0
 public TrainingProgramController(BangazonContext context)
 {
     _context = context;
 }
示例#23
0
 // Constructor method to create an instance of context to communicate with our database.
 public DepartmentController(BangazonContext ctx)
 {
     _context = ctx;
 }
示例#24
0
 /**
  * Purpose: Saves a reference to the database context.
  * Arguments:
  *      ctx - Database context.
  * Return:
  *      An instance of the class.
  */
 public UserCreate(BangazonContext ctx) : base(ctx)
 {
 }
 public CustomerController(BangazonContext ctx)
 {
     context = ctx;
 }
 // Constructor method to create an instance of context to communicate with our database.
 public ComputerController(BangazonContext ctx)
 {
     _context = ctx;
 }
示例#27
0
 public OrdersController(BangazonContext ctx)
 {
     context = ctx;
 }
示例#28
0
 public ProductTypeController(BangazonContext ctx)
 {
     _context = ctx;
 }
示例#29
0
 public ProductsController(BangazonContext ctx)
 {
     context = ctx;
 }
示例#30
0
 /**
  * Purpose: Saves a reference to the database context.
  * Arguments:
  *      ctx - Database context.
  * Return:
  *      An instance of the class.
  */
 public ProductTypeList(BangazonContext ctx) : base(ctx)
 {
 }