コード例 #1
0
        public ServiceTypeServiceInterceptor(ServiceTypeValidator serviceTypeValidator)
        {
            _serviceTypeValidator = serviceTypeValidator;

            BuildUp(new Dictionary <string, Action <IInvocation> >
            {
                {
                    nameof(GetServiceAllTypesAsync),
                    x => GetServiceAllTypesAsync()
                },
                {
                    nameof(GetSingleServiceTypeAsync),
                    x => GetSingleServiceTypeAsync((int)x.Arguments[0])
                },
                {
                    nameof(CreateServiceTypeAsync),
                    x => CreateServiceTypeAsync((ServiceType)x.Arguments[0])
                },
                {
                    nameof(UpdateServiceTypeAsync),
                    x => UpdateServiceTypeAsync((ServiceType)x.Arguments[0])
                },
                {
                    nameof(DeleteServiceTypeAsync),
                    x => DeleteServiceTypeAsync((int)x.Arguments[0])
                }
            });
        }
コード例 #2
0
        public Task <ServiceType> CreateServiceTypeAsync(ServiceType type)
        {
            ServiceTypeValidator.ValidateNameNotEmpty(type);
            ServiceTypeValidator.ValidateNameNotTooLong(type);
            _serviceTypeValidator.ValidateNameDoesntExist(type);

            _serviceTypeValidator.CanCreateServiceType();
            return(null);
        }