예제 #1
0
 public void Validar()
 {
     AssertionConcern.AssertArgumentNotEmpty(CPF, Erros.EmptyCPF);
     AssertionConcern.AssertArgumentNotEmpty(RG, Erros.EmptyRG);
     AssertionConcern.AssertArgumentNotEmpty(Sexo, Erros.EmptySex);
     AssertionConcern.AssertArgumentNotNull(EstadoCivil, Erros.EmptyMaritalStatus);
 }
예제 #2
0
        public void SetName(string name)
        {
            AssertionConcern.AssertArgumentNotEmpty(name, "Name is required");
            AssertionConcern.AssertArgumentLength(name, MinLength, MaxLength, string.Format("Name needs to be between {0} and {1} characters", MinLength, MaxLength));

            Name = name;
        }
예제 #3
0
 public ICommandResult Post(RegisterCustomerCommand command)
 {
     //fail fast validation
     AssertionConcern.AssertArgumentNotEmpty(command.FirstName, "O Primeiro nome não pode ser nulo.");
     AssertionConcern.AssertArgumentNotEmpty(command.Email, "O email nome não pode ser nulo.");
     return(_handler.Handle(command));
 }
        public async Task <Author> GetByUserId(string userId)
        {
            AssertionConcern.AssertArgumentNotEmpty(userId, Constants.Messages.Exception.InvalidUserId, nameof(userId));

            Author result = null;

            var results = this.connection.Table <User>().Where(e => e.UserId == userId);
            var user    = (await results.ToListAsync()).SingleOrDefault();

            if (user != null)
            {
                // check if null if neuron is inactive or deactivated, if so, should throw exception
                var userNeuron = (await this.neuronGraphQueryClient.GetNeuronById(
                                      this.settingsService.CortexGraphOutBaseUrl + "/",
                                      user.NeuronId.ToString(),
                                      new NeuronQuery()
                {
                    NeuronActiveValues = ActiveValues.All
                }
                                      )
                                  ).Neurons.FirstOrDefault();

                AssertionConcern.AssertStateTrue(userNeuron != null, Constants.Messages.Exception.NeuronNotFound);
                AssertionConcern.AssertStateTrue(userNeuron.Active, Constants.Messages.Exception.NeuronInactive);

                var permits = await(this.connection.Table <RegionPermit>().Where(e => e.UserNeuronId == user.NeuronId)).ToArrayAsync();
                result = new Author(user, permits);
            }

            return(result);
        }
예제 #5
0
        public CalendarEntry(
            Tenant tenant,
            CalendarId calendarId,
            CalendarEntryId calendarEntryId,
            string description,
            string location,
            Owner owner,
            DateRange timeSpan,
            Repetition repetition,
            Alarm alarm,
            IEnumerable <Participant> invitees = null)
        {
            AssertionConcern.AssertArgumentNotNull(tenant, "The tenant must be provided.");
            AssertionConcern.AssertArgumentNotNull(calendarId, "The calendar id must be provided.");
            AssertionConcern.AssertArgumentNotNull(calendarEntryId, "The calendar entry id must be provided.");
            AssertionConcern.AssertArgumentNotEmpty(description, "The description must be provided.");
            AssertionConcern.AssertArgumentNotEmpty(location, "The location must be provided.");
            AssertionConcern.AssertArgumentNotNull(owner, "The owner must be provided.");
            AssertionConcern.AssertArgumentNotNull(timeSpan, "The time span must be provided.");
            AssertionConcern.AssertArgumentNotNull(repetition, "The repetition must be provided.");
            AssertionConcern.AssertArgumentNotNull(alarm, "The alarm must be provided.");

            if (repetition.Repeats == RepeatType.DoesNotRepeat)
            {
                repetition = Repetition.DoesNotRepeat(timeSpan.Ends);
            }

            AssertTimeSpans(repetition, timeSpan);

            Apply(new CalendarEntryScheduled(tenant, calendarId, calendarEntryId, description, location, owner, timeSpan, repetition, alarm, invitees));
        }
