public async Task <IActionResult> Edit(Guid id, [Bind("FirstName,LastName,PhoneNumber,JobTitle,Nationality,TenancyStartDate,TenancyEndDate,TenantImage,Id,CreatedDate,UpdatedDate")] Tenant tenant, IFormFile profilePic) { if (id != tenant.Id) { return(NotFound()); } if (ModelState.IsValid) { if (profilePic != null) { // Uploaded a new image, delete the existing... if (await _tenantService.DeleteTenantImage(tenant.TenantImage)) { tenant.TenantImage = await _tenantService.CreateTenantImage(tenant.Id, profilePic); } } var result = await _tenantService.UpdateTenant(tenant); return(RedirectToAction("Detail", "Property", new { portfolioId = result.Property.Portfolio.Id, propertyId = result.Property.Id } +"#nav-tenant/") .WithSuccess("Success", "Tenant sucessfully updated")); } return(View(tenant)); }