You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.5 KiB

11 years ago
  1. using Microsoft.AspNet.Identity.EntityFramework;
  2. using Sevomin.Models;
  3. using Sevomin.Models.Helpers;
  4. using System.IO;
  5. using System.Threading.Tasks;
  6. using System.Web.Mvc;
  7. namespace Sevomin.WebFrontend.Controllers
  8. {
  9. [Authorize]
  10. public class AuthorizedController : BaseController
  11. {
  12. public AuthorizedController()
  13. : this(new SevominUserManager(new UserStore<User>(SevominDbContext.Current)))
  14. {
  15. }
  16. public AuthorizedController(SevominUserManager userManager)
  17. {
  18. UserManager = userManager;
  19. }
  20. public SevominUserManager UserManager { get; private set; }
  21. public async Task<ActionResult> GetResume(string userid = "", bool english = false)
  22. {
  23. if (string.IsNullOrWhiteSpace(userid))
  24. userid = (await UserManager.FindByNameAsync(User.Identity.Name)).Id;
  25. Dovomin user = await UserManager.FindByIdAsync(userid) as Dovomin;
  26. if (user == null)
  27. return HttpNotFound();
  28. //ToDo: فکر کنم هر کسی که لاگ این کرده باشه میتونه رزومه هر کسی را دانلود کنه
  29. string path = Path.Combine(Server.MapPath("~/App_Data/resumes/"), english ? user.EnglishResume : user.PersianResume);
  30. string fileDownloadName = string.Format("{0} {1} Resume{2}", user.DisplayName, english ? "English" : "Persian", Path.GetExtension(path));
  31. return File(path, "application/octet-stream", fileDownloadName);
  32. }
  33. }
  34. }