// GET: Tenancies/Details/5 public async Task <IActionResult> Details(int?id) { if (id == null) { return(NotFound()); } TenancyViewModel tenancyVM = new TenancyViewModel(); var _tenancy = await _tenancySvc.GetTenancyAsync(id.Value); if (_tenancy == null) { return(NotFound()); } var user = await _userManager.GetUserAsync(HttpContext.User); //Get logged in user tenancyVM = _mapper.Map <TenancyViewModel>(_tenancy); //Map tenancy object to ViewModel //Get created by & update by username ApplicationUser createByUser = await _userManager.FindByIdAsync(tenancyVM.createdByUserID); tenancyVM.createdByUsername = createByUser.UserName; ApplicationUser updatedByUser = await _userManager.FindByIdAsync(tenancyVM.updatedByUserID); tenancyVM.updatedByUsername = updatedByUser.UserName; tenancyVM.tenancyhousehold = await _tenancySvc.GetTenancyHouseholdAsync(tenancyVM.tenancyId); //Get household data for tenancy tenancyVM.property = await _propertySvc.GetPropertyViewAsync(tenancyVM.propertyId.Value); //Get property view data for tenancy tenancyVM.actions = await _actionSvc.GetActionsForTenancyAsync(tenancyVM.tenancyId); //Get actions data for tenancy tenancyVM.alerts = await _alertSvc.GetAlertsForTenancyAsync(tenancyVM.tenancyId); //Get all alerts for tenancy tenancyVM.rentLedger = await _rentAccountSvc.GetRentLedgerForTenancyAsync(tenancyVM.tenancyId); //Get rent ledger records for tenancy ViewBag.ApiLocation = _config["APILocation"]; //Set API location URL ViewBag.LoggedInUserId = user.Id; //Set logged in user Id return(View(tenancyVM)); }