예제 #6
0
        public CreateTerminal(Guid id, Guid presynapticNeuronId, Guid postsynapticNeuronId, NeurotransmitterEffect effect, float strength, string externalReferenceUrl, string userId)
        {
            AssertionConcern.AssertArgumentValid(
                g => g != Guid.Empty,
                id,
                Messages.Exception.InvalidId,
                nameof(id)
                );
            AssertionConcern.AssertArgumentValid(
                g => g != Guid.Empty,
                presynapticNeuronId,
                Messages.Exception.InvalidId,
                nameof(presynapticNeuronId)
                );
            AssertionConcern.AssertArgumentValid(
                g => g != Guid.Empty,
                postsynapticNeuronId,
                Messages.Exception.InvalidId,
                nameof(postsynapticNeuronId)
                );
            AssertionConcern.AssertArgumentNotEmpty(
                userId,
                Messages.Exception.InvalidUserId,
                nameof(userId)
                );

            this.Id = id;
            this.PresynapticNeuronId  = presynapticNeuronId;
            this.PostsynapticNeuronId = postsynapticNeuronId;
            this.Effect               = effect;
            this.Strength             = strength;
            this.ExternalReferenceUrl = externalReferenceUrl;
            this.UserId               = userId;
        }
예제 #7
0
 public static bool ValidDescription(this Branch branch)
 {
     return(AssertionConcern.IsValid(
                AssertionConcern.AssertArgumentNotEmpty(branch.Description, "Preencha o ramo."),
                AssertionConcern.AssertArgumentLength(branch.Description, 3, 30, "Ramo deve possuir mais que 3 até 30 caracteres.")
                ));
 }
예제 #8
0
 public static bool ValidName(this Product product)
 {
     return(AssertionConcern.IsValid(
                AssertionConcern.AssertArgumentLength(product.Name, 3, 20, "Produto deve possuir mais que 3 até 20 caracteres."),
                AssertionConcern.AssertArgumentNotEmpty(product.Name, "Informe o produto.")
                ));
 }
예제 #9
0
 public static bool ValidDescription(this Plan plan)
 {
     return(AssertionConcern.IsValid(
                AssertionConcern.AssertArgumentLength(plan.Description, 10, 150, "Descrição do plano deve possuir mais do que 9 até 150 caracteres."),
                AssertionConcern.AssertArgumentNotEmpty(plan.Description, "Informe uma descrição para o plano.")
                ));
 }
예제 #10
0
 public static bool ValidName(this Plan plan)
 {
     return(AssertionConcern.IsValid(
                AssertionConcern.AssertArgumentLength(plan.Name, 3, 80, "Nome do plano deve possuir mais que 2 até 80 caracteres."),
                AssertionConcern.AssertArgumentNotEmpty(plan.Name, "Informe o nome do plano.")
                ));
 }
예제 #11
0
 public void SetPassword(string password, string confirmation)
 {
     AssertionConcern.AssertArgumentNotEmpty(password, "Senha não pode ser vazia");
     AssertionConcern.AssertArgumentEquals(confirmation, password, "Senha e confirmação de senha são diferentes");
     AssertionConcern.AssertArgumentLength(password, 6, 20, "Senha inválida");
     this.Password = password;
 }
 public static bool ValidTitle(this Service service)
 {
     return(AssertionConcern.IsValid(
                AssertionConcern.AssertArgumentLength(service.Title, 3, 30, "Título deve possuir mais que 3 até 30 caracteres."),
                AssertionConcern.AssertArgumentNotEmpty(service.Title, "Informe o título")
                ));
 }
 public static bool ValidDescription(this Service service)
 {
     return(AssertionConcern.IsValid(
                AssertionConcern.AssertArgumentNotEmpty(service.Description, "Informe algo sobre sua empresa."),
                AssertionConcern.AssertArgumentLength(service.Description, 10, 120, "Descrição deve possuir mais que 10 até 120 caracteres.")
                ));
 }
 public static bool ValidPhone(this Service service)
 {
     return(AssertionConcern.IsValid(
                AssertionConcern.AssertArgumentLength(service.Phone, 12, 12, "Telefone incorreto."),
                AssertionConcern.AssertArgumentNotEmpty(service.Phone, "Informe um número de telefone.")
                ));
 }
