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.

89 lines
3.2 KiB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 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. //استخدام نیروی «کنترل پروژه» با ×× سال سابقه ×× دارای ×مدرک× ×× برای کار در ×کشور×شهر×
  8. namespace Sevomin.Models
  9. {
  10. public class JobMiniViewModel
  11. {
  12. private int MaxNumberOfMiniParams = 6;
  13. [Key]
  14. public long Id { get; set; }
  15. [Required]
  16. [StringLength(128)]
  17. public string AvalinId { get; set; }
  18. public string AvalinUsername { get; set; }
  19. [DisplayName("آخرین مهلت اعلام آمادگی")]
  20. [DataType(DataType.Date)]
  21. public DateTime ExpireDate { get; set; }
  22. [DisplayName("آخرین مهلت اعلام آمادگی")]
  23. [DataType(DataType.Date)]
  24. public string JalaliExpireDate
  25. {
  26. get
  27. {
  28. return DateAssist.ToShamsi(this.ExpireDate);
  29. }
  30. set
  31. {
  32. ExpireDate = DateAssist.ValidateAndSetToMiladi(value) ?? DateTime.MinValue;
  33. }
  34. }
  35. [DisplayName("کار تمام وقت")]
  36. public bool IsFullTime { get; set; }
  37. public bool ShowCompanyLogo { get; set; }
  38. public bool ShowCompanyName { get; set; }
  39. public string CompanyName { get; set; }
  40. public string CompanyLogo { get; set; }
  41. public IList<Tuple<string, string>> Parameters;
  42. public JobMiniViewModel(Job job, int maxNumberOfMiniParams = 6)
  43. {
  44. this.MaxNumberOfMiniParams = maxNumberOfMiniParams;
  45. this.Id = job.Id;
  46. this.AvalinId = job.AvalinId;
  47. this.ExpireDate = job.ExpireDate == DateTime.MinValue ? DateTime.Now.AddDays(14) : job.ExpireDate;
  48. this.IsFullTime = job.IsFullTime;
  49. this.AvalinUsername = job.Avalin.UserName;
  50. this.ShowCompanyLogo = job.ShowCompanyLogo;
  51. this.ShowCompanyName = job.ShowCompanyName;
  52. if (this.ShowCompanyName)
  53. this.CompanyName = job.Avalin.DisplayName;
  54. if (job.JobParameters == null)
  55. return;
  56. Parameters = new List<Tuple<string,string>>();
  57. var jpz = job.JobParameters.Where(x=>!string.IsNullOrWhiteSpace(x.StringValue)).OrderByDescending(x=>x.Moscow).Take(Math.Min(MaxNumberOfMiniParams * 3, job.JobParameters.Count()))
  58. .OrderBy(x => x.Parameter.GroupName).ThenByDescending(x => x.Moscow).Take((int)(MaxNumberOfMiniParams*1.5)).ToList();
  59. for (int i = 0; i < jpz.Count(); i++)
  60. {
  61. string format = jpz[i].Parameter.DisplayFormat;
  62. format = format.Replace("$", jpz[i].Parameter.Name);
  63. string value = jpz[i].StringValue;
  64. if (jpz[i].Parameter.DisplayMethod == 4)
  65. {
  66. value = jpz[i].Parameter.ParameterValues.ToList().Where(x =>x.NumbericValue == jpz[i].NumericValue).Select(x => x.Value)
  67. .FirstOrDefault();
  68. }
  69. Parameters.Add(new Tuple<string,string>(format, value));
  70. }
  71. }
  72. }
  73. }