Exemplo n.º 1
0
        public IndexModel(ILogger <IndexModel> logger,
                          OnlineBookstoreDBContext _context,
                          IUserService userService,
                          ILoginedService loginedService,
                          IBookService bookService)
        {
            ViewModel        = new IndexPageViewModel();
            Context          = _context;
            this.userService = userService;
            _bookService     = bookService;
            _loginedService  = loginedService;
            _logger          = logger;

            //对ViewModel的初始化
            if (Context.Book.ToList().Count >= 4)
            {
                ViewModel.RecommendedBooks = Context.Book.ToList().Take(4).ToList();
            }
            else
            {
                ViewModel.RecommendedBooks = Context.Book.ToList();
            }
            ViewModel.LimitedSaleBooks = Context.Book.ToList();
            ViewModel.Categories       = Context.Category.Select(x => x.CateName).ToList();
            ViewModel.NewBooks         = new List <Book>();
            ViewModel.NewBooks.Add(Context.Book.ToList().Last());
            if (Context.Book.ToList().Count() >= 2)
            {
                ViewModel.NewBooks.Add(Context.Book.ToList()[Context.Book.ToList().Count() - 2]);
            }
        }
Exemplo n.º 2
0
        public CateDetailsModel(ILogger <CateDetailsModel> logger, OnlineBookstoreDBContext _context, IUserService userService, ILoginedService loginedService, IBookService bookService)
        {
            ViewModel        = new CateDetailsPageViewModel();
            Context          = _context;
            this.userService = userService;
            _bookService     = bookService;
            _loginedService  = loginedService;
            _logger          = logger;

            ViewModel.RecommendedBooks = Context.Book.ToList();
        }
Exemplo n.º 3
0
 public ShoppingCartModel_unPay(ILogger <ShoppingCartModel_unPay> logger, IPurchaseService purchaseService,
                                IOrderService orderService, IBookService bookService, ILoginedService loginedService,
                                OnlineBookstoreDBContext context, IUserService userService)
 {
     _logger              = logger;
     _purchaseService     = purchaseService;
     _orderService        = orderService;
     _bookService         = bookService;
     this._loginedService = loginedService;
     _context             = context;
     _userService         = userService;
 }
Exemplo n.º 4
0
        /// <summary>
        /// 当前用户信息
        /// </summary>
        //private readonly UserManager<ExtendedIdentityUser> _userManager;
        //, UserManager<ExtendedIdentityUser> userManager

        public DetailsModel(OnlineBookstoreDBContext context,
                            ILoginedService loginedService,
                            IOrderService orderService,
                            IUserService userService,
                            IPurchaseService purchaseService)
        {
            //_userManager = userManager;
            _context              = context;
            this._loginedService  = loginedService;
            this._orderService    = orderService;
            this._userService     = userService;
            this._purchaseService = purchaseService;
            ViewModel             = new DetailsPageViewModel();
        }
Exemplo n.º 5
0
 public PurchaseService(OnlineBookstoreDBContext context)
 {
     this._context = context;
     _purchases    = context.Purchase.ToList();
 }
Exemplo n.º 6
0
 public BookService(OnlineBookstoreDBContext context)
 {
     _context = context;
 }
Exemplo n.º 7
0
 public UserService(OnlineBookstoreDBContext context)
 {
     this._context = context;
     _users        = _context.User.ToList();
 }
Exemplo n.º 8
0
 public OrderService(OnlineBookstoreDBContext context)
 {
     this._context = context;
     _order        = context.Order.ToList();
 }