Beispiel #1
0
        public static async Task SeedAsync(IUnitCodeRepositoryAsync unitCodeRepository)
        {
            // Seed Default UnitCode
            var defaultUnicode = new UnitCode
            {
                Id          = (int)UnitCodes.ROOT_UNITCODE,
                Name        = "Quản trị phần mềm",
                PhoneNumber = "033.248.7344",
                Address     = "Thanh Trì - Hà Nội",
                Describe    = "Quản trị phần mềm"
            };

            var unitCode = await unitCodeRepository.GetUnitCodeByIdAsync(defaultUnicode.Id);

            if (unitCode == null)
            {
                await unitCodeRepository.AddAsync(defaultUnicode);
            }
        }
Beispiel #2
0
        public CreateUnitCodeCommandValidator(IUnitCodeRepositoryAsync unitCodeRepository)
        {
            this.unitCodeRepository = unitCodeRepository;

            //RuleFor(m => m.Id)
            //    .NotEmpty().WithMessage("{PropertyName} is required.")
            //    .NotNull()
            //    .MaximumLength(3).WithMessage("{PropertyName} must not exceed 3 characters.")
            //    .Matches(@"^\d+$").WithMessage("{PropertyName} does not allow special character.");

            RuleFor(m => m.Name)
            .NotEmpty().WithMessage("{PropertyName} is required.")
            .NotNull()
            .MaximumLength(150).WithMessage("{PropertyName} must not exceed 150 characters.");

            RuleFor(m => m.PhoneNumber)
            .MaximumLength(15).WithMessage("{PropertyName} must not exceed 15 characters.");

            RuleFor(m => m.Address)
            .MaximumLength(100).WithMessage("{PropertyName} must not exceed 100 characters.");

            RuleFor(m => m.Describe)
            .MaximumLength(150).WithMessage("{PropertyName} must not exceed 150 characters.");
        }
Beispiel #3
0
 public DeleteUnitCodeByIdCommandHandler(IUnitCodeRepositoryAsync unitCodeRepository)
 {
     _unitCodeRepository = unitCodeRepository;
 }
 public CreateUnitCodeCommandHandler(IUnitCodeRepositoryAsync unitCodeRepository, IMapper mapper)
 {
     _unitCodeRepository = unitCodeRepository;
     _mapper             = mapper;
 }
 public UpdateUnitCodeCommandHandler(IUnitCodeRepositoryAsync unitCodeRepository)
 {
     _unitCodeRepository = unitCodeRepository;
 }