示例#1
0
        public async Task <IActionResult> Detail(string customerId)
        {
            if (string.IsNullOrWhiteSpace(customerId))
            {
                throw new ApplicationException("Can't get customer with id null");
            }

            DetailCustomerViewModel model = new DetailCustomerViewModel();

            model.Customer = await _customerService.GetCustomerById(customerId);

            if (model.Customer == null)
            {
                return(RedirectToAction(nameof(ErrorController.Error404), "Error"));
            }

            var size = 3;
            var page = 1;

            model.ListTransactionHistoryModel = await _transactionHistoryService.GetListTransactionHistory(size, page, customerId);

            var dateFrom = DateTime.Now.AddDays(-30).Date;
            var dateTo   = DateTime.Now.Date;

            model.PropertyFluctuations = await _transactionHistoryService.GetPropertyFluctuations(customerId, dateFrom, dateTo);

            model.InvestmentTarget = await _investmentTargetService.GetInvestmentTarget(customerId);

            model.UserPortfolios = await _userService.GetUserPorfolio(customerId);

            return(View(model));
        }
        public ActionResult Details(int id)
        {
            //check if id is within the number of records in the DB (number of customers)
            if (id > _dbContext.Customers.Count() + 1 || id < 1)
            {
                return(HttpNotFound());
            }

            var customerDetail = new DetailCustomerViewModel()
            {
                Customer = _dbContext.Customers.Include(c => c.MemberShipType).SingleOrDefault(customer => customer.Id == id)
            };

            return(View(customerDetail));
        }
示例#3
0
        public async Task <IActionResult> Detail()
        {
            if (!_userService.IsSignedIn(User))
            {
                return(RedirectToAction(nameof(HomeController.Index), "Home"));
            }

            var currentUser = await _userService.GetCurrentUser();

            DetailCustomerViewModel model = new DetailCustomerViewModel();

            model.Customer = currentUser;

            var dateFrom = DateTime.Now.AddDays(-30).Date;
            var dateTo   = DateTime.Now.Date;

            model.PropertyFluctuations = await _transactionHistoryService.GetPropertyFluctuations(currentUser.Id, dateFrom, dateTo);

            model.InvestmentTarget = await _investmentTargetService.GetInvestmentTarget(currentUser.Id);

            return(View(model));
        }