104 lines
3.0 KiB
C#
104 lines
3.0 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.Messages
|
|
{
|
|
/// <summary>
|
|
/// Repräsentiert eine Konversation zwischen 2 Benutzern
|
|
/// </summary>
|
|
public class Conversation : SyncEntity
|
|
{
|
|
/// <summary>
|
|
/// Ziel der Konversation - UserId
|
|
/// </summary>
|
|
[Required]
|
|
[MaxLength(128)]
|
|
[JsonPropertyName("recipient")]
|
|
public string Recipient { get; set; }
|
|
|
|
/// <summary>
|
|
/// Typ des Empfängers. DogOwner oder DogWalker
|
|
/// </summary>
|
|
[JsonPropertyName("receipientType")]
|
|
public AppUserType ReceipientType { get; set; }
|
|
|
|
/// <summary>
|
|
/// Name des Addressaten
|
|
/// </summary>
|
|
[MaxLength(300)]
|
|
[JsonPropertyName("recipientName")]
|
|
public string RecipientName { get; set; }
|
|
|
|
/// <summary>
|
|
/// Kürzel des Addressaten
|
|
/// </summary>
|
|
[MaxLength(2)]
|
|
[JsonPropertyName("recipientShort")]
|
|
public string RecipientShort { get; set; }
|
|
|
|
/// <summary>
|
|
/// Foto
|
|
/// </summary>
|
|
[JsonPropertyName("recipientPhoto")]
|
|
public string RecipientPhoto { get; set; }
|
|
|
|
/// <summary>
|
|
/// Id der letzten Nachricht
|
|
/// </summary>
|
|
[MaxLength(128)]
|
|
[JsonPropertyName("lastMessageId")]
|
|
public string LastMessageId { get; set; }
|
|
|
|
/// <summary>
|
|
/// Vorschautext der letzten Nachricht
|
|
/// </summary>
|
|
[JsonPropertyName("lastMessagePreview")]
|
|
public string LastMessagePreview { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gibt an ob ungelesene Nachrichten enthalten sind
|
|
/// </summary>
|
|
[JsonPropertyName("hasUnreadMessages")]
|
|
public bool HasUnreadMessages { get; set; }
|
|
|
|
/// <summary>
|
|
/// Wann wurde die Konversation erstellt
|
|
/// </summary>
|
|
[Required]
|
|
[JsonPropertyName("created")]
|
|
public DateTimeOffset Created { get; set; }
|
|
|
|
/// <summary>
|
|
/// Vorname + Nachname erster Buchstabe + Punkt, oder nur Vorname wenn kein Nachname
|
|
/// </summary>
|
|
[NotMapped]
|
|
[JsonIgnore]
|
|
public string RecipientFullNameShort
|
|
{
|
|
get
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(RecipientName))
|
|
{
|
|
var parts = RecipientName.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;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|