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

namespace YBDevice.NApi.Application.MeasureInfo
{

    /// <summary>
    /// 记录对比
    /// </summary>
    public class ResultDiffC2SDto : IValidatableObject
    {
        /// <summary>
        /// 第一个记录ID
        /// </summary>
        [Required(ErrorMessage = "请选择第一条记录")]
        public Guid FirstId { get; set; }
        /// <summary>
        /// 第二个记录ID
        /// </summary>
        [Required(ErrorMessage = "请选择第二条记录")]
        public Guid SecondId { get; set; }
        /// <summary>
        /// 设备类型
        /// </summary>
        public int DevType { get; set; } = 1;
        /// <summary>
        /// 家庭成员ID
        /// </summary>
        public int FamilyId { get; set; }
        /// <summary>
        /// 验证
        /// </summary>
        /// <param name="validationContext"></param>
        /// <returns></returns>
        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            if (FamilyId <= 0)
            {
                yield return new ValidationResult("请先选择家庭成员", new[] { nameof(FamilyId) });
            }
            if(FirstId == SecondId)
            {
                yield return new ValidationResult("请选择两条不同的数据", new[] { nameof(FirstId) });
            }
        }
    }
    /// <summary>
    /// 测量记录详情
    /// </summary>
    public class ResultDetailC2SDto
    {
        /// <summary>
        /// 测量记录ID
        /// </summary>
        public Guid Id { get; set; }
    }
    /// <summary>
    /// 记录对比返回值
    /// </summary>
    public class ResultDiffS2CDto
    {
        /// <summary>
        /// 时间
        /// </summary>
        public string Time { get; set; }
        /// <summary>
        /// 头像
        /// </summary>
        public string HeadImg { get; set; }
        /// <summary>
        /// 昵称
        /// </summary>
        public string NickName { get; set; }
        /// <summary>
        /// 性别,1-男,2-女
        /// </summary>
        public GenderType Sex { get; set; }
        /// <summary>
        /// 天数
        /// </summary>
        public int Day { get; set; }
        /// <summary>
        /// 体重差
        /// </summary>
        public decimal WeightDiff { get; set; }
        /// <summary>
        /// 减脂差
        /// </summary>
        public decimal Fat_WDiff { get; set; }
        /// <summary>
        /// 第一个记录测量项
        /// </summary>
        public ResultDiffItemS2SDto FirstResult { get; set; }
        /// <summary>
        /// 第二个记录测量项
        /// </summary>
        public ResultDiffItemS2SDto SecondResult { get; set; }
    }
    /// <summary>
    /// 测量 项
    /// </summary>
    public class ResultDiffItemS2SDto: UserMeasureModel
    {

    }

    /// <summary>
    /// 删除测量记录
    /// </summary>
    public class DeleteResultC2SDto : IValidatableObject
    {
        /// <summary>
        /// 测量记录ID
        /// </summary>
        [Required(ErrorMessage = "请先选择记录")]
        public Guid Id { get; set; }

        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            if (Id == Guid.Empty)
            {
                yield return new ValidationResult("请先选择记录", new[] { nameof(Id) });
            }
        }
    }
}
