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.

52 lines
1.7 KiB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Web.Mvc;
  7. using Sevomin.Models;
  8. using Sevomin.Models.Repositories;
  9. using Microsoft.AspNet.Identity;
  10. using Microsoft.AspNet.Identity.EntityFramework;
  11. using Sevomin.Models.Helpers;
  12. using System.Web;
  13. namespace Sevomin.WebFrontend.Controllers
  14. {
  15. public class JobController : AuthorizedController
  16. {
  17. IJobRepository _JobRepository;
  18. public SevominUserManager UserManager { get; private set; }
  19. private HttpContextBase _httpContext;
  20. public JobController()
  21. : this(JobRepository.Current,
  22. new SevominUserManager(new UserStore<User>(SevominDbContext.Current)), null)
  23. {
  24. }
  25. protected override void Initialize(System.Web.Routing.RequestContext requestContext)
  26. {
  27. base.Initialize(requestContext);
  28. _httpContext = requestContext.HttpContext;
  29. }
  30. public JobController(IJobRepository jobRepository, SevominUserManager userManager, HttpContextBase httpContext)
  31. {
  32. _JobRepository = jobRepository;
  33. UserManager = userManager;
  34. _httpContext = httpContext;
  35. }
  36. public async Task<ActionResult> NewJob()
  37. {
  38. User u = await UserManager.FindByNameAsync(User.Identity.Name);
  39. if (u == null)
  40. throw new InvalidOperationException("شما خیلی هنرمندی! به ما هم بگو چجوری!");
  41. Avalin avalin = (Avalin)u;
  42. Job job = _JobRepository.GetEmptyJobFor(avalin);
  43. JobViewModel jvm = new JobViewModel(job);
  44. return View(jvm);
  45. }
  46. }
  47. }