PWA Fundvelo der Caritas.
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

Validator.cs 2.5KB

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