EmployeeValidator.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using FluentValidation;
  2. using GreenTree.Strohrmann.ERP.Domain.Model;
  3. using GreenTree.Strohrmann.ERP.Web.Models.Business;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Threading.Tasks;
  8. namespace GreenTree.Strohrmann.ERP.Web.Validators
  9. {
  10. public class EmployeeValidator : AbstractValidator<EmployeeModel>
  11. {
  12. #region DI fields
  13. // The global DbContext
  14. private readonly ERPDbContext _eRPDbContext;
  15. #endregion
  16. #region Ctor
  17. /// <summary>
  18. /// Initializes a new instance of the EmployeeValidator class
  19. /// </summary>
  20. /// <param name="eRPDbContext">Global DbContext.</param>
  21. public EmployeeValidator(
  22. ERPDbContext eRPDbContext)
  23. {
  24. _eRPDbContext = eRPDbContext;
  25. RuleFor(m => m.Firstname)
  26. .NotEmpty();
  27. RuleFor(m => m.Lastname)
  28. .NotEmpty();
  29. RuleFor(m => m.MailAddress)
  30. .EmailAddress()
  31. .WithMessage("Es muss eine gültige E-Mail Adresse eingegeben werden.");
  32. RuleFor(m => m.EmployeeDegree)
  33. .NotEmpty();
  34. }
  35. #endregion
  36. }
  37. }