﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using HockeyApp.Common.Enums;
using HockeyApp.Models.Interfaces;
using HockeyApp.Models.Users;

namespace HockeyApp.Models.Posts
{
    [Table("Posts", Schema = "post")]
    public class Post : ILinkableEntity, IHistoryTrackableEntity
    {
        public long Id { get; set; }

        [Required]
        [StringLength(250)]
        public string Name { get; set; }

        [Required]
        [StringLength(100)]
        public string LinkName { get; set; }

        public string Summary { get; set; }

        [Required]
        [DataType(DataType.MultilineText)]
        public string Content { get; set; }


        public PostState State { get; set; }

        //[Display(Name = "Количество просмотров")]
        //[DefaultValue(0)]
        //public long ViewCount { get; set; }

        [ForeignKey("Moderator")]
        public long? ModeratorId { get; set; }

        public virtual User Moderator { get; set; }

        [DefaultValue(0)]
        public int ReplyCount { get; set; }

        [DefaultValue(0)]
        public int VoteUpCount { get; set; }

        [DefaultValue(0)]
        public int VoteDownCount { get; set; }

        public string Meta { get; set; }

        [Column(TypeName = "datetime")]
        public DateTime CreateDate { get; set; }

        [ForeignKey("Creator")]
        public long CreatorId { get; set; }
        public virtual User Creator { get; set; }


        [ForeignKey("Editor")]
        public long? EditorId { get; set; }
        public virtual User Editor { get; set; }
        public DateTime? EditDate { get; set; }

        public virtual ICollection<Reply> Replies { get; set; }

        public virtual ICollection<PostTag> PostTags { get; set; }
    }
}
