using Sevomin.Models.Helpers;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Sevomin.Models
{
    public class DovominJobViewModel
    {        
        public long Id { get; set; }

        public string DovominId { get; set; }

        public long JobId { get; set; }
        
        public DateTime ApplyDate { get; set; }
        
        public string JalaliApplyDate 
        {
            get
            {
                return DateAssist.ToShamsi(this.ApplyDate);
            }
            set
            {
                ApplyDate = DateAssist.ValidateAndSetToMiladi(value) ?? DateTime.MinValue;
            }
        }
                
        [DisplayName("یادداشت برای کارفرما")]
        public string CoverLetter { get; set; }

        public decimal Affinity { get; set; }

        public bool MinimumRequirement { get; set; }

        public DateTime? AvalinSeen { get; set; }

        public string JalaliAvalinSeen
        {
            get
            {
                if(AvalinSeen.HasValue)
                    return DateAssist.ToShamsi(this.AvalinSeen.Value);

                return null;
            }
            set
            {
                AvalinSeen = DateAssist.ValidateAndSetToMiladi(value) ?? DateTime.MinValue;
            }
        }

        public string AvalinComment { get; set; }

        public bool AvalinDelete { get; set; }

        public DovominJobViewModel(DovominJob dovominJob)
        {
            this.Id = dovominJob.Id;
            this.DovominId = dovominJob.DovominId;
            this.JobId = dovominJob.JobId;
            this.ApplyDate = dovominJob.ApplyDate;
            this.CoverLetter = dovominJob.CoverLetter;
            this.Affinity = dovominJob.Affinity;
            this.MinimumRequirement = dovominJob.MinimumRequirement;
            this.AvalinSeen = dovominJob.AvalinSeen;
            this.AvalinComment = dovominJob.AvalinComment;
            this.AvalinDelete = dovominJob.AvalinDelete;
        }

        public DovominJobViewModel()
        {

        }
    }
}