|
@ -6,26 +6,34 @@ using System.Threading.Tasks; |
|
|
using System.Web.Mvc; |
|
|
using System.Web.Mvc; |
|
|
using Sevomin.Models; |
|
|
using Sevomin.Models; |
|
|
using Sevomin.Models.Repositories; |
|
|
using Sevomin.Models.Repositories; |
|
|
|
|
|
using Microsoft.AspNet.Identity; |
|
|
|
|
|
using Microsoft.AspNet.Identity.EntityFramework; |
|
|
|
|
|
using Sevomin.Models.Helpers; |
|
|
|
|
|
|
|
|
namespace Sevomin.WebFrontend.Controllers |
|
|
namespace Sevomin.WebFrontend.Controllers |
|
|
{ |
|
|
{ |
|
|
public class JobController : AuthorizedController |
|
|
public class JobController : AuthorizedController |
|
|
{ |
|
|
{ |
|
|
IJobRepository _JobRepository; |
|
|
IJobRepository _JobRepository; |
|
|
|
|
|
public SevominUserManager UserManager { get; private set; } |
|
|
|
|
|
|
|
|
public JobController() |
|
|
public JobController() |
|
|
|
|
|
: this(JobRepository.Current, new SevominUserManager(new UserStore<User>(SevominDbContext.Current))) |
|
|
{ |
|
|
{ |
|
|
_JobRepository = JobRepository.Current; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public JobController(IJobRepository jobRepository) |
|
|
|
|
|
|
|
|
public JobController(IJobRepository jobRepository, SevominUserManager userManager) |
|
|
{ |
|
|
{ |
|
|
_JobRepository = jobRepository; |
|
|
_JobRepository = jobRepository; |
|
|
|
|
|
UserManager = userManager; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public ActionResult NewJob() |
|
|
|
|
|
|
|
|
public async Task<ActionResult> NewJob() |
|
|
{ |
|
|
{ |
|
|
Avalin avalin = (Avalin)User; //????
|
|
|
|
|
|
|
|
|
User u = await UserManager.FindByNameAsync(User.Identity.Name); |
|
|
|
|
|
if (u == null) |
|
|
|
|
|
throw new InvalidOperationException("شما خیلی هنرمندی! به ما هم بگو چجوری!"); |
|
|
|
|
|
Avalin avalin = (Avalin)u; |
|
|
Job job = _JobRepository.GetEmptyJobFor(avalin); |
|
|
Job job = _JobRepository.GetEmptyJobFor(avalin); |
|
|
JobViewModel jvm = new JobViewModel(job); |
|
|
JobViewModel jvm = new JobViewModel(job); |
|
|
return View(jvm); |
|
|
return View(jvm); |
|
|