| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- using cwebplusApp.Shared.Models;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
-
- 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 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");
- }
- }
- }
- }
|