Browse Source

jobMiniViewModel

confirmation-email
J 11 years ago
parent
commit
cfb227063a
1 changed files with 64 additions and 4 deletions
  1. +64
    -4
      Sevomin.Models/JobMiniViewModel.cs

+ 64
- 4
Sevomin.Models/JobMiniViewModel.cs View File

@ -1,8 +1,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Sevomin.Models.Helpers;
//استخدام نیروی «کنترل پروژه» با ×× سال سابقه ×× دارای ×مدرک× ×× برای کار در ×کشور×شهر× //استخدام نیروی «کنترل پروژه» با ×× سال سابقه ×× دارای ×مدرک× ×× برای کار در ×کشور×شهر×
namespace Sevomin.Models namespace Sevomin.Models
@ -10,9 +13,66 @@ namespace Sevomin.Models
public class JobMiniViewModel public class JobMiniViewModel
{ {
public string JobTitle { get; set; }
public string Country { get; set; }
public string City { get; set; }
public Tuple<string,string> Experience { get; set; }
private const int MaxNumberOfMiniParams = 6;
[Key]
public long Id { get; set; }
[Required]
[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 bool IsFullTime { get; set; }
public IList<Tuple<string, string>> Parameters;
public JobMiniViewModel(Job job)
{
this.Id = job.Id;
this.AvalinId = job.AvalinId;
this.ExpireDate = job.ExpireDate == DateTime.MinValue ? DateTime.Now.AddDays(14) : job.ExpireDate;
this.IsFullTime = job.IsFullTime;
if (job.JobParameters == null)
return;
Parameters = new List<Tuple<string,string>>();
var jpz = job.JobParameters.Where(x=>x.NumericValue != null).OrderByDescending(x=>x.Moscow).Take(Math.Min(MaxNumberOfMiniParams * 3, job.JobParameters.Count()))
.OrderBy(x => x.Parameter.GroupName).ThenByDescending(x => x.Moscow).Take((int)(MaxNumberOfMiniParams*1.5)).ToList();
for (int i = 0; i < jpz.Count(); i++)
{
string format = jpz[i].Parameter.DisplayFormat;
format = format.Replace("$", jpz[i].Parameter.Name);
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();
}
Parameters.Add(new Tuple<string,string>(format, value));
}
}
} }
} }

Loading…
Cancel
Save