@ -0,0 +1,62 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.ComponentModel.DataAnnotations; | |||
using System.ComponentModel.DataAnnotations.Schema; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace Sevomin.Models | |||
{ | |||
public class DovominParameter | |||
{ | |||
[Key] | |||
public long Id { get; set; } | |||
[Index("IX_DovominParameterUniqueIndex", Order = 1, IsUnique = true)] | |||
[Required] | |||
public long ParameterId { get; set; } | |||
[Index] | |||
[Index("IX_DovominParameterUniqueIndex", Order=2, IsUnique=true)] | |||
[Required] | |||
[StringLength(128)] | |||
public string DovominId { get; set; } | |||
public string StringValue { get; private set; } | |||
public decimal? NumericValue { get; private set; } | |||
public byte Moscow { get; set; } | |||
public virtual Parameter Parameter { get; set; } | |||
public virtual Dovomin Dovomin { get; set; } | |||
public DovominParameter() | |||
{} | |||
public DovominParameter(Dovomin dovomin, Parameter parameter) | |||
{ | |||
this.Dovomin = dovomin; | |||
this.Parameter = parameter; | |||
this.StringValue = ""; | |||
this.NumericValue = null; | |||
this.Moscow = 0; | |||
} | |||
public void SetValue(string value) | |||
{ | |||
decimal val; | |||
if (decimal.TryParse(value, out val)) | |||
{ | |||
NumericValue = val; | |||
StringValue = value; | |||
} | |||
else | |||
{ | |||
NumericValue = null; | |||
StringValue = value; | |||
} | |||
} | |||
} | |||
} |
@ -0,0 +1,53 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.ComponentModel.DataAnnotations; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace Sevomin.Models | |||
{ | |||
public class DovominParameterViewModel | |||
{ | |||
public string StringValue { get; private set; } | |||
public byte MoscowValue { get; set; } | |||
public long Id { get; set; } | |||
public long ParameterId { get; set; } | |||
public string DovominId { get; set; } | |||
public string ParameterName { get; set; } | |||
public bool HasMoscow { get; set; } | |||
public byte DisplayMethod { get; set; } | |||
public string GroupName { get; set; } | |||
public string CommentAvalin { get; set; } | |||
public string CommentDovomin { get; set; } | |||
public IList<Tuple<decimal,string>> ParameterValues { get; set; } | |||
public DovominParameterViewModel(DovominParameter dp) | |||
{ | |||
StringValue = dp.StringValue; | |||
MoscowValue = dp.Moscow; | |||
Id = dp.Id; | |||
ParameterId = dp.Parameter.Id; | |||
DovominId = dp.Dovomin.Id; | |||
ParameterName = dp.Parameter.Name; | |||
HasMoscow = dp.Parameter.Moscow; | |||
DisplayMethod = dp.Parameter.DisplayMethod; | |||
GroupName = dp.Parameter.GroupName; | |||
CommentAvalin = dp.Parameter.CommentAvalin; | |||
CommentDovomin = dp.Parameter.CommentDovomin; | |||
ParameterValues = new List<Tuple<decimal, string>>(); | |||
foreach (var val in dp.Parameter.ParameterValues) | |||
{ | |||
ParameterValues.Add(new Tuple<decimal, string>(val.NumbericValue, val.Value)); | |||
} | |||
} | |||
} | |||
} |
@ -0,0 +1,81 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.ComponentModel.DataAnnotations; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using Sevomin.Models.Helpers; | |||
using System.ComponentModel; | |||
namespace Sevomin.Models | |||
{ | |||
public class DovominViewModel | |||
{ | |||
[Required] | |||
[StringLength(128)] | |||
public string Id { get; set; } | |||
[DisplayName("نام")] | |||
public string FirstName { get; set; } | |||
[DisplayName("نام خانوادگی")] | |||
public string LastName { get; set; } | |||
[DisplayName("تاریخ تولد")] | |||
[DataType(DataType.Date)] | |||
public DateTime BirthDate { get; set; } | |||
[DisplayName("تاریخ تولد")] | |||
[DataType(DataType.Date)] | |||
public string JalaliBirthDate | |||
{ | |||
get | |||
{ | |||
return DateAssist.ToShamsi(this.BirthDate); | |||
} | |||
set | |||
{ | |||
BirthDate = DateAssist.ValidateAndSetToMiladi(value) ?? DateTime.MinValue; | |||
} | |||
} | |||
[DisplayName("دورههای آموزشی")] | |||
public string Description { get; set; } | |||
[DisplayName("رزومه انگلیسی")] | |||
public string EnglishResume { get; set; } | |||
[DisplayName("رزومه فارسی")] | |||
public string PersianResume { get; set; } | |||
[DisplayName("تمام وقت")] | |||
public bool IsFullTime { get; set; } | |||
[DisplayName("پاره وقت")] | |||
public bool IsPartTime { get; set; } | |||
public IList<DovominParameterViewModel> Parameters; | |||
public DovominViewModel(Dovomin dovomin) | |||
{ | |||
this.Id = dovomin.Id; | |||
this.FirstName = dovomin.FirstName; | |||
this.LastName = dovomin.LastName; | |||
this.IsFullTime = dovomin.IsFulltime; | |||
this.IsPartTime = dovomin.IsPartTime; | |||
this.BirthDate = dovomin.BirthDate == DateTime.MinValue ? DateTime.Now : dovomin.BirthDate; | |||
this.Description = dovomin.Description; | |||
this.EnglishResume = dovomin.EnglishResume; | |||
this.PersianResume = dovomin.PersianResume; | |||
if (dovomin.DovominParameters == null) | |||
return; | |||
Parameters = new List<DovominParameterViewModel>(); | |||
foreach (var jp in dovomin.DovominParameters) | |||
{ | |||
Parameters.Add(new DovominParameterViewModel(jp)); | |||
} | |||
} | |||
} | |||
} |
@ -0,0 +1,29 @@ | |||
// <auto-generated /> | |||
namespace Sevomin.Models.Migrations | |||
{ | |||
using System.CodeDom.Compiler; | |||
using System.Data.Entity.Migrations; | |||
using System.Data.Entity.Migrations.Infrastructure; | |||
using System.Resources; | |||
[GeneratedCode("EntityFramework.Migrations", "6.1.0-30225")] | |||
public sealed partial class DovominParameter : IMigrationMetadata | |||
{ | |||
private readonly ResourceManager Resources = new ResourceManager(typeof(DovominParameter)); | |||
string IMigrationMetadata.Id | |||
{ | |||
get { return "201403300806354_DovominParameter"; } | |||
} | |||
string IMigrationMetadata.Source | |||
{ | |||
get { return null; } | |||
} | |||
string IMigrationMetadata.Target | |||
{ | |||
get { return Resources.GetString("Target"); } | |||
} | |||
} | |||
} |
@ -0,0 +1,50 @@ | |||
namespace Sevomin.Models.Migrations | |||
{ | |||
using System; | |||
using System.Data.Entity.Migrations; | |||
public partial class DovominParameter : DbMigration | |||
{ | |||
public override void Up() | |||
{ | |||
CreateTable( | |||
"dbo.DovominParameters", | |||
c => new | |||
{ | |||
Id = c.Long(nullable: false, identity: true), | |||
ParameterId = c.Long(nullable: false), | |||
DovominId = c.String(nullable: false, maxLength: 128), | |||
StringValue = c.String(), | |||
NumericValue = c.Decimal(precision: 18, scale: 2), | |||
Moscow = c.Byte(nullable: false), | |||
}) | |||
.PrimaryKey(t => t.Id) | |||
.ForeignKey("dbo.Dovomin", t => t.DovominId) | |||
.ForeignKey("dbo.Parameters", t => t.ParameterId, cascadeDelete: true) | |||
.Index(t => new { t.ParameterId, t.DovominId }, unique: true, name: "IX_DovominParameterUniqueIndex") | |||
.Index(t => t.DovominId); | |||
AddColumn("dbo.Dovomin", "BirthDate", c => c.DateTime(nullable: false)); | |||
AddColumn("dbo.Dovomin", "IsFulltime", c => c.Boolean(nullable: false)); | |||
AddColumn("dbo.Dovomin", "IsPartTime", c => c.Boolean(nullable: false)); | |||
AddColumn("dbo.Dovomin", "Description", c => c.String()); | |||
AddColumn("dbo.Dovomin", "EnglishResume", c => c.String()); | |||
AddColumn("dbo.Dovomin", "PersianResume", c => c.String()); | |||
} | |||
public override void Down() | |||
{ | |||
DropForeignKey("dbo.DovominParameters", "ParameterId", "dbo.Parameters"); | |||
DropForeignKey("dbo.DovominParameters", "DovominId", "dbo.Dovomin"); | |||
DropIndex("dbo.DovominParameters", new[] { "DovominId" }); | |||
DropIndex("dbo.DovominParameters", "IX_DovominParameterUniqueIndex"); | |||
DropColumn("dbo.Dovomin", "PersianResume"); | |||
DropColumn("dbo.Dovomin", "EnglishResume"); | |||
DropColumn("dbo.Dovomin", "Description"); | |||
DropColumn("dbo.Dovomin", "IsPartTime"); | |||
DropColumn("dbo.Dovomin", "IsFulltime"); | |||
DropColumn("dbo.Dovomin", "BirthDate"); | |||
DropTable("dbo.DovominParameters"); | |||
} | |||
} | |||
} |