Browse Source

first part of job creation view

confirmation-email
Milad Karbasizadeh 11 years ago
parent
commit
dd7627d329
4 changed files with 279 additions and 12 deletions
  1. +213
    -0
      Sevomin.Models/Helpers/DateAssist.cs
  2. +35
    -1
      Sevomin.Models/JobViewModel.cs
  3. +1
    -0
      Sevomin.Models/Sevomin.Models.csproj
  4. +30
    -11
      Sevomin.WebFrontend/Views/Job/JobEditor.cshtml

+ 213
- 0
Sevomin.Models/Helpers/DateAssist.cs View File

@ -0,0 +1,213 @@
using System;
using System.Globalization;
namespace Sevomin.Models.Helpers
{
public class DateAssist
{
public class FromToDate
{
public DateTime Start;
public DateTime End;
public string startShamsi;
public string endShamsi;
}
/// <summary>
/// None Zero-Based month number
/// </summary>
/// <param name="monthNumber"></param>
/// <returns></returns>
public static string GetPersianMonthName(int monthNumber)
{
switch (monthNumber)
{
case 1:
return "فروردین";
case 2:
return "اردیبهشت";
case 3:
return "خرداد";
case 4:
return "تیر";
case 5:
return "مرداد";
case 6:
return "شهریور";
case 7:
return "مهر";
case 8:
return "آبان";
case 9:
return "آذر";
case 10:
return "دی";
case 11:
return "بهمن";
case 12:
return "اسفند";
default:
throw new ArgumentException("شماره ماه باید بین 1 تا 12 باشد.", "monthNumber", null);
}
}
public static string GetFullPersianDate(DateTime value)
{
PersianCalendar pc = new PersianCalendar();
return string.Format("{0} {1} {2}",
pc.GetDayOfMonth(value), GetPersianMonthName(pc.GetMonth(value)),
pc.GetYear(value));
}
public static DateTime? ValidateAndSetToMiladi(string value, DateTime? defaultValue = null)
{
string vd = ValidateDate(value);
if (string.IsNullOrEmpty(vd))
return defaultValue;
return ToMiladi(vd);
}
public static DateTime ToMiladi(string value)
{
if (value == "" || value == null)
return DateTime.MinValue;
PersianCalendar pc = new PersianCalendar();
DateTime mil;
mil = pc.ToDateTime(int.Parse(value.Substring(0, 4)),
int.Parse(value.Substring(5, 2)), int.Parse(value.Substring(8, 2))
, 0, 0, 0, 0);
return mil;
}
public static string ToShamsi(DateTime value)
{
if (value == DateTime.MinValue)
return string.Empty;
PersianCalendar pc = new PersianCalendar();
return string.Format("{0:0000}/{1:00}/{2:00}",
pc.GetYear(value), pc.GetMonth(value),
pc.GetDayOfMonth(value));
}
public static string ValidateDate(string value)
{
if (value == null)
return "";
int offset = 0;
if (value.Length == 8) //13801010
{
value = value.Insert(4, "/");
value = value.Insert(7, "/");
}
if (int.TryParse(value, out offset))
{
if (offset > 500 || offset < -500)
return "";
return ToShamsi(DateTime.Today.AddDays(offset));
}
else
{
try
{
DateTime val = ToMiladi(value);
if (val < DateTime.Today.AddYears(-5) ||
val > DateTime.Today.AddYears(10))
return "";
return value;
}
catch (Exception)
{
return "";
}
}
}
public static FromToDate GetThisMonth()
{
PersianCalendar pc = new PersianCalendar();
DateTime value = DateTime.Today;
return GetMonth(pc.GetMonth(value));
}
/// <summary>
/// returns date of 1st and last day of month as a
/// FromToDate object
/// </summary>
/// <param name="monthIndex">Index of Mounth 1-based</param>
/// <returns>FromToDate object</returns>
public static FromToDate GetMonth(int monthIndex)
{
PersianCalendar pc = new PersianCalendar();
FromToDate ftd = new FromToDate();
DateTime value = DateTime.Today;
string startShamsi = string.Format("{0:0000}/{1:00}/{2:00}",
pc.GetYear(value), monthIndex,
1);
string endShamsi = string.Format("{0:0000}/{1:00}/{2:00}",
pc.GetYear(value), monthIndex,
pc.GetDaysInMonth(pc.GetYear(value), monthIndex));
ftd.Start = ToMiladi(startShamsi);
ftd.End = ToMiladi(endShamsi);
ftd.startShamsi = startShamsi;
ftd.endShamsi = endShamsi;
return ftd;
}
public static String NextMonth(string currentDate, int dayOfMonth)
{
return NextMonth(currentDate, dayOfMonth, 1);
}
public static String NextMonth(string currentDate, int dayOfMonth, int monthInterval)
{
try
{
PersianCalendar pc = new PersianCalendar();
int year = int.Parse(currentDate.Substring(0, 4));
int month = int.Parse(currentDate.Substring(5, 2));
month += monthInterval;
if (month > 12)
{
year += 1;
month = 1;
}
if (pc.GetDaysInMonth(year, month) < dayOfMonth)
dayOfMonth = pc.GetDaysInMonth(year, month);
return string.Format("{0:0000}/{1:00}/{2:00}", year, month, dayOfMonth);
}
catch (Exception)
{
return "";
}
}
public static string ToPersianNumbers(string number)
{
char[] temp = new char[number.Length];
for (int i = 0; i < number.Length; i++)
{
char value = number[i];
if (value >= 48 && value <= 57)
temp[i] = (char)(value + 1728);
else
temp[i] = value;
}
return new String(temp);
}
public static int GetJalaliWeekNumber(DateTime gregorianDate)
{
PersianCalendar pc = new PersianCalendar();
DateTime gregYearStart = pc.ToDateTime(pc.GetYear(gregorianDate), 1, 1, 0, 0, 0, 0);
int diff = (gregorianDate - gregYearStart).Days;
int wd = ((int)pc.GetDayOfWeek(gregorianDate) + 2) % 7;
return (diff - wd + 10) / 7;
}
}
}

