Ejemplo n.º 1
0
        public async Task <IActionResult> MyBalance()
        {
            var client = await _clientRepository.GetClientByEmailAsync(User.Identity.Name);

            if (client == null)
            {
                return(NotFound());
            }

            var miles = await _mileRepository.GetMilesAssociatedWithClientAsync(client.Id);

            if (miles == null)
            {
                return(NotFound());
            }

            ViewData["StatusBalance"] = miles.Where(m => m.MilesType.Description == "Status").Sum(m => m.Balance);
            ViewData["BonusBalance"]  = miles.Where(m => m.MilesType.Description == "Bonus").Sum(m => m.Balance);

            var bonus = miles.Where(m => m.MilesType.Description == "Bonus");

            var model = _converterHelper.FromMileToMilesViewModel(bonus);

            return(View(model));
        }