PWA Fundvelo der Caritas.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

Validator.cs 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using cwebplusApp.Shared.Models;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Threading.Tasks;
  6. namespace cwebplusApp.Shared.Services {
  7. public class Validator {
  8. public static void ValidateFoundReportKeyData(FoundReport report) {
  9. int notValid = 0;
  10. notValid += String.IsNullOrEmpty(report.GeographicInfo.Address) ? 1 : 0;
  11. notValid += String.IsNullOrEmpty(report.GeographicInfo.Town) ? 1 : 0;
  12. notValid += String.IsNullOrEmpty(report.GeographicInfo.Postcode) ? 1 : 0;
  13. notValid += (report.FarbeId == null) ? 1 : 0;
  14. notValid += (report.MarkeId == null && String.IsNullOrEmpty(report.NeueMarke)) ? 1 : 0;
  15. notValid += (report.TypId == null) ? 1 : 0;
  16. if (notValid > 0) {
  17. throw new ArgumentException("ValidationException");
  18. }
  19. }
  20. public static void ValidateAlternatePickContact(FoundReport report) {
  21. if (!report.AbholadresseIstKontakt) {
  22. int notValid = 0;
  23. notValid += String.IsNullOrEmpty(report.AbholAnrede) ? 1 : 0;
  24. notValid += String.IsNullOrEmpty(report.AbholVorname) ? 1 : 0;
  25. notValid += String.IsNullOrEmpty(report.AbholNachname) ? 1 : 0;
  26. notValid += String.IsNullOrEmpty(report.AbholStrasse) ? 1 : 0;
  27. notValid += String.IsNullOrEmpty(report.AbholPLZ) ? 1 : 0;
  28. notValid += String.IsNullOrEmpty(report.AbholOrt) ? 1 : 0;
  29. if (notValid > 0) {
  30. throw new ArgumentException("ValidationException");
  31. }
  32. }
  33. }
  34. public static void ValidateContact(Report report) {
  35. int notValid = 0;
  36. notValid += String.IsNullOrEmpty(report.Anrede) ? 1 : 0;
  37. notValid += String.IsNullOrEmpty(report.Vorname) ? 1 : 0;
  38. notValid += String.IsNullOrEmpty(report.Nachname) ? 1 : 0;
  39. notValid += String.IsNullOrEmpty(report.Telefon) ? 1 : 0;
  40. if (notValid > 0) {
  41. throw new ArgumentException("ValidationException");
  42. }
  43. }
  44. }
  45. }