//--------------------------------------------------------------------
//     此代码由T4模板自动生成  byzhouhang 20210918
//	   生成时间 2022-03-04 13:33:45 
//     对此文件的更改可能会导致不正确的行为，并且如果重新生成代码，这些更改将会丢失。
//--------------------------------------------------------------------
using IRaCIS.Core.Domain.Share;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using IRaCIS.Core.Application.Contracts.DTO;
using Newtonsoft.Json;

namespace IRaCIS.Core.Application.ViewModel
{
    /// <summary> TrialExternalUserView  列表视图模型 </summary>
    public class TrialExternalUserView : TrialExternalUserAddOrEdit
    {

        public DateTime CreateTime { get; set; }
        public Guid CreateUserId { get; set; }
        public DateTime UpdateTime { get; set; }
        public Guid UpdateUserId { get; set; }

        public bool IsSystemUser { get; set; }


        public Guid SystemUserId { get; set; }



        [JsonIgnore]
        public TrialExternalUserStateEnum InviteState { get; set; }


        public TrialExternalUserStateEnum State
        {
            get
            {
                if (InviteState == TrialExternalUserStateEnum.HasSend && ExpireTime != null && ExpireTime < DateTime.Now)
                { 
                    return TrialExternalUserStateEnum.OverTime; 
                }
                else
                {
                    return InviteState;
                }
            }
        }




        public UserTypeEnum? UserTypeEnum { get; set; }

        public DateTime? ExpireTime { get; set; }

        public bool? IsJoin { get; set; }

        public DateTime? ConfirmTime { get; set; }

        public string RejectReason { get; set; } = string.Empty;
    }

    ///<summary>TrialExternalUserQuery  列表查询参数模型</summary>
    public class TrialExternalUserQuery
    {
        public Guid TrialId { get; set; }

        public string Phone { get; set; } = string.Empty;
        public string Email { get; set; } = string.Empty;

        public string Name { get; set; } = string.Empty;


    }

    ///<summary> TrialExternalUserAddOrEdit  列表查询参数模型</summary>
    public class TrialExternalUserAddOrEdit 
    {
        public Guid? Id { get; set; }

        [NotDefault]
        public Guid TrialId { get; set; }

        public string OrganizationName { get; set; } = String.Empty;


        [NotDefault]
        public Guid UserTypeId { get; set; }

        public string Email { get; set; } = string.Empty;

        public string Phone { get; set; } = string.Empty;

        public string FirstName { get; set; } = string.Empty;
        public string LastName { get; set; } = string.Empty;



        //public bool IsSendEmail { get; set; }

        //public string RouteUrl { get; set; } = string.Empty;


    }


    public class TrialExternalUserAddAndSendEmail: TrialExternalUserAddOrEdit
    {
        public bool IsSendEmail { get; set; }

        public string BaseUrl { get; set; } = string.Empty;

        public string RouteUrl { get; set; } = string.Empty;
    }


    public class TrialExternalUserConfirm
    {
        public string BaseUrl { get; set; } = string.Empty;

        [NotDefault]
        public Guid Id { get; set; }

        public bool? IsJoin { get; set; }

        public DateTime? ConfirmTime { get; set; }

        public string RejectReason { get; set; } = string.Empty;

    }

    public class TrialSiteUserSurveyUserConfirm : TrialExternalUserConfirm
    {
        //[NotDefault]
        //public Guid TrialId { get; set; }

        //[NotDefault]
        //public  Guid SiteId { get; set; }
    }


    public class TrialInfoWithPreparationInfo : TrialExternalUserConfirm
    {

        public string ExperimentName { get; set; } = string.Empty;

        public string TrialCode { get; set; } = string.Empty;

        public string Indication { get; set; } = string.Empty;

        public string ResearchProgramNo { get; set; } = string.Empty;

        public Guid UserId { get; set; }

        public Guid TrialId { get; set; }
    }

    public class TrialExternalUserSendEmail
    {
        [NotDefault]
        public Guid TrialId { get; set; }

        public string BaseUrl { get; set; } = string.Empty;

        public string RouteUrl { get; set; } = string.Empty;

        public List<UserEmail> SendUsers { get; set; } = new List<UserEmail>();
    }

    public class UserEmail
    {
        public Guid Id { get; set; }

        public string Email { get; set; } = string.Empty;

        public bool IsSystemUser { get; set; }

        [NotDefault]
        public Guid SystemUserId { get; set; }

    }




}