예제 #15
0
        public void SetName(string name)
        {
            AssertionConcern.AssertArgumentNotEmpty(name, Errors.NameRequired);
            AssertionConcern.AssertArgumentLength(name, NameMaxLength, string.Format(Errors.NameMaxLength, NameMaxLength));

            Name = name;
        }
예제 #16
0
 public static bool ValidDescription(this Product product)
 {
     return(AssertionConcern.IsValid(
                AssertionConcern.AssertArgumentLength(product.Description, 3, 120, "Descrição do produto deve possuir mais que 3 até 120 caracteres."),
                AssertionConcern.AssertArgumentNotEmpty(product.Description, "Informe a descrição do produto.")
                ));
 }
예제 #17
0
        public ChangeNeuronTag(Guid id, string newTag, string userId, int expectedVersion)
        {
            AssertionConcern.AssertArgumentValid(
                g => g != Guid.Empty,
                id,
                Messages.Exception.InvalidId,
                nameof(id)
                );
            AssertionConcern.AssertArgumentNotNull(newTag, nameof(newTag));
            AssertionConcern.AssertArgumentNotEmpty(
                userId,
                Messages.Exception.InvalidUserId,
                nameof(userId)
                );
            AssertionConcern.AssertArgumentValid(
                i => i >= 1,
                expectedVersion,
                Messages.Exception.InvalidExpectedVersion,
                nameof(expectedVersion)
                );

            this.Id              = id;
            this.NewTag          = newTag;
            this.UserId          = userId;
            this.ExpectedVersion = expectedVersion;
        }
예제 #18
0
 public static bool ValidName(this Model model)
 {
     return(AssertionConcern.IsValid(
                AssertionConcern.AssertArgumentLength(model.Nome, 3, 50, "Modelo deve possuir mais que 3 até 50 caracteres."),
                AssertionConcern.AssertArgumentNotEmpty(model.Nome, "Informe o modelo.")
                ));
 }
예제 #19
0
 public void Validar()
 {
     AssertionConcern.AssertArgumentNotEmpty(Nome, Erros.EmptyName);
     AssertionConcern.AssertArgumentNotNull(Papeis, Erros.PaperEmptyPerson);
     AssertionConcern.AssertArgumentNotNull(MeiosComunicacao, Erros.MeansOfCommunicationEmpty);
     AssertionConcern.AssertArgumentNotNull(Enderecos, Erros.EmptyAddress);
 }
예제 #20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="User"/> class
        /// and publishes a <see cref="UserRegistered"/> event.
        /// </summary>
        /// <param name="tenantId">
        /// Initial value of the <see cref="TenantId"/> property.
        /// </param>
        /// <param name="username">
        /// Initial value of the <see cref="Username"/> property.
        /// </param>
        /// <param name="password">
        /// Initial value of the <see cref="Password"/> property.
        /// </param>
        /// <param name="enablement">
        /// Initial value of the <see cref="Enablement"/> property.
        /// </param>
        /// <param name="person">
        /// Initial value of the <see cref="Person"/> property.
        /// </param>
        public User(
            TenantId tenantId,
            string username,
            string password,
            Enablement enablement,
            Person person)
        {
            AssertionConcern.AssertArgumentNotNull(tenantId, "The tenantId is required.");
            AssertionConcern.AssertArgumentNotNull(person, "The person is required.");
            AssertionConcern.AssertArgumentNotEmpty(username, "The username is required.");
            AssertionConcern.AssertArgumentLength(username, 3, 250, "The username must be 3 to 250 characters.");

            // Defer validation to the property setters.
            this.Enablement = enablement;
            this.Person     = person;
            this.TenantId   = tenantId;
            this.Username   = username;

            this.ProtectPassword(string.Empty, password);

            person.User = this;

            DomainEventPublisher
            .Instance
            .Publish(new UserRegistered(
                         tenantId,
                         username,
                         person.Name,
                         person.ContactInformation.EmailAddress));
        }
