-
Notifications
You must be signed in to change notification settings - Fork 0
/
ProductsViewModel.cs
53 lines (45 loc) · 1.57 KB
/
ProductsViewModel.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using TheWidgetStore.Models;
namespace TheWidgetStore.ViewModels
{
public class ProductsViewModel
{
private HomeModel homeModel = new HomeModel();
public List<Widget> ProductList { get; set; }
// used by JQuery grid
public int? page { get; set; }
public int? limit { get; set; }
public string sortBy { get; set; }
public string direction { get; set; }
public string searchString { get; set; }
public int totalRecords { get; set; }
public List<int> productIDList { get; set; }
public decimal cartTotal { get; set; }
public void GetProductList(ProductsViewModel productsViewModel)
{
int total;
ProductList = homeModel.GetAllProducts(productsViewModel, out total);
totalRecords = total;
}
public void GetCartProducts(ProductsViewModel productsViewModel)
{
int total;
ProductList = homeModel.GetCartProducts(productsViewModel, out total);
totalRecords = total;
// Loop through product list, and add each product price to cart total
}
public void GetCartTotal()
{
cartTotal = homeModel.GetCartTotal(productIDList);
}
}
public class Widget
{
public int ProductID { get; set; }
public string ProductName { get; set; }
public decimal Price { get; set; }
}
}