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