154 lines
4.0 KiB
C#

using System;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace gehGassi.Web.Models
{
/// <summary>
/// Viewmodel für die Antwort von Form-Posts
/// </summary>
public class ResponseVm
{
/// <summary>
/// Erfolgreich?
/// </summary>
[JsonProperty(PropertyName = "success")]
public bool Success { get; set; }
/// <summary>
/// Html wenn nicht erfolgreich...
/// </summary>
[JsonProperty(PropertyName = "html")]
public string Html { get; set; }
/// <summary>
/// Optionale Daten
/// </summary>
[JsonProperty(PropertyName = "data")]
public string Data { get; set; }
/// <summary>
/// Fehlermeldung
/// </summary>
[JsonProperty(PropertyName = "errorMessage")]
public string ErrorMessage { get; set; }
/// <summary>
/// Erstellt eine Instanz
/// </summary>
public ResponseVm()
{
Success = false;
Html = string.Empty;
Data = string.Empty;
}
}
/// <summary>
/// Ergebnis einer Batch-Reponse Operation
/// </summary>
public class BatchResponseVm
{
private readonly string _errorHeader;
/// <summary>
/// Erfolgreich?
/// </summary>
[JsonProperty(PropertyName = "success")]
public bool Success { get; set; }
/// <summary>
/// Fehlermeldung
/// </summary>
[JsonProperty(PropertyName = "errorMessage")]
public string ErrorMessage
{
get
{
var text = _errorHeader;
foreach (var deleteResponseVm in BatchResponseList)
{
text += Environment.NewLine + deleteResponseVm.ErrorMessage;
}
return text;
}
}
/// <summary>
/// Liste der einzelnen Operationen
/// </summary>
[JsonProperty(PropertyName = "batchResponseList")]
public List<BatchResponseItemVm> BatchResponseList { get; set; }
/// <summary>
/// Erstellt eine Instanz
/// </summary>
public BatchResponseVm(string errorHeader)
{
_errorHeader = errorHeader;
BatchResponseList = new List<BatchResponseItemVm>();
}
}
/// <summary>
/// Ergebnis einer einzelnen Batch-Operation
/// </summary>
public class BatchResponseItemVm
{
/// <summary>
/// Id des Datensatzes
/// </summary>
[JsonProperty(PropertyName = "id")]
public string Id { get; set; }
/// <summary>
/// Name des Datensatzes
/// </summary>
[JsonProperty(PropertyName = "name")]
public string Name { get; set; }
/// <summary>
/// Operation erfolgreich
/// </summary>
[JsonProperty(PropertyName = "success")]
public bool Success { get; set; }
/// <summary>
/// Konnte nicht gefunden werden
/// </summary>
[JsonProperty(PropertyName = "notFound")]
public bool NotFound { get; set; }
/// <summary>
/// Fehlermeldung
/// </summary>
[JsonProperty(PropertyName = "errorMessage")]
public string ErrorMessage { get; set; }
/// <summary>
/// Optional: Daten die zurückgegeben werden sollen
/// </summary>
[JsonProperty(PropertyName = "data")]
public string Data { get; set; }
}
/// <summary>
/// Viewmodel für die Antwort von Form-Posts für AppUserReport-Module
/// </summary>
public class AppUserReportResponseVm : ResponseVm
{
/// <summary>
/// Modul das geladen / Entladen werden soll
/// </summary>
public string Module { get; set; }
/// <summary>
/// Erstellt eine Instanz
/// </summary>
public AppUserReportResponseVm()
{
Module = string.Empty;
}
}
}