Example #1
0
        //public  void ValidateProperty( Property property)
        //{

        //    var results = _validationRulesService.Validate(property);
        //    if (!results.IsValid)
        //    {
        //        throw new DomainValidationException("create_property_validation", results.Errors);
        //    }
        //}
        public void Validate(RegisterPropertyCommand propertyInfo)
        {
            var results = _validationRulesService.Validate(propertyInfo);
            if (!results.IsValid)
            {
                throw new DomainValidationException("create_property_validation", results.Errors);
            }
        }
Example #2
0
 public Property(RegisterPropertyCommand addPropertyCommand, DateTime?dateCreated = null, Guid?id = null) : base(dateCreated, id)
 {
     _validationService.Validate(addPropertyCommand);
     Name                = addPropertyCommand.Name;
     Code                = addPropertyCommand.Code;
     PhoneNumber         = addPropertyCommand.PhoneNumber;
     Address             = addPropertyCommand.Address;
     Superintendent      = addPropertyCommand.Superintendent;
     Units               = addPropertyCommand.Units;
     NoReplyEmailAddress = addPropertyCommand.NoReplyEmailAddress;
 }
        public async Task <Property> RegisterPropertyAsync(RegisterPropertyCommand propertyInfo)
        {
            await Task.CompletedTask;
            //_authService.Check(() => _authService.IsAuthenticatedSuperintendent());
            var prop = new Property(propertyInfo);
            var p    = _propertyRepository.GetPropertyByCode(prop.Code);

            if (p != null)
            {
                throw new DomainEntityDuplicateException("duplicate_property", "duplicate property name");
            }
            _propertyRepository.AddProperty(prop);
            await _authService.SetUserClaims(GetClaims().Login, UserRolesEnum.Superintendent, prop.Code, null);

            return(prop);
        }
        //public  ValidationResult Validate  ( Property  property)
        //{
        //    var validator = new PropertyValidator();

        //    return validator.Validate(property);

        //}
        public ValidationResult Validate(RegisterPropertyCommand propertyInfo)
        {
            var validator = new RegisterPropertyCommandValidator();

            return(validator.Validate(propertyInfo));
        }