| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- 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;
- 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;
- notValid += String.IsNullOrEmpty(report.Telefon) ? 1 : 0;
- if (notValid > 0) {
- throw new ArgumentException("ValidationException");
- }
- }
- }
- }
|