You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
API/src/Model/Activity.cs

68 lines
2.6 KiB

using System.ComponentModel.DataAnnotations;
namespace Model;
public class Activity
{
public int Id { get; set; }
public string Type { get; set; }
public DateTime Date { get; set; }
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
private int _effort;
[Range(0, 5)]
public int Effort
{
get => _effort;
set
{
if (value < 0 || value > 5)
{
throw new ArgumentException("Effort must be between 0 and 5.");
}
_effort = value;
}
}
public float Variability { get; set; }
public float Variance { get; set; }
public float StandardDeviation { get; set; }
public float Average { get; set; }
public int Maximum { get; set; }
public int Minimum { get; set; }
public float AverageTemperature { get; set; }
public bool HasAutoPause { get; set; }
public Activity(int idActivity ,string type, DateTime date, DateTime startTime, DateTime endTime,
int effort, float variability, float variance, float standardDeviation,
float average, int maximum, int minimum, float averageTemperature, bool hasAutoPause)
{
Id = idActivity;
Type = type;
Date = date;
StartTime = startTime;
EndTime = endTime;
Effort = effort;
Variability = variability;
Variance = variance;
StandardDeviation = standardDeviation;
Average = average;
Maximum = maximum;
Minimum = minimum;
AverageTemperature = averageTemperature;
HasAutoPause = hasAutoPause;
}
public Activity(){}
public override string ToString()
{
return $"Activity #{Id}: {Type} on {Date:d/M/yyyy} from {StartTime:HH:mm:ss} to {EndTime:HH:mm:ss}" +
$" with an effort of {Effort}/5 and an average temperature of {AverageTemperature}°C" +
$" and a heart rate variability of {Variability} bpm" +
$" and a variance of {Variance} bpm" +
$" and a standard deviation of {StandardDeviation} bpm" +
$" and an average of {Average} bpm" +
$" and a maximum of {Maximum} bpm" +
$" and a minimum of {Minimum} bpm" +
$" and auto pause is {(HasAutoPause ? "enabled" : "disabled")}.";
}
}