using System;
using System.Collections.Generic;
using Sockeye.Biz;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json;

namespace Sockeye.Models
{
    //NOTE: Any non required field (nullable in DB) sb nullable here, i.e. decimal? not decimal, 
    //otherwise the server will call it an invalid record if the field isn't sent from client

    public class Review : ICoreBizObjectModel
    {
        public long Id { get; set; }
        public uint Concurrency { get; set; }

        [Required]
        public string Name { get; set; }
        // public bool Active { get; set; }//NOT USED
        public string Notes { get; set; }
        public string Wiki { get; set; }
        public string CustomFields { get; set; }
        public List<string> Tags { get; set; }

        [Required]
        public DateTime ReviewDate { get; set; }
        public DateTime? CompletedDate { get; set; }
        public string CompletionNotes { get; set; }
        [Required]
        public long UserId { get; set; }
        [NotMapped]
        public string UserViz { get; set; }
        [Required]
        public long AssignedByUserId { get; set; }
        [NotMapped]
        public string AssignedByUserViz { get; set; }

        [Required]
        public long ObjectId { get; set; }
        [Required]
        public SockType SockType { get; set; }//int
        [NotMapped]
        public string ReviewObjectViz { get; set; }

        [NotMapped]
        public bool OverDue
        {
            get
            {
                return (ReviewDate > DateTime.UtcNow);
            }
        }


        public Review()
        {
            Tags = new List<string>();
        }

        [NotMapped, JsonIgnore]
        public SockType SType { get => SockType.Review; }

    }//eoc

}//eons
/*
DATES should be indexed for fast viewing
CREATE TABLE [dbo].[ASCHEDULEMARKER](
	[AID] [uniqueidentifier] NOT NULL,
	[ACREATED] [datetime] NOT NULL,
	[ACREATOR] [uniqueidentifier] NOT NULL,
	[AMODIFIER] [uniqueidentifier] NOT NULL,
	[ANAME] [nvarchar](255) NULL,
	[ANOTES] [ntext] NULL,
	[AMODIFIED] [datetime] NULL,
	[ASTARTDATE] [datetime] NULL,
	[ASTOPDATE] [datetime] NULL,
	[ASCHEDULEMARKERSOURCETYPE] [smallint] NULL,
	[ASOURCEID] [uniqueidentifier] NOT NULL,
	[AARGB] [int] NULL,
	[AFOLLOWID] [uniqueidentifier] NULL,
	[AFOLLOWTYPE] [smallint] NULL,
	[ACOMPLETED] [bit] NOT NULL,

*/