using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using edu.jhu.Cas.Util;
using Newtonsoft.Json;

namespace RestApi.Models
{
    public class UserInfo
    {
        public string UserId { get; set; }
        
        public string FullName { get; set; }
        
        public string Email { get; set; }
        
        [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
        public string Password { get; set; }

        [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
        public string MyDBHost { get; set; }

        [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
        public string MyDBName { get; set; }

        public long? WebServicesId { get; set; }


        public static UserInfo FromCJUser(CJUser cju)
        {
            UserInfo info = new UserInfo();
            info.UserId = cju.UserID;
            info.FullName = cju.Name;
            info.Email = cju.Email;
            info.Password = null;
            info.WebServicesId = cju.WebServicesID;
            info.MyDBHost = null;
            info.MyDBName = null;
            return info;
        }

        public static UserInfo FromUser(User cju)
        {
            UserInfo info = new UserInfo();
            info.UserId = cju.UserID;
            info.FullName = cju.Name;
            info.Email = cju.Email;
            info.Password = null;
            info.WebServicesId = cju.WebServicesID;
            info.MyDBHost = cju.MyDBHost;
            info.MyDBName = cju.MyDBName;
            return info;
        }
    }
}