PWA Fundvelo der Caritas.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. if (notValid > 0) {
  47. throw new ArgumentException("ValidationException");
  48. }
  49. }
  50. public static void ValidateAccount(UserData account) {
  51. int notValid = 0;
  52. notValid += String.IsNullOrEmpty(account.Salutation) ? 1 : 0;
  53. notValid += String.IsNullOrEmpty(account.Firstname) ? 1 : 0;
  54. notValid += String.IsNullOrEmpty(account.Lastname) ? 1 : 0;
  55. notValid += String.IsNullOrEmpty(account.Email) ? 1 : 0;
  56. if (notValid > 0) {
  57. throw new ArgumentException("ValidationException");
  58. }
  59. }
  60. }
  61. }