702 lines
16 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using gehGassiApp.Domain.Base;
using gehGassiApp.Domain.Common;
namespace gehGassiApp.Domain.Dogs
{
/// <summary>
/// Repräsentiert einen Hund
/// </summary>
public class Dog : SyncEntity
{
private DogSex _sex;
private string _name;
private string _description;
private string _photo;
private DateTimeOffset? _birthDate;
private DogSize _size;
private bool _pullsTheLeash;
private bool _walksTheLeash;
private bool _basicCommands;
private bool _hunter;
private bool _eating;
private bool _jumper;
private bool _likesAdults;
private bool _likesChildren;
private bool _likesConspecifics;
private bool _isTrustful;
private bool _isAggressiv;
private bool _isLoneGunner;
private DogAggressionLevel _aggressionLevel;
private bool _rushesOutside;
private bool _isCalm;
private bool _isPeeing;
private bool _isShy;
private bool _isGuard;
private string _intolerances;
private bool _chiped;
private bool _sterilized;
private string _medicalInfo;
private bool _houseTrained;
private DogFeedingTimes _feedingTimes;
private string _feedingIndividual;
private RatingStatistics _ratingStatistics;
private bool _blocked;
private bool _locked;
/// <summary>
/// Id der Hunderasse
/// </summary>
[MaxLength(128)]
public string DogRaceId { get; set; }
/// <summary>
/// Id des App-Users
/// </summary>
[Required]
[MaxLength(128)]
public string AppUserId { get; set; }
#region Basis
/// <summary>
/// Nummer des Hundes
/// </summary>
[Required]
[MaxLength(100)]
public string Number { get; set; }
/// <summary>
/// Name des Hundes
/// </summary>
[Required]
[MaxLength(100)]
public string Name
{
get => _name;
set
{
_name = value;
OnPropertyChanged();
}
}
/// <summary>
/// Optional: Beschreibung
/// </summary>
[MaxLength(5000)]
public string Description
{
get => _description;
set
{
_description = value;
OnPropertyChanged();
}
}
/// <summary>
/// Optional - Foto des Hundes
/// </summary>
[MaxLength(500)]
public string Photo
{
get
{
if (string.IsNullOrWhiteSpace(_photo))
return string.Empty;
if (!_photo.ToLower().StartsWith("http"))
{
if (!File.Exists(_photo))
return Path.Combine(FileSystem.AppDataDirectory, Path.GetFileName(_photo) ?? string.Empty);
}
return _photo;
}
set
{
_photo = value;
OnPropertyChanged();
}
}
/// <summary>
/// Geburtstag des Hundes
/// </summary>
public DateTimeOffset? BirthDate
{
get => _birthDate;
set
{
_birthDate = value;
OnPropertyChanged();
}
}
/// <summary>
/// Geschlecht des Hundes
/// </summary>
[Required]
public DogSex Sex
{
get => _sex;
set
{
_sex = value;
OnPropertyChanged();
}
}
/// <summary>
/// Größe des Hundes
/// </summary>
[Required]
public DogSize Size
{
get => _size;
set
{
_size = value;
OnPropertyChanged();
}
}
#endregion
#region Eigenschaften beim Gassi gehen
/// <summary>
/// Zieht an der Leine
/// </summary>
[Required]
public bool PullsTheLeash
{
get => _pullsTheLeash;
set
{
_pullsTheLeash = value;
OnPropertyChanged();
}
}
/// <summary>
/// Geht an der Leine
/// </summary>
[Required]
public bool WalksTheLeash
{
get => _walksTheLeash;
set
{
_walksTheLeash = value;
OnPropertyChanged();
}
}
/// <summary>
/// Kennt die Grundkommandos
/// </summary>
[Required]
public bool BasicCommands
{
get => _basicCommands;
set
{
_basicCommands = value;
OnPropertyChanged();
}
}
/// <summary>
/// Jagd andere Tiere
/// </summary>
[Required]
public bool Hunter
{
get => _hunter;
set
{
_hunter = value;
OnPropertyChanged();
}
}
/// <summary>
/// Versucht alles zu essen
/// </summary>
[Required]
public bool Eating
{
get => _eating;
set
{
_eating = value;
OnPropertyChanged();
}
}
/// <summary>
/// Springt Menschen an
/// </summary>
[Required]
public bool Jumper
{
get => _jumper;
set
{
_jumper = value;
OnPropertyChanged();
}
}
#endregion
#region Persönlichkeit
/// <summary>
/// Mag Erwachsene
/// </summary>
[Required]
public bool LikesAdults
{
get => _likesAdults;
set
{
_likesAdults = value;
OnPropertyChanged();
}
}
/// <summary>
/// Mag Kinder
/// </summary>
[Required]
public bool LikesChildren
{
get => _likesChildren;
set
{
_likesChildren = value;
OnPropertyChanged();
}
}
/// <summary>
/// Mag Artgenossen
/// </summary>
[Required]
public bool LikesConspecifics
{
get => _likesConspecifics;
set
{
_likesConspecifics = value;
OnPropertyChanged();
}
}
/// <summary>
/// Ist zutraulich
/// </summary>
[Required]
public bool IsTrustful
{
get => _isTrustful;
set
{
_isTrustful = value;
OnPropertyChanged();
}
}
/// <summary>
/// Ist aggressiv
/// </summary>
[Required]
public bool IsAggressiv
{
get => _isAggressiv;
set
{
_isAggressiv = value;
OnPropertyChanged();
}
}
/// <summary>
/// Ist ein Einzelgänger
/// </summary>
[Required]
public bool IsLoneGunner
{
get => _isLoneGunner;
set
{
_isLoneGunner = value;
OnPropertyChanged();
}
}
/// <summary>
/// Aggressionsgrad des Hundes, wenn aggressiv
/// </summary>
[Required]
public DogAggressionLevel AggressionLevel
{
get => _aggressionLevel;
set
{
_aggressionLevel = value;
OnPropertyChanged();
}
}
#endregion
#region Verhalten wenn jemand das Haus betritt
/// <summary>
/// Stürmt nach draussen
/// </summary>
[Required]
public bool RushesOutside
{
get => _rushesOutside;
set
{
_rushesOutside = value;
OnPropertyChanged();
}
}
/// <summary>
/// Ist ruhig und entspannt
/// </summary>
[Required]
public bool IsCalm
{
get => _isCalm;
set
{
_isCalm = value;
OnPropertyChanged();
}
}
/// <summary>
/// Pinkelt vor Aufregung
/// </summary>
[Required]
public bool IsPeeing
{
get => _isPeeing;
set
{
_isPeeing = value;
OnPropertyChanged();
}
}
/// <summary>
/// Ist schüchtern
/// </summary>
[Required]
public bool IsShy
{
get => _isShy;
set
{
_isShy = value;
OnPropertyChanged();
}
}
/// <summary>
/// Bewacht das zuhause
/// </summary>
[Required]
public bool IsGuard
{
get => _isGuard;
set
{
_isGuard = value;
OnPropertyChanged();
}
}
#endregion
#region Medical
/// <summary>
/// Unverträglichkeiten
/// </summary>
[MaxLength(5000)]
public string Intolerances
{
get => _intolerances;
set
{
_intolerances = value;
OnPropertyChanged();
}
}
/// <summary>
/// Ist gechipt
/// </summary>
[Required]
public bool Chiped
{
get => _chiped;
set
{
_chiped = value;
OnPropertyChanged();
}
}
/// <summary>
/// Ist sterilisiert?
/// </summary>
[Required]
public bool Sterilized
{
get => _sterilized;
set
{
_sterilized = value;
OnPropertyChanged();
}
}
/// <summary>
/// Medizinische Informationen
/// </summary>
[MaxLength(5000)]
public string MedicalInfo
{
get => _medicalInfo;
set
{
_medicalInfo = value;
OnPropertyChanged();
}
}
#endregion
#region Sitting
/// <summary>
/// Ist stubenrein?
/// </summary>
[Required]
public bool HouseTrained
{
get => _houseTrained;
set
{
_houseTrained = value;
OnPropertyChanged();
}
}
/// <summary>
/// Fütterungszeiten
/// </summary>
[Required]
public DogFeedingTimes FeedingTimes
{
get => _feedingTimes;
set
{
_feedingTimes = value;
OnPropertyChanged();
}
}
/// <summary>
/// Fütterungszeiten Individuell
/// </summary>
[MaxLength(500)]
public string FeedingIndividual
{
get => _feedingIndividual;
set
{
_feedingIndividual = value;
OnPropertyChanged();
}
}
#endregion
/// <summary>
/// Rating-Statistiken für den Hund
/// </summary>
public RatingStatistics RatingStatistics
{
get => _ratingStatistics;
set
{
_ratingStatistics = value;
OnPropertyChanged();
}
}
#region Erweiterung Blockier- und Sperrinfo
/// <summary>
/// Hundebesitzer ist blockiert
/// </summary>
[NotMapped]
public bool Blocked
{
get => _blocked;
set
{
if (value == _blocked) return;
_blocked = value;
OnPropertyChanged();
OnPropertyChanged(nameof(BlockedOrLocked));
}
}
/// <summary>
/// Hundebesitzer ist gesperrt
/// </summary>
[NotMapped]
public bool Locked
{
get => _locked;
set
{
if (value == _locked) return;
_locked = value;
OnPropertyChanged();
OnPropertyChanged(nameof(BlockedOrLocked));
}
}
/// <summary>
/// Hundebesitzer blockiert oder gesperrt?
/// </summary>
[NotMapped]
public bool BlockedOrLocked => Blocked || Locked;
#endregion
/// <summary>
/// Datum der Erstellung
/// </summary>
public DateTimeOffset Created { get; set; }
public Dog()
{
RatingStatistics = new RatingStatistics();
OnPropertyChanged();
}
}
/// <summary>
/// Min-Info eines Hundes
/// </summary>
public class DogMinInfo : SyncEntityVw
{
/// <summary>
/// Id der Hunderasse
/// </summary>
public string DogRaceId { get; set; }
/// <summary>
/// Name der Hunderasse
/// </summary>
public string DogRaceName { get; set; }
/// <summary>
/// Name des Hundes
/// </summary>
public string Name { get; set; }
/// <summary>
/// Optional - Foto des Hundes
/// </summary>
public string Photo { get; set; }
/// <summary>
/// Geschlecht
/// </summary>
public DogSex Sex { get; set; }
/// <summary>
/// Größe des Hundes
/// </summary>
public DogSize Size { get; set; }
/// <summary>
/// Geburtstag des Hundes
/// </summary>
public DateTimeOffset? BirthDate { get; set; }
/// <summary>
/// Durchschnittliche Bewertung
/// </summary>
public decimal AverageRating { get; set; }
/// <summary>
/// Anzahl Bewertungen
/// </summary>
public int TotalRatings { get; set; }
#region Erweiterung Blockier- und Sperrinfo
/// <summary>
/// Hundebesitzer ist blockiert
/// </summary>
[NotMapped]
public bool Blocked { get; set; }
/// <summary>
/// Hundebesitzer ist gesperrt
/// </summary>
[NotMapped]
public bool Locked { get; set; }
/// <summary>
/// Hundebesitzer blockiert oder gesperrt?
/// </summary>
[NotMapped]
public bool BlockedOrLocked => Blocked || Locked;
#endregion
}
/// <summary>
/// Hilfsklasse für das Speichern von Hunden zu Walks
/// </summary>
public class DogWalkJson
{
/// <summary>
/// Id des Hundes
/// </summary>
[JsonPropertyName("id")]
public string Id { get; set; }
/// <summary>
/// Name des Hundes
/// </summary>
[JsonPropertyName("name")]
public string Name { get; set; }
}
}