using System.ComponentModel.DataAnnotations;
using System.Collections.Generic;

namespace CARRE_DSS2.Models
{
    public class Patient
    {
        public Patient()
        {
            this.AttachedExperts = new HashSet<ApplicationUser>();
        }

        [Key]
        [Display(Name = "Id")]
        public int Id { get; set; }

        [Display(Name = "User name")]
        public string UserName { get; set; }

        [Display(Name = "Graph name")]
        public string GraphName { get; set; }

        [Display(Name = "Email")]
        public string Email { get; set; }

        [Display(Name = "Token")]
        public string Token { get; set; }

        public virtual ICollection<ApplicationUser> AttachedExperts { get; set; }

        public ICollection<Measurement> getAvailableMeasurments()
        {
            var restFull = new CarreRestFull();
            var restMeasurmentList = restFull.getMeasurmentsList(Token);

            var measurmentList = new HashSet<Measurement>();

            foreach(var m1 in restMeasurmentList)
            {
                var m2 = new Measurement(this, m1.measurement, m1.lastMeasured, m1.firstMeasured);
                measurmentList.Add(m2);
            }

            return measurmentList;
        }
    }
}