using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Web.Mvc;
|
|
using Sevomin.Models;
|
|
using Sevomin.Models.Repositories;
|
|
using Microsoft.AspNet.Identity;
|
|
using Microsoft.AspNet.Identity.EntityFramework;
|
|
using Sevomin.Models.Helpers;
|
|
using System.Web;
|
|
|
|
namespace Sevomin.WebFrontend.Controllers
|
|
{
|
|
public class JobController : AuthorizedController
|
|
{
|
|
IJobRepository _JobRepository;
|
|
public SevominUserManager UserManager { get; private set; }
|
|
private HttpContextBase _httpContext;
|
|
|
|
public JobController()
|
|
: this(JobRepository.Current,
|
|
new SevominUserManager(new UserStore<User>(SevominDbContext.Current)), null)
|
|
{
|
|
}
|
|
|
|
protected override void Initialize(System.Web.Routing.RequestContext requestContext)
|
|
{
|
|
base.Initialize(requestContext);
|
|
_httpContext = requestContext.HttpContext;
|
|
}
|
|
|
|
public JobController(IJobRepository jobRepository, SevominUserManager userManager, HttpContextBase httpContext)
|
|
{
|
|
_JobRepository = jobRepository;
|
|
UserManager = userManager;
|
|
_httpContext = httpContext;
|
|
}
|
|
|
|
public async Task<ActionResult> NewJob()
|
|
{
|
|
User u = await UserManager.FindByNameAsync(User.Identity.Name);
|
|
if (u == null)
|
|
throw new InvalidOperationException("شما خیلی هنرمندی! به ما هم بگو چجوری!");
|
|
Avalin avalin = (Avalin)u;
|
|
Job job = _JobRepository.GetEmptyJobFor(avalin);
|
|
JobViewModel jvm = new JobViewModel(job);
|
|
return View(jvm);
|
|
}
|
|
}
|
|
}
|