+ 35
- 1
Sevomin.Models/JobViewModel.cs View File

@ -5,6 +5,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Sevomin.Models.Helpers;
using System.ComponentModel;
namespace Sevomin.Models
{
@ -17,17 +18,47 @@ namespace Sevomin.Models
[StringLength(128)]
public string AvalinId { get; set; }
[DisplayName("تاریخ انقضا")]
[DataType(DataType.Date)]
public DateTime ExpireDate { get; set; }
[DisplayName("تاریخ انقضا")]
[DataType(DataType.Date)]
public string JalaliExpireDate
{
get
{
return DateAssist.ToShamsi(this.ExpireDate);
}
set
{
ExpireDate = DateAssist.ValidateAndSetToMiladi(value) ?? DateTime.MinValue;
}
}
[DisplayName("سایر مشخصات")]
public string Description { get; set; }
[DisplayName("نوع رزومه")]
public byte ResumeType { get; set; }
[DisplayName("نام رابط/نماینده شرکت")]
public string ContactPersonName { get; set; }
[DisplayName("تلفن رابط/نماینده شرکت")]
public string ContactPersonPhone { get; set; }
[EmailValidation]
[DisplayName("ایمیل رابط/نماینده شرکت")]
public string ContactPersonEMail { get; set; }
[DisplayName("نمایش نام شرکت")]
public bool ShowCompanyName { get; set; }
[DisplayName("نمایش لوگوی شرکت")]
public bool ShowCompanyLogo { get; set; }
[DisplayName("کار تمام وقت")]
public bool IsFullTime { get; set; }
public IList<JobParameterViewModel> Parameters;
@ -36,7 +67,7 @@ namespace Sevomin.Models
{
this.Id = job.Id;
this.AvalinId = job.AvalinId;
this.ExpireDate = job.ExpireDate;
this.ExpireDate = job.ExpireDate == DateTime.MinValue ? DateTime.Now : job.ExpireDate;
this.Description = job.Description;
this.ResumeType = job.ResumeType;
this.ContactPersonEMail = job.ContactPersonEMail;
@ -46,6 +77,9 @@ namespace Sevomin.Models
this.ShowCompanyName = job.ShowCompanyName;
this.IsFullTime = job.IsFullTime;
if (job.JobParameters == null)
return;
Parameters = new List<JobParameterViewModel>();
foreach (var jp in job.JobParameters)
{


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

@ -63,6 +63,7 @@
<ItemGroup>
<Compile Include="Avalin.cs" />
<Compile Include="Dovomin.cs" />
<Compile Include="Helpers\DateAssist.cs" />
<Compile Include="Helpers\EmailValidationAttribute.cs" />
<Compile Include="Helpers\SevominUserStore.cs" />
<Compile Include="Helpers\SevominUserValidator.cs" />


+ 30
- 11
Sevomin.WebFrontend/Views/Job/JobEditor.cshtml View File

@ -1,4 +1,4 @@
@model Sevomin.Models.JobParameterViewModel
@model Sevomin.Models.JobViewModel
@using (Html.BeginForm("", "", FormMethod.Post, new { role = "form" }))
{
@ -8,26 +8,45 @@
<div class="panel-body">
<div class="col-md-6">
<div class="form-group">
<label for="exampleInputEmail1">نوع رزومه</label>
<input type="email" class="form-control" id="exampleInputEmail1" placeholder="Enter email">
<div class="checkbox">
@*<label for="exampleInputEmail1">تاریخ انقضا</label> <span class="glyphicon glyphicon-exclamation-sign form-help" data-toggle="tooltip" data-for="boogh" data-placement="top" title="این یک راهنما برای این فیلد است"></span>
<input type="text" class="form-control datepickerify" id="boogh" placeholder="Enter email">*@
<label>
@Html.DisplayNameFor(model => model.IsFullTime) @Html.CheckBoxFor(model => model.IsFullTime)
</label>
</div>
</div>
<div class="form-group">
<label for="exampleInputEmail1">نماینده</label>
<input type="email" class="form-control" placeholder="Enter email">
<div class="checkbox">
<label>
@Html.DisplayNameFor(model => model.ShowCompanyName) @Html.CheckBoxFor(model => model.ShowCompanyName)
</label>
</div>
</div>
<div class="form-group">
<div class="checkbox">
<label>
@Html.DisplayNameFor(model => model.ShowCompanyLogo) @Html.CheckBoxFor(model => model.ShowCompanyLogo)
</label>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="exampleInputEmail1">تاریخ انقضا</label> <span class="glyphicon glyphicon-exclamation-sign form-help" data-toggle="tooltip" data-for="boogh" data-placement="top" title="این یک راهنما برای این فیلد است"></span>
<input type="text" class="form-control datepickerify" id="boogh" placeholder="Enter email">
@Html.LabelFor(model => model.JalaliExpireDate)
@Html.TextBoxFor(model => model.JalaliExpireDate, new { @class = "form-control datepickerify" })
</div>
<div class="form-group">
@Html.LabelFor(model => model.ContactPersonName)
@Html.TextBoxFor(model => model.ContactPersonName, new { @class = "form-control" })
</div>
<div class="form-group">
<label for="exampleInputEmail1">محیط کاری</label>
<input type="email" class="form-control" placeholder="Enter email">
@Html.LabelFor(model => model.ContactPersonPhone)
@Html.TextBoxFor(model => model.ContactPersonPhone, new { @class = "form-control" })
</div>
<div class="form-group">
<label for="exampleInputEmail1">محل کار</label>
<input type="email" class="form-control" placeholder="Enter email">
@Html.LabelFor(model => model.ContactPersonEMail)
@Html.TextBoxFor(model => model.ContactPersonEMail, new { @class = "form-control" })
</div>
</div>
</div>


Loading…
Cancel
Save