Browse Source

Job single page done

confirmation-email
Milad Karbasizadeh 11 years ago
parent
commit
8807cef1eb
15 changed files with 280 additions and 40 deletions
  1. +19
    -0
      Sevomin.Models/Enums/MuSCoW.cs
  2. +19
    -0
      Sevomin.Models/Enums/ResumeTypes.cs
  3. +66
    -0
      Sevomin.Models/Helpers/Make Use Of Enums (They are pretty useless without this file!).cs
  4. +16
    -5
      Sevomin.Models/JobMiniViewModel.cs
  5. +3
    -1
      Sevomin.Models/JobParameterViewModel.cs
  6. +3
    -0
      Sevomin.Models/Sevomin.Models.csproj
  7. +28
    -10
      Sevomin.WebFrontend.Controllers/JobController.cs
  8. +6
    -0
      Sevomin.WebFrontend/App_Start/RouteConfig.cs
  9. +30
    -8
      Sevomin.WebFrontend/Content/common.css
  10. +2
    -0
      Sevomin.WebFrontend/Sevomin.WebFrontend.csproj
  11. +7
    -1
      Sevomin.WebFrontend/Views/Job/JobEditor.cshtml
  12. +21
    -11
      Sevomin.WebFrontend/Views/Job/JobList.cshtml
  13. +1
    -2
      Sevomin.WebFrontend/Views/Job/NewJob.cshtml
  14. +57
    -0
      Sevomin.WebFrontend/Views/Job/SingleJob.cshtml
  15. +2
    -2
      Sevomin.WebFrontend/Views/Shared/JobParameterViewModel.cshtml

+ 19
- 0
Sevomin.Models/Enums/MuSCoW.cs View File

@ -0,0 +1,19 @@
using Sevomin.Models.Helpers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Sevomin.Models.Enums
{
public enum MuSCoW
{
[StringValue("الزامی")]
Must = 4,
[StringValue("خیلی مهم")]
Should = 3,
[StringValue("مفید")]
Could = 2
}
}

+ 19
- 0
Sevomin.Models/Enums/ResumeTypes.cs View File

@ -0,0 +1,19 @@
using Sevomin.Models.Helpers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Sevomin.Models.Enums
{
public enum ResumeTypes
{
[StringValue("انگلیسی")]
English = 2,
[StringValue("فارسی")]
Persian = 1,
[StringValue("تفاوت ندارد")]
Any = 0
}
}

+ 66
- 0
Sevomin.Models/Helpers/Make Use Of Enums (They are pretty useless without this file!).cs View File

@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Web.Mvc;
namespace Sevomin.Models.Helpers
{
public class StringValue : System.Attribute
{
private string _value;
public StringValue(string value)
{
_value = value;
}
public string Value
{
get { return _value; }
}
}
public static class StringEnum
{
public static SelectList GetSelectList(Type inputEnum, bool textAsValue)
{
List<SelectListItem> retList = new List<SelectListItem>();
if (inputEnum.IsEnum)
{
foreach (Enum property in Enum.GetValues(inputEnum))
{
retList.Add(new SelectListItem
{
Text = GetStringValue(property),
Value = Convert.ToInt16(inputEnum.GetField(property.ToString()).GetValue(null)).ToString() //textAsValue ? GetStringValue(property) : property.ToString()
});
}
return new SelectList(retList, "Value", "Text");
}
else
throw new InvalidOperationException("The input type is not an enum.");
}
public static string GetStringValue(Enum value)
{
Type type = value.GetType();
//Check first in our cached results...
//Look for our 'StringValueAttribute'
//in the field's custom attributes
FieldInfo fi = type.GetField(value.ToString());
StringValue[] attrs =
fi.GetCustomAttributes(typeof(StringValue),
true) as StringValue[];
foreach (var item in attrs)
{
if (!string.IsNullOrEmpty(item.Value))
return item.Value;
}
return string.Empty;
}
}
}

+ 16
- 5
Sevomin.Models/JobMiniViewModel.cs View File

