using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using gehGassiApp.Domain.Base;
namespace gehGassiApp.Domain.Common
{
///
/// Repräsentiert eine Bewertung
///
public class Rating : SyncEntity
{
///
/// Wer hat das Rating erstellt?
///
[Required]
[MaxLength(128)]
public string FromId { get; set; }
///
/// Typ der Quelle des Ratings
///
[Required]
public AppUserType FromType { get; set; }
///
/// Ziel Id des Ratings
///
[Required]
[MaxLength(128)]
public string TargetId { get; set; }
///
/// Ziel-Typ
///
[Required]
public RatingTarget TargetType { get; set; }
///
/// Vergebene Bewertung
///
[Required]
public decimal Points { get; set; }
///
/// Anmerkungen zum Rating
///
[MaxLength(500)]
public string Info { get; set; }
///
/// Wann erstellt?
///
[Required]
public DateTimeOffset Created { get; set; }
}
///
/// Repräsentiert ein Rating
///
public class RatingStatistics
{
///
/// Anzahl der Bewertungen
///
[Required]
public int TotalRatings { get; set; }
///
/// Anzahl der Punkte die vergeben wurden
///
[Required]
public decimal TotalPoints { get; set; }
///
/// Durchschnittliche Bewertung
///
[Required]
public decimal AverageRating { get; set; }
}
///
/// Repräsentiert ein Rating das von jemanden für jemanden oder etwas vergeben wurde mit Namen augelöst
///
public class RatingWithNames : SyncEntityVw
{
///
/// Wer hat das Rating erstellt?
///
public string FromId { get; set; }
///
/// Name des Rating Erstellers
///
public string FromName { get; set; }
///
/// Photo des Ratings Erstellers
///
public string FromPhoto { get; set; }
///
/// Typ der Quelle des Ratings
///
public AppUserType FromType { get; set; }
///
/// Ziel Id des Ratings
///
public string TargetId { get; set; }
///
/// Name des Rating Ziels
///
public string TargetName { get; set; }
///
/// Photo des Ratings Ziels
///
public string TargetPhoto { get; set; }
///
/// Ziel-Typ
///
public RatingTarget TargetType { get; set; }
///
/// Vergebene Bewertung
///
public decimal Points { get; set; }
///
/// Anmerkungen zum Rating
///
public string Info { get; set; }
///
/// Wann erstellt?
///
public DateTimeOffset Created { get; set; }
///
/// Von Vorname
///
public string FromFirstName
{
get
{
if (!string.IsNullOrWhiteSpace(FromName))
{
var parts = FromName.Split(" ");
return parts[0];
}
return string.Empty;
}
}
///
/// Vorname + Nachname erster Buchstabe + Punkt, oder nur Vorname wenn kein Nachname
///
public string FromFullNameShort
{
get
{
if (!string.IsNullOrWhiteSpace(FromName))
{
var parts = FromName.Split(" ");
var firstName = parts[0];
var lastName = string.Empty;
if (parts.Length > 1)
lastName = parts[1];
return string.IsNullOrWhiteSpace(lastName) ? firstName : $"{firstName} {lastName[..1]}.";
}
return string.Empty;
}
}
///
/// Ziel Vorname
///
public string TargetFirstName
{
get
{
if (!string.IsNullOrWhiteSpace(TargetName))
{
var parts = TargetName.Split(" ");
return parts[0];
}
return string.Empty;
}
}
///
/// Vorname + Nachname erster Buchstabe + Punkt, oder nur Vorname wenn kein Nachname
///
public string TargetFullNameShort
{
get
{
if (!string.IsNullOrWhiteSpace(TargetName))
{
var parts = TargetName.Split(" ");
var firstName = parts[0];
var lastName = string.Empty;
if (parts.Length > 1)
lastName = parts[1];
return string.IsNullOrWhiteSpace(lastName) ? firstName : $"{firstName} {lastName[..1]}.";
}
return string.Empty;
}
}
#region Erweiterung Blockier- und Sperrinfo
///
/// blockiert
///
[NotMapped]
public bool FromBlocked { get; set; }
///
/// gesperrt
///
[NotMapped]
public bool FromLocked { get; set; }
///
/// blockiert oder gesperrt?
///
[NotMapped]
public bool FromBlockedOrLocked => FromBlocked || FromLocked;
#endregion
}
}