using System;
using System.ComponentModel.DataAnnotations;
using API.Entities.Interfaces;
namespace API.Entities
{
    /// 
    /// Represents the progress a single user has on a given Chapter.
    /// 
    //[Index(nameof(SeriesId), nameof(VolumeId), nameof(ChapterId), nameof(AppUserId), IsUnique = true)]
    public class AppUserProgress : IEntityDate, IHasConcurrencyToken
    {
        /// 
        /// Id of Entity
        /// 
        public int Id { get; set; }
        /// 
        /// Pages Read for given Chapter
        /// 
        public int PagesRead { get; set; }
        /// 
        /// Volume belonging to Chapter
        /// 
        public int VolumeId { get; set; }
        /// 
        /// Series belonging to Chapter
        /// 
        public int SeriesId { get; set; }
        /// 
        /// Chapter
        /// 
        public int ChapterId { get; set; }
        /// 
        /// For Book Reader, represents the nearest passed anchor on the screen that can be used to resume scroll point
        /// on next load
        /// 
        public string BookScrollId { get; set; }
        // Relationships
        /// 
        /// Navigational Property for EF. Links to a unique AppUser
        /// 
        public AppUser AppUser { get; set; }
        /// 
        /// User this progress belongs to
        /// 
        public int AppUserId { get; set; }
        /// 
        /// When this was first created
        /// 
        public DateTime Created { get; set; }
        /// 
        /// Last date this was updated
        /// 
        public DateTime LastModified { get; set; }
        /// 
        [ConcurrencyCheck]
        public uint RowVersion { get; private set; }
        /// 
        public void OnSavingChanges()
        {
            RowVersion++;
        }
    }
}