@ -13,7 +13,7 @@ namespace Sevomin.Models
public class JobMiniViewModel
{
private const int MaxNumberOfMiniParams = 6;
private int MaxNumberOfMiniParams = 6;
[Key]
public long Id { get; set; }
@ -21,11 +21,11 @@ namespace Sevomin.Models
[StringLength(128)]
public string AvalinId { get; set; }
[DisplayName("تاریخ انقضا")]
[DisplayName("آخرین مهلت اعلام آمادگی")]
[DataType(DataType.Date)]
public DateTime ExpireDate { get; set; }
[DisplayName("تاریخ انقضا")]
[DisplayName("آخرین مهلت اعلام آمادگی")]
[DataType(DataType.Date)]
public string JalaliExpireDate
{
@ -42,15 +42,27 @@ namespace Sevomin.Models
[DisplayName("کار تمام وقت")]
public bool IsFullTime { get; set; }
public bool ShowCompanyLogo { get; set; }
public bool ShowCompanyName { get; set; }
public string CompanyName { get; set; }
public string CompanyLogo { get; set; }
public IList<Tuple<string, string>> Parameters;
public JobMiniViewModel(Job job)
public JobMiniViewModel(Job job, int maxNumberOfMiniParams = 6)
{
this.MaxNumberOfMiniParams = maxNumberOfMiniParams;
this.Id = job.Id;
this.AvalinId = job.AvalinId;
this.ExpireDate = job.ExpireDate == DateTime.MinValue ? DateTime.Now.AddDays(14) : job.ExpireDate;
this.IsFullTime = job.IsFullTime;
this.ShowCompanyLogo = job.ShowCompanyLogo;
this.ShowCompanyName = job.ShowCompanyName;
if (this.ShowCompanyName)
this.CompanyName = job.Avalin.DisplayName;
if (job.JobParameters == null)
return;
@ -67,7 +79,6 @@ namespace Sevomin.Models
string value = jpz[i].StringValue;
if (jpz[i].Parameter.DisplayMethod == 4)
{
value = jpz[i].Parameter.ParameterValues.ToList().Where(x =>x.NumbericValue == jpz[i].NumericValue).Select(x => x.Value)
.FirstOrDefault();
}


+ 3
- 1
Sevomin.Models/JobParameterViewModel.cs View File

@ -20,6 +20,7 @@ namespace Sevomin.Models
public string ParameterName { get; set; }
public bool HasMoscow { get; set; }
public byte DisplayMethod { get; set; }
public string DisplayFormat { get; set; }
public string GroupName { get; set; }
public string CommentAvalin { get; set; }
@ -40,6 +41,7 @@ namespace Sevomin.Models
ParameterName = jp.Parameter.Name;
HasMoscow = jp.Parameter.Moscow;
DisplayMethod = jp.Parameter.DisplayMethod;
DisplayFormat = jp.Parameter.DisplayFormat;
GroupName = jp.Parameter.GroupName;
CommentAvalin = jp.Parameter.CommentAvalin;
@ -52,4 +54,4 @@ namespace Sevomin.Models
}
}
}
}
}

+ 3
- 0
Sevomin.Models/Sevomin.Models.csproj View File

@ -67,8 +67,11 @@
<Compile Include="DovominViewModel.cs" />
<Compile Include="DovominParameter.cs" />
<Compile Include="Dovomin.cs" />
<Compile Include="Enums\MuSCoW.cs" />
<Compile Include="Enums\ResumeTypes.cs" />
<Compile Include="Helpers\DateAssist.cs" />
<Compile Include="Helpers\EmailValidationAttribute.cs" />
<Compile Include="Helpers\Make Use Of Enums %28They are pretty useless without this file!%29.cs" />
<Compile Include="Helpers\SevominUserStore.cs" />
<Compile Include="Helpers\SevominUserValidator.cs" />
<Compile Include="Job.cs" />


+ 28
- 10
Sevomin.WebFrontend.Controllers/JobController.cs View File

@ -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)];


+ 6
- 0
Sevomin.WebFrontend/App_Start/RouteConfig.cs View File

