You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
3.5 KiB

10 years ago
  1. using Sevomin.Models.Helpers;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.ComponentModel.DataAnnotations;
  6. using System.Linq;
  7. namespace Sevomin.Models
  8. {
  9. public class JobViewModel
  10. {
  11. [Key]
  12. public long Id { get; set; }
  13. [Required]
  14. [StringLength(128)]
  15. public string AvalinId { get; set; }
  16. [DisplayName("تاریخ انقضا")]
  17. [DataType(DataType.Date)]
  18. public DateTime ExpireDate { get; set; }
  19. [DisplayName("تاریخ انقضا")]
  20. [DataType(DataType.Date)]
  21. public string JalaliExpireDate
  22. {
  23. get
  24. {
  25. return DateAssist.ToShamsi(this.ExpireDate);
  26. }
  27. set
  28. {
  29. ExpireDate = DateAssist.ValidateAndSetToMiladi(value) ?? DateTime.MinValue;
  30. }
  31. }
  32. [DisplayName("تاریخ ایجاد")]
  33. [DataType(DataType.Date)]
  34. public DateTime CreateDate { get; set; }
  35. [DisplayName("تاریخ ایجاد")]
  36. [DataType(DataType.Date)]
  37. public string JalaliCreateDate
  38. {
  39. get
  40. {
  41. return DateAssist.ToShamsi(this.CreateDate);
  42. }
  43. set
  44. {
  45. CreateDate = DateAssist.ValidateAndSetToMiladi(value) ?? DateTime.MinValue;
  46. }
  47. }
  48. [DisplayName("سایر مشخصات")]
  49. public string Description { get; set; }
  50. [DisplayName("نوع رزومه")]
  51. public byte ResumeType { get; set; }
  52. [DisplayName("نام رابط/نماینده شرکت")]
  53. public string ContactPersonName { get; set; }
  54. [DisplayName("تلفن رابط/نماینده شرکت")]
  55. public string ContactPersonPhone { get; set; }
  56. [EmailValidation]
  57. [DisplayName("ایمیل رابط/نماینده شرکت")]
  58. public string ContactPersonEMail { get; set; }
  59. [DisplayName("نمایش نام شرکت")]
  60. public bool ShowCompanyName { get; set; }
  61. [DisplayName("نمایش لوگوی شرکت")]
  62. public bool ShowCompanyLogo { get; set; }
  63. [DisplayName("کار تمام وقت")]
  64. public bool IsFullTime { get; set; }
  65. public IList<JobParameterViewModel> Parameters;
  66. public JobViewModel(Job job)
  67. {
  68. this.Id = job.Id;
  69. this.AvalinId = job.AvalinId;
  70. this.ExpireDate = job.ExpireDate == DateTime.MinValue ? DateTime.UtcNow.AddDays(14) : job.ExpireDate;
  71. this.CreateDate = job.CreateDate == DateTime.MinValue ? DateTime.UtcNow : job.CreateDate;
  72. this.Description = job.Description;
  73. this.ResumeType = job.ResumeType;
  74. this.ContactPersonEMail = job.ContactPersonEMail;
  75. this.ContactPersonName = job.ContactPersonName;
  76. this.ContactPersonPhone = job.ContactPersonPhone;
  77. this.ShowCompanyLogo = job.ShowCompanyLogo;
  78. this.ShowCompanyName = job.ShowCompanyName;
  79. this.IsFullTime = job.IsFullTime;
  80. if (job.JobParameters == null)
  81. return;
  82. Parameters = new List<JobParameterViewModel>();
  83. foreach (var jp in job.JobParameters)
  84. {
  85. Parameters.Add(new JobParameterViewModel(jp));
  86. }
  87. Parameters = Parameters.OrderBy(x => x.GroupName).ToList();
  88. }
  89. }
  90. }