// GET: Properties/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var property = await _propertySvc.GetPropertyAsync(id.Value);

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

            var user = await _userManager.GetUserAsync(HttpContext.User); //Get logged in user

            var activeTenancy = await _tenancySvc.GetActiveTenancyForPropertyIdAsync(id.Value);

            PropertyViewModel propertyVM = _mapper.Map <PropertyViewModel>(property);               //Map property model object to viewmodel

            propertyVM.tenancyHistory = await _tenancySvc.GetTenanciesForPropertyIdAsync(id.Value); //Get tenancy history for property

            if (activeTenancy != null)
            {
                propertyVM.tenancyId = activeTenancy.tenancyId;
            }

            //Get created by & update by username
            ApplicationUser createByUser = await _userManager.FindByIdAsync(propertyVM.createdByUserID);

            propertyVM.createdByUsername = createByUser.UserName;

            ApplicationUser updatedByUser = await _userManager.FindByIdAsync(propertyVM.updatedByUserID);

            propertyVM.updatedByUsername = updatedByUser.UserName;

            ViewBag.ApiLocation    = _config["APILocation"]; //Set API location URL
            ViewBag.LoggedInUserId = user.Id;                //Set logged in user Id

            return(View(propertyVM));
        }