@ -56,6 +56,12 @@ namespace Sevomin.WebFrontend
url: "jobs/new-job",
defaults: new { controller = "Job", action = "NewJob" }
);
routes.MapRoute(
name: "SingleJob",
url: "jobs/{jobId}",
defaults: new { controller = "Job", action = "SingleJob" }
);
#endregion
routes.MapRoute(


+ 30
- 8
Sevomin.WebFrontend/Content/common.css View File

@ -16,24 +16,27 @@ body{
padding: 60px;
}
.h1, .h2, .h3, .h4, .h5, .h6{
font-family: Koodak, "Helvetica Neue",Helvetica,Arial,sans-serif;
h1, h2, h3, h4, h5, h6{
font-family: Koodak, "Helvetica Neue",Helvetica,Arial,sans-serif;
}
.rtl{
direction: rtl;
text-align: right;
direction: rtl !important;
text-align: right !important;
}
.ltr{
direction: ltr;
text-align: left;
direction: ltr !important;
text-align: left !important;
}
th{
text-align: right;
}
.navbar{
height: 30px;
background: #5B9BD5;
height: 30px;
background: #5B9BD5;
border-radius: 0px !important;
}
@ -52,4 +55,23 @@ body{
.navbar-brand img{
height: 25px;
}
.job-list-top-toolbar, .job-list-bottom-toolbar{
text-align: left !important;
}
.job-list-top-toolbar{
border-bottom: 1px solid #E0E0E0;
padding: 0px 10px 10px 0px;
margin-bottom: 5px;
}
.job-list-bottom-toolbar{
border-top: 1px solid #E0E0E0;
padding: 10px 10px 0px 0px;
}
.job-list-bottom-toolbar .date{
float: right;
}

+ 2
- 0
Sevomin.WebFrontend/Sevomin.WebFrontend.csproj View File

@ -259,6 +259,7 @@
<Content Include="Views\Home\DovominIndex.cshtml" />
<Content Include="Views\Home\AvalinIndex.cshtml" />
<Content Include="Views\Job\JobList.cshtml" />
<Content Include="Views\Job\SingleJob.cshtml" />
<None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
</None>
@ -277,6 +278,7 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\company-logos\" />
<Folder Include="App_Data\resumes\" />
</ItemGroup>
<PropertyGroup>


+ 7
- 1
Sevomin.WebFrontend/Views/Job/JobEditor.cshtml View File

@ -10,6 +10,12 @@
<div class="panel-heading">مشخصات اصلی آگهی</div>
<div class="panel-body">
<div class="col-md-6">
<div class="form-group">
@Html.LabelFor(model => model.ResumeType)
@Html.DropDownListFor(model => model.ResumeType,
Sevomin.Models.Helpers.StringEnum.GetSelectList(typeof(Sevomin.Models.Enums.ResumeTypes), false),
new { @class = "form-control" })
</div>
<div class="form-group">
<div class="checkbox">
<label>
@ -30,7 +36,7 @@
@Html.DisplayNameFor(model => model.ShowCompanyLogo) @Html.CheckBoxFor(model => model.ShowCompanyLogo)
</label>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">


+ 21
- 11
Sevomin.WebFrontend/Views/Job/JobList.cshtml View File

@ -1,17 +1,27 @@
@model IList<Sevomin.Models.JobMiniViewModel>
<div class="col-md-12">
@foreach (var job in Model)
{
<div class="panel panel-default">
<div class="panel-body">
<p class="rtl"> کارشناس برنامه ریزی و کنترل پروژه
<section>
@foreach (var job in Model)
{
<div class="panel panel-default">
<div class="panel-body">
<div class="job-list-top-toolbar rtl">
<a href="@Url.Action("SingleJob", new { jobId = job.Id })" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-th-list"></span> مشاهده جزییات بیشتر</a>
</div>
<p class="rtl">
کارشناس برنامه ریزی و کنترل پروژه
@foreach (var param in job.Parameters)
{
{
@MvcHtmlString.Create(string.Format(param.Item1, param.Item2) + " ")
}
</p>
}
</p>
<div class="job-list-bottom-toolbar rtl">
<span class="date">آخرین مهلت اعلام آمادگی: @job.JalaliExpireDate</span>
<a href="#" class="btn btn-primary btn-xs"><span class="glyphicon glyphicon-ok"></span> اعلام آمادگی</a>
</div>
</div>
</div>
</div>
}
</div>
}
</section>
</div>

+ 1
- 2
Sevomin.WebFrontend/Views/Job/NewJob.cshtml View File

@ -1,5 +1,4 @@

@{
@{
ViewBag.Title = "انتشار آگهی جدید";
}


+ 57
- 0
Sevomin.WebFrontend/Views/Job/SingleJob.cshtml View File

@ -0,0 +1,57 @@
@model Sevomin.Models.JobViewModel
@{
ViewBag.Title = string.Format("{0} {1}", "جزییات آگهی جذب نیروی برنامه ریزی پروژه", ViewBag.ShortJobDescription);
}
<div class="row">
<div class="col-md-12">
<h2 class="rtl">جذب نیروی برنامه ریزی پروژه</h2>
<h4 class="rtl">@ViewBag.ShortJobDescription</h4>
<div class="table-responsive rtl">
<p>
<a class="btn btn-primary btn-xs" href="#"><span class="glyphicon glyphicon-ok"></span>اعلام آمادگی</a>
</p>
<table class="table table-bordered">
<thead>
<tr>
<th>@Html.DisplayNameFor(m => m.JalaliCreateDate)</th>
<th>@Html.DisplayNameFor(m => m.JalaliExpireDate)</th>
<th>@Html.DisplayNameFor(m => m.ResumeType)</th>
<th>@Html.DisplayNameFor(m => m.IsFullTime)</th>
</tr>
</thead>
<tbody>
<tr>
<td>@Html.DisplayFor(m => m.JalaliCreateDate)</td>
<td>@Html.DisplayFor(m => m.JalaliExpireDate)</td>
<td>@Sevomin.Models.Helpers.StringEnum.GetStringValue((Sevomin.Models.Enums.ResumeTypes)Model.ResumeType)</td>
<td>@(Model.IsFullTime ? "بله" : "خیر")</td>
</tr>
</tbody>
</table>
<table class="table table-stripped table-bordered">
<thead>
<tr>
<th colspan="2">ویژگی</th>
<th>میزان اهمیت</th>
</tr>
</thead>
<tbody>
@foreach (var param in Model.Parameters)
{
if (!string.IsNullOrWhiteSpace(param.StringValue))
{
<tr>
<th>@param.ParameterName</th>
<td>@(param.DisplayMethod == 4 ? param.ParameterValues.FirstOrDefault(v => v.Item1.ToString() == param.StringValue).Item2 : param.StringValue)</td>
<td>@Sevomin.Models.Helpers.StringEnum.GetStringValue((Sevomin.Models.Enums.MuSCoW)param.MoscowValue)</td>
</tr>
}
}
</tbody>
</table>
</div>
</div>
</div>

+ 2
- 2
Sevomin.WebFrontend/Views/Shared/JobParameterViewModel.cshtml View File

@ -1,7 +1,7 @@
@model Sevomin.Models.JobParameterViewModel
@{ string paramId = string.Format("value-{0}", Model.ParameterId.ToString());
string muscowId = string.Format("moscow-{0}", Model.ParameterId.ToString());
var MuSCoWList = new List<Tuple<string, string>>() { new Tuple<string, string>("الزامی", "4"), new Tuple<string, string>("خیلی مهم", "3"), new Tuple<string, string>("مفید", "2") }; }
var MuSCoWList = Sevomin.Models.Helpers.StringEnum.GetSelectList(typeof(Sevomin.Models.Enums.MuSCoW), false); }
<div class="form-group">
<div class="row">
<div class="col-md-3 pull-right">
@ -34,7 +34,7 @@
<div class="col-md-3 pull-right">
@if (Model.HasMoscow)
{
@Html.DropDownList(muscowId, new SelectList(MuSCoWList, "item2", "item1", string.IsNullOrWhiteSpace(Model.StringValue) ? "2" : Model.StringValue), new { @class = "form-control" })
@Html.DropDownList(muscowId, new SelectList(MuSCoWList, "Value", "Text", Model.MoscowValue == 0 ? 2 : Model.MoscowValue), new { @class = "form-control" })
}
</div>
</div>

Loading…
Cancel
Save