예제 #21
0
 public static bool ValidFirstName(this CustomerName customerName)
 {
     return(AssertionConcern.IsValid(
                AssertionConcern.AssertArgumentLength(customerName.FirstName, 3, 40, "Primeiro nome deve possuir mais que 2 até 40 caracteres."),
                AssertionConcern.AssertArgumentNotEmpty(customerName.FirstName, "Informe seu primeiro nome.")
                ));
 }
 public static bool ValidPassword(this Customer customer)
 {
     return(AssertionConcern.IsValid(
                AssertionConcern.AssertArgumentLength(customer.Password, 8, 16, "Senha deve possuir mais que 7 até 16 caracteres."),
                AssertionConcern.AssertArgumentNotEmpty(customer.Password, "Informe a senha.")
                ));
 }
 public static bool ValidCompanyName(this Customer customer)
 {
     return(AssertionConcern.IsValid(
                AssertionConcern.AssertArgumentLength(customer.CompanyName, 3, 80, "Nome da empresa deve possuir mais que 2 até 80 caracteres."),
                AssertionConcern.AssertArgumentNotEmpty(customer.CompanyName, "Informe o nome da empresa.")
                ));
 }
 public static bool ValidNumber(this Address address)
 {
     return(AssertionConcern.IsValid(
                AssertionConcern.AssertArgumentNotEmpty(address.Number.ToString(), "Informe o número"),
                AssertionConcern.AssertArgumentRange(address.Number, 1, 99999, "Número inválido.")
                ));
 }
예제 #25
0
        public void SetDdd(string ddd)
        {
            AssertionConcern.AssertArgumentNotEmpty(ddd, Errors.DddNumberRequired);
            AssertionConcern.AssertArgumentLength(ddd, DddMaxLength, string.Format(Errors.DddMaxLength, DddMaxLength));

            Ddd = ddd;
        }
예제 #26
0
        public void SetNumber(string number)
        {
            AssertionConcern.AssertArgumentNotEmpty(number, Errors.PhoneNumberRequired);
            AssertionConcern.AssertArgumentLength(number, NumberMaxLength, string.Format(Errors.NumberMaxLength, NumberMaxLength));

            Number = number;
        }
 public static bool ValidEmail(this Customer customer)
 {
     return(AssertionConcern.IsValid(
                AssertionConcern.AssertArgumentLength(customer.Email, 5, 60, "Email deve possuir mais que 4 até 60 caracteres."),
                AssertionConcern.AssertArgumentNotEmpty(customer.Email, "Informe o email."),
                AssertionConcern.AssertArgumentMatches(@"^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$", customer.Email, "Email inválido.")
                ));
 }
 public void validacoes()
 {
     AssertionConcern.AssertArgumentFalse(this.DataLancamento.Date == new DateTime(0001, 01, 01).Date, "Data de lançamento é obrigatório!");
     AssertionConcern.AssertArgumentNotEmpty(this.Historico, "Histórico é obrigatório!");
     AssertionConcern.AssertArgumentLength(this.Historico, 5, 60, "Histórico deve conter no mínimo 5 caracteres");
     AssertionConcern.AssertArgumentFalse(this.Valor <= 0, "Valor Deve ser maior que 0!");
     //AssertionConcern.AssertArgumentFalse(this.DataLancamento.Date == viagem.DataChegada.Date, "A data de lançamento deve ser a mesma da chegada");
 }
예제 #29
0
파일: User.cs 프로젝트: andersonaap/collhub
 public override bool IsValid()
 {
     return(this.EmailAddress.IsValid() && AssertionConcern.IsValid
            (
                AssertionConcern.AssertArgumentNotEmpty(this.Username, "user name is required"),
                AssertionConcern.AssertArgumentNotEmpty(this.Password, "password is required")
            ));
 }
예제 #30
0
 public void Validate()
 {
     AssertionConcern.AssertArgumentNotEmpty(Name, "O campo Nome do produto não pode estar vazio");
     AssertionConcern.AssertArgumentNotEmpty(Description, "O campo Descricao do produto não pode estar vazio");
     AssertionConcern.AssertArgumentEquals(CategoryId, Guid.Empty, "O campo CategoriaId do produto não pode estar vazio");
     AssertionConcern.AssertArgumentLowerThan(Value, 1, "O campo Valor do produto não pode se menor igual a 0");
     AssertionConcern.AssertArgumentNotEmpty(Image, "O campo Imagem do produto não pode estar vazio");
 }