PWA Fundvelo der Caritas.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Validator.cs 3.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. notValid += String.IsNullOrEmpty(report.AbholMail) ? 1 : 0;
  36. if (notValid > 0) {
  37. throw new ArgumentException("ValidationException");
  38. }
  39. }
  40. }
  41. public static void ValidateContact(Report report) {
  42. int notValid = 0;
  43. notValid += String.IsNullOrEmpty(report.Anrede) ? 1 : 0;
  44. notValid += String.IsNullOrEmpty(report.Vorname) ? 1 : 0;
  45. notValid += String.IsNullOrEmpty(report.Nachname) ? 1 : 0;
  46. notValid += String.IsNullOrEmpty(report.Telefon) ? 1 : 0;
  47. if (notValid > 0) {
  48. throw new ArgumentException("ValidationException");
  49. }
  50. }
  51. public static void ValidateAccount(UserData account) {
  52. int notValid = 0;
  53. notValid += String.IsNullOrEmpty(account.Salutation) ? 1 : 0;
  54. notValid += String.IsNullOrEmpty(account.Firstname) ? 1 : 0;
  55. notValid += String.IsNullOrEmpty(account.Lastname) ? 1 : 0;
  56. notValid += String.IsNullOrEmpty(account.Email) ? 1 : 0;
  57. if (notValid > 0) {
  58. throw new ArgumentException("ValidationException");
  59. }
  60. }
  61. }
  62. }