@ -10,13 +10,13 @@ using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework ;
using Sevomin.Models.Helpers ;
using System.Web ;
using Sevomin.Models.Enums ;
namespace Sevomin.WebFrontend.Controllers
{
public class JobController : AuthorizedController
{
IJobRepository _JobRepository ;
public SevominUserManager UserManager { get ; private set ; }
IJobRepository _JobRepository ;
private HttpContextBase _httpContext ;
public JobController ( )
@ -31,10 +31,9 @@ namespace Sevomin.WebFrontend.Controllers
_httpContext = requestContext . HttpContext ;
}
public JobController ( IJobRepository jobRepository , SevominUserManager userManager , HttpContextBase httpContext )
public JobController ( IJobRepository jobRepository , SevominUserManager userManager , HttpContextBase httpContext ) : base ( userManager )
{
_JobRepository = jobRepository ;
UserManager = userManager ;
_JobRepository = jobRepository ;
_httpContext = httpContext ;
}
@ -60,14 +59,14 @@ namespace Sevomin.WebFrontend.Controllers
[HttpPost]
public async Task < ActionResult > NewJob ( string JalaliExpireDate , string ContactPersonName ,
string ContactPersonPhone , string ContactPersonEMail , bool IsFullTime ,
bool ShowCompanyName , string Description , bool ShowCompanyLogo , FormCollection form )
bool ShowCompanyName , string Description , bool ShowCompanyLogo , ResumeTypes ResumeType , FormCollection form )
{
Job job = await GetEmptyJob ( ) ;
try
{
UpdateFields ( JalaliExpireDate , ContactPersonName , ContactPersonPhone ,
ContactPersonEMail , IsFullTime , ShowCompanyName ,
Description , ShowCompanyLogo , form , job ) ;
Description , ShowCompanyLogo , ResumeType , form , job ) ;
JobRepository . Current . Save ( ) ;
}
catch ( Exception )
@ -100,14 +99,14 @@ namespace Sevomin.WebFrontend.Controllers
[HttpPost]
public async Task < ActionResult > Edit ( long id , string JalaliExpireDate , string ContactPersonName ,
string ContactPersonPhone , string ContactPersonEMail , bool IsFullTime ,
bool ShowCompanyName , string Description , bool ShowCompanyLogo , FormCollection form )
bool ShowCompanyName , string Description , bool ShowCompanyLogo , ResumeTypes ResumeType , FormCollection form )
{
Job job = await FetchJob ( id ) ;
try
{
UpdateFields ( JalaliExpireDate , ContactPersonName , ContactPersonPhone ,
ContactPersonEMail , IsFullTime , ShowCompanyName ,
Description , ShowCompanyLogo , form , job ) ;
Description , ShowCompanyLogo , ResumeType , form , job ) ;
JobRepository . Current . Save ( ) ;
}
catch ( Exception )
@ -127,9 +126,27 @@ namespace Sevomin.WebFrontend.Controllers
. ToList ( )
. Select ( j = > new JobMiniViewModel ( j ) ) . ToList ( ) ) ;
}
public ActionResult SingleJob ( long jobId )
{
Job job = _JobRepository . Find ( jobId ) ;
if ( job = = null )
return HttpNotFound ( ) ;
JobViewModel viewModel = new JobViewModel ( job ) ;
JobMiniViewModel jvm = new JobMiniViewModel ( job , 3 ) ;
StringBuilder sb = new StringBuilder ( "کارشناس برنامه ریزی و کنترل پروژه " ) ;
foreach ( var param in jvm . Parameters )
sb . Append ( string . Format ( param . Item1 + " " , param . Item2 ) ) ;
ViewBag . ShortJobDescription = sb . ToString ( ) ;
return View ( viewModel ) ;
}
private static void UpdateFields ( string JalaliExpireDate , string ContactPersonName , string ContactPersonPhone , string ContactPersonEMail , bool IsFullTime , bool ShowCompanyName , string Description , bool ShowCompanyLogo , FormCollection form , Job job )
private static void UpdateFields ( string JalaliExpireDate , string ContactPersonName , string ContactPersonPhone , string ContactPersonEMail , bool IsFullTime , bool ShowCompanyName , string Description , bool ShowCompanyLogo , ResumeTypes ResumeType , FormCollection form , Job job )
{
job . ExpireDate = DateAssist . ToMiladi ( JalaliExpireDate ) ;
job . ContactPersonEMail = ContactPersonEMail ;
@ -139,6 +156,7 @@ namespace Sevomin.WebFrontend.Controllers
job . IsFullTime = IsFullTime ;
job . ShowCompanyLogo = ShowCompanyLogo ;
job . ShowCompanyName = ShowCompanyName ;
job . ResumeType = ( byte ) ResumeType ;
foreach ( var jp in job . JobParameters )
{
string value = form [ string . Format ( "value-{0}" , jp . Parameter . Id ) ] ;