| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- using FluentValidation;
- using GreenTree.Strohrmann.ERP.Domain.Model;
- using GreenTree.Strohrmann.ERP.Web.Models.Business;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- namespace GreenTree.Strohrmann.ERP.Web.Validators
- {
- public class CraftValidator : AbstractValidator<CraftModel>
- {
- #region DI fields
- // The global DbContext
- private readonly ERPDbContext _eRPDbContext;
- #endregion
- #region Ctor
- /// <summary>
- /// Initializes a new instance of the EmployeeValidator class
- /// </summary>
- /// <param name="eRPDbContext">Global DbContext.</param>
- public CraftValidator(
- ERPDbContext eRPDbContext)
- {
- _eRPDbContext = eRPDbContext;
- RuleFor(m => m.Name)
- .NotEmpty();
- RuleFor(m => m.CustomerId)
- .NotEmpty();
- RuleFor(m => m.CreationDate)
- .NotEmpty();
- RuleForEach(m => m.CraftEmployees)
- .SetValidator(new CraftEmployeeValidator(_eRPDbContext));
- RuleForEach(m => m.CraftMaterials)
- .SetValidator(new CraftMaterialValidator(_eRPDbContext));
- //RuleForEach(m => m.CraftEmployees)
- // .ChildRules(subModel =>
- // {
- // subModel
- // .RuleFor(x => x.Value.EmployeeId)
- // .GreaterThan(0);
- // subModel
- // .RuleFor(x => x.Value.Amount)
- // .GreaterThan(0);
- // subModel
- // .RuleFor(x => x.Value.Value)
- // .GreaterThan(0);
- // });
- }
- #endregion
- }
- }
|