Exemplo n.º 1
0
        public async Task <IActionResult> DownloadCompanyData(string password)
        {
            string personalDataFileName = "JobFinder_Data_{0}.json";

            var user = await userManager.GetUserAsync(User);

            var isPasswordValid = !await userManager.HasPasswordAsync(user) || password != null &&
                                  await userManager.CheckPasswordAsync(user, password);

            if (!isPasswordValid)
            {
                this.Error(NotificationMessages.InvalidPassword);
                return(this.RedirectToAction("Dashboard", "JobSeeker"));
            }

            var company = await companyService.GetCompanyForUser(User.Identity.Name);

            var personalData = await personalDataService.GetPersonalDataForCompanyJson(company.Id);

            Response.Headers.Add("Content-Disposition",
                                 "attachment; filename=" + string.Format(personalDataFileName, company.CompanyName));
            return(new FileContentResult(Encoding.UTF8.GetBytes(personalData), "text/json"));
        }