using cwebplusApp.Shared.Models; using System; namespace cwebplusApp.Shared.Services { public class Validator { public static void ValidateFoundReportKeyData(FoundReport report) { int notValid = 0; notValid += String.IsNullOrEmpty(report.GeographicInfo.Address) ? 1 : 0; notValid += String.IsNullOrEmpty(report.GeographicInfo.Town) ? 1 : 0; notValid += String.IsNullOrEmpty(report.GeographicInfo.Postcode) ? 1 : 0; notValid += (report.FarbeId == null) ? 1 : 0; notValid += (report.MarkeId == null && String.IsNullOrEmpty(report.NeueMarke)) ? 1 : 0; notValid += (report.TypId == null) ? 1 : 0; if (notValid > 0) { throw new ArgumentException("ValidationException"); } } public static void ValidateMissingReportKeyData(MissingReport report) { int notValid = 0; notValid += (report.FarbeId == null) ? 1 : 0; notValid += (report.MarkeId == null && String.IsNullOrEmpty(report.NeueMarke)) ? 1 : 0; notValid += (report.TypId == null) ? 1 : 0; if (notValid > 0) { throw new ArgumentException("ValidationException"); } } public static void ValidateAlternatePickContact(FoundReport report) { if (!report.AbholadresseIstKontakt) { int notValid = 0; notValid += String.IsNullOrEmpty(report.AbholAnrede) ? 1 : 0; notValid += String.IsNullOrEmpty(report.AbholVorname) ? 1 : 0; notValid += String.IsNullOrEmpty(report.AbholNachname) ? 1 : 0; notValid += String.IsNullOrEmpty(report.AbholStrasse) ? 1 : 0; notValid += String.IsNullOrEmpty(report.AbholPLZ) ? 1 : 0; notValid += String.IsNullOrEmpty(report.AbholOrt) ? 1 : 0; notValid += String.IsNullOrEmpty(report.AbholMail) ? 1 : 0; if (notValid > 0) { throw new ArgumentException("ValidationException"); } } } public static void ValidateContact(Report report) { int notValid = 0; notValid += String.IsNullOrEmpty(report.Anrede) ? 1 : 0; notValid += String.IsNullOrEmpty(report.Vorname) ? 1 : 0; notValid += String.IsNullOrEmpty(report.Nachname) ? 1 : 0; if (notValid > 0) { throw new ArgumentException("ValidationException"); } } public static void ValidateAccount(UserData account) { int notValid = 0; notValid += String.IsNullOrEmpty(account.Salutation) ? 1 : 0; notValid += String.IsNullOrEmpty(account.Firstname) ? 1 : 0; notValid += String.IsNullOrEmpty(account.Lastname) ? 1 : 0; notValid += String.IsNullOrEmpty(account.Email) ? 1 : 0; if (notValid > 0) { throw new ArgumentException("ValidationException"); } } } }