public ActionValidationResult(Guid userNeuronId, IEnumerable <ErrorInfo> errors, IEnumerable <NeuronValidationResult> neuronValidationResults) { AssertionConcern.AssertArgumentNotNull(errors, nameof(errors)); AssertionConcern.AssertArgumentNotNull(neuronValidationResults, nameof(neuronValidationResults)); this.UserNeuronId = userNeuronId; this.Errors = errors; this.NeuronValidationResults = neuronValidationResults; }
public void SetPassword(string password, string confirmPassword) { AssertionConcern.AssertArgumentNotNull(password, Errors.InvalidPassword); AssertionConcern.AssertArgumentNotNull(confirmPassword, Errors.InvalidPasswordConfirmation); AssertionConcern.AssertArgumentEquals(password, confirmPassword, Errors.PasswordDoNotMatch); AssertionConcern.AssertArgumentLength(password, 6, 20, Errors.InvalidPasswordNumberChraracters); this.Password = PasswordAssertionConcern.Encrypt(password); }
/// <summary> /// Validar o Contato /// </summary> public void Validate() { AssertionConcern.AssertArgumentLength(this.Name, 3, 60, "Errors.InvalidContactName"); AssertionConcern.AssertArgumentNotNull(this.Name, ""); AssertionConcern.AssertArgumentLength(this.Telefone, 8, 12, "Errors.InvalidContactTelefone"); AssertionConcern.AssertArgumentNotNull(this.Telefone, ""); EmailAssertionConcern.AssertIsValid(this.Email); PasswordAssertionConcern.AssertIsValid(this.Password); }
public override bool IsValid() { return(AssertionConcern.IsValid ( AssertionConcern.AssertArgumentNotNull(_tenantId, "TenentId is required."), AssertionConcern.AssertArgumentNotEmpty(this.Name, "The tenant name is required."), AssertionConcern.AssertArgumentLength(this.Name, 1, 100, "The name must be 100 characters or less.") )); }
public VehicleType(string description, byte capacity) { AssertionConcern.AssertArgumentNotNull(description, "Descrição do tipo do veículo não pode ser nula."); AssertionConcern.AssertArgumentLength(description, 2, 50, "Descrição do tipo do veículo deve ter entre 2 e 50 caracteres."); AssertionConcern.AssertArgumentGreaterThanZero(capacity, "Capacidade do tipo do veículo deve ser maior que zero."); this.Description = description; this.Capacity = capacity; }
public void ChangeAggregate(string newAggregate) { AssertionConcern.AssertArgumentNotNull(newAggregate, nameof(newAggregate)); if (newAggregate != this.Aggregate) { base.ApplyChange(new AggregateChanged(this.Id, newAggregate)); } }
//public string[] Roles { get; set; } public void ValidaSenha(string senha, string senhaConfirm) { AssertionConcern.AssertArgumentNotNull(senha, "Senha invalida!"); AssertionConcern.AssertArgumentNotNull(senhaConfirm, "Confirmação de Senha invalida!"); AssertionConcern.AssertArgumentEquals(senha, senhaConfirm, "As senhas não conferem!"); AssertionConcern.AssertArgumentLength(senha, 2, 20, "As senhas devem ter no minimo 2 e no maxiomo 20 caracteres!"); this.Senha = senha; }
public void SetPassword(string password, string confirmPassword) { AssertionConcern.AssertArgumentNotNull(password, Errors.InvalidUserPassword); AssertionConcern.AssertArgumentNotNull(confirmPassword, Errors.InvalidPasswordConfirmation); AssertionConcern.AssertArgumentEquals(password, confirmPassword, Errors.PasswordsDoesNotMatch); AssertionConcern.AssertArgumentLength(password, 6, 20, Errors.InvalidUserPassword); Password = password; }
public TeamMemberId(Tenants.TenantId tenantId, string id) { AssertionConcern.AssertArgumentNotNull(tenantId, "The tenantId must be provided."); AssertionConcern.AssertArgumentNotEmpty(id, "The id must be provided."); AssertionConcern.AssertArgumentLength(id, 36, "The id must be 36 characters or less."); this.TenantId = tenantId; this.Id = id; }
public void setSenha(String senha, String confirmaSenha) { AssertionConcern.AssertArgumentNotNull(senha, Errors.senhaInvalida); AssertionConcern.AssertArgumentNotNull(confirmaSenha, Errors.confimacaoSenhaInvalida); AssertionConcern.AssertArgumentEquals(senha, confirmaSenha, Errors.senhaInvalida); AssertionConcern.AssertArgumentLength(senha, 6, 20, Errors.senhaInvalida); this.Senha = SenhaAssertionConcern.Encrypt(senha); }
public void SetarSenha(string senha, string confirmarSenha) { AssertionConcern.AssertArgumentNotNull(senha, "Senha Inválida"); AssertionConcern.AssertArgumentNotNull(confirmarSenha, "Senha de confirmação inválida"); AssertionConcern.AssertArgumentEquals(senha, confirmarSenha, "Senhas não coincidem"); AssertionConcern.AssertArgumentLength(senha, 3, 12, "Senha inválida"); this.Senha = PasswordAssertionConcern.Encrypt(senha); }
public Author(User user, IEnumerable <RegionPermit> permits) { // TODO: Add TDD test AssertionConcern.AssertArgumentNotNull(user, nameof(user)); AssertionConcern.AssertArgumentNotNull(permits, nameof(permits)); this.User = user; this.Permits = permits; }
public static bool CreatePhoneScopeIsValid(this Phone phone) { return(AssertionConcern.IsSatisfiedBy( AssertionConcern.AssertArgumentNotNull(phone.DDD, Errors.InvalidDDD), AssertionConcern.AssertArgumentLength(phone.DDD, 2, 2, Errors.InvalidDDD), AssertionConcern.AssertArgumentNotNull(phone.Number, Errors.InvalidPhone), AssertionConcern.AssertArgumentLength(phone.Number, 8, 8, Errors.InvalidPhone) )); }
public Calendar(Tenant tenant, CalendarId calendarId, string name, string description, Owner owner, IEnumerable <CalendarSharer> sharedWith = null) { AssertionConcern.AssertArgumentNotNull(tenant, "The tenant must be provided."); AssertionConcern.AssertArgumentNotNull(calendarId, "The calendar id must be provided."); AssertionConcern.AssertArgumentNotEmpty(name, "The name must be provided."); AssertionConcern.AssertArgumentNotEmpty(description, "The description must be provided."); AssertionConcern.AssertArgumentNotNull(owner, "The owner must be provided."); Apply(new CalendarCreated(tenant, calendarId, name, description, owner, sharedWith)); }
public void Uninvite(Participant participant) { AssertionConcern.AssertArgumentNotNull(participant, "The participant must be provided."); if (this.invitees.Contains(participant)) { Apply(new CalendarEntryParticipantUninvited(this.tenant, this.calendarId, this.calendarEntryId, participant)); } }
public void ChangeTag(string newTag) { AssertionConcern.AssertArgumentNotNull(newTag, nameof(newTag)); if (newTag != this.Tag) { base.ApplyChange(new TagChanged(this.Id, newTag)); } }
public User Authenticate(string email, string password) { User user = GetByEmail(email); AssertionConcern.AssertArgumentNotNull(user, ErrorMessages.UserNotFound); PasswordAssertionConcern.AssertIsValid(password); PasswordAssertionConcern.AssertPasswordIsSame(user.Password, password); return(user); }
private static int CalculatePasswordStrength(string plainTextPassword) { AssertionConcern.AssertArgumentNotNull(plainTextPassword, "Password strength cannot be tested on null."); int strength = 0; int length = plainTextPassword.Length; if (length > 7) { strength += 10; // bonus: one point each additional strength += (length - 7); } int digitCount = 0; int letterCount = 0; int lowerCount = 0; int upperCount = 0; int symbolCount = 0; for (int idx = 0; idx < length; ++idx) { char ch = plainTextPassword[idx]; if (char.IsLetter(ch)) { ++letterCount; if (char.IsUpper(ch)) { ++upperCount; } else { ++lowerCount; } } else if (char.IsDigit(ch)) { ++digitCount; } else { ++symbolCount; } } strength += (upperCount + lowerCount + symbolCount); // bonus: letters and digits if ((letterCount >= 2) && (digitCount >= 2)) { strength += (letterCount + digitCount); } return(strength); }
public static bool CreateQuestionScopeIsValid(this Question question) { return(AssertionConcern.IsSatisfiedBy( AssertionConcern.AssertArgumentNotNull(question.TypeReply, Errors.TypeIsRequired), AssertionConcern.AssertArgumentNotNull(question.TypeQuestion, Errors.TypeIsRequired), AssertionConcern.AssertArgumentNotNull(question.Enunciation, Errors.EnuciationIsRequired), AssertionConcern.AssertArgumentLength(question.Enunciation, 2, 256, Errors.InvalidEnunciation) )); }
public void SetPassword(string password, string confirmPassword) { AssertionConcern.AssertArgumentNotNull(password, Errors.InvalidUserPassword); AssertionConcern.AssertArgumentNotNull(confirmPassword, Errors.InvalidUserPassword); AssertionConcern.AssertArgumentLength(password, 6, 20, Errors.InvalidUserPassword); AssertionConcern.AssertArgumentEquals(password, confirmPassword, Errors.PasswordDoesNotMatch); this.Password = PasswordAssertionConcern.Encrypt(password); }
public void validacoes() { AssertionConcern.AssertArgumentNotNull(this.AnoFabricacao, "Ano de fasbricação não pode ser nulo"); AssertionConcern.AssertArgumentNotEmpty(this.Fabricante, "Nome do fabricante deve conter no mínimo 3 caracteres"); AssertionConcern.AssertArgumentNotEmpty(this.Modelo, "Modelo não pode ser nullo"); AssertionConcern.AssertArgumentNotNull(this.AnoModelo, "Ano de modelo obrigatório"); AssertionConcern.AssertArgumentTrue(this.AnoFabricacao >= 2000, "O veiculo deve ter sido fabricado a partir de 2000"); AssertionConcern.AssertArgumentTrue(this.AnoModelo >= this.AnoFabricacao, "O ano de fabricação não pode ser maior que o de modelo"); }
public Notification(long notificationId, IDomainEvent domainEvent) { AssertionConcern.AssertArgumentNotNull(domainEvent, "The event is required."); this._notificationId = notificationId; this._domainEvent = domainEvent; _occurredOn = domainEvent.OccurredOn; _version = domainEvent.EventVersion; _typeName = domainEvent.GetType().FullName; }
public EstimationLogEntry(Tenants.TenantId tenantId, TaskId taskId, DateTime date, int hoursRemaining) { AssertionConcern.AssertArgumentNotNull(tenantId, "The tenant id must be provided."); AssertionConcern.AssertArgumentNotNull(taskId, "The task id must be provided."); TenantId = tenantId; TaskId = taskId; Date = date.Date; HoursRemaining = hoursRemaining; }
public Discussion(Tenant tenantId, ForumId forumId, DiscussionId discussionId, Author author, string subject, string exclusiveOwner = null) { AssertionConcern.AssertArgumentNotNull(tenantId, "The tenant must be provided."); AssertionConcern.AssertArgumentNotNull(forumId, "The forum id must be provided."); AssertionConcern.AssertArgumentNotNull(discussionId, "The discussion id must be provided."); AssertionConcern.AssertArgumentNotNull(author, "The author must be provided."); AssertionConcern.AssertArgumentNotEmpty(subject, "The subject must be provided."); Apply(new DiscussionStarted(tenantId, forumId, discussionId, author, subject, exclusiveOwner)); }
public CurrentAttendanceMonth(DateTime startDay, DateTime endDay) { AssertionConcern.AssertArgumentNotNull(startDay, "Start day cannot be null."); AssertionConcern.AssertArgumentNotNull(endDay, "End day cannot be null."); AssertionConcern.AssertArgumentTrue(DateTime.Compare(startDay, endDay) >= 0, "End day must be larger than stard day."); this.StartDay = startDay; this.EndDay = endDay; this.Month = startDay.Month; }
public void InitiateDiscussion(DiscussionDescriptor descriptor) { AssertionConcern.AssertArgumentNotNull(descriptor, "The descriptor must not be null."); if (Discussion.Availability == DiscussionAvailability.Requested) { Discussion = Discussion.NowReady(descriptor); DomainEventPublisher.Instance.Publish( new BacklogItemDiscussionInitiated(TenantId, BacklogItemId, Discussion)); } }
/// <summary> /// Determines whether a <see cref="User"/> has a <see cref="Role"/>, /// given the names of the user and the role. /// </summary> /// <param name="tenantId"> /// A <see cref="TenantId"/> identifying a <see cref="Tenant"/> with /// which a <see cref="User"/> and <see cref="Role"/> are associated. /// </param> /// <param name="username"> /// The unique username identifying a <see cref="User"/>. /// </param> /// <param name="roleName"> /// The unique name identifying a <see cref="Role"/>. /// </param> /// <returns> /// <c>true</c> if the <see cref="User"/> has the /// <see cref="Role"/>; otherwise, <c>false</c>. /// </returns> public bool IsUserInRole(TenantId tenantId, string username, string roleName) { AssertionConcern.AssertArgumentNotNull(tenantId, "TenantId must not be null."); AssertionConcern.AssertArgumentNotEmpty(username, "Username must not be provided."); AssertionConcern.AssertArgumentNotEmpty(roleName, "Role name must not be null."); User user = _userRepository.UserWithUsername(tenantId, username); return((user != null) && IsUserInRole(user, roleName)); }
public InApporvalOvertimeOrder(Guid id, Guid staffId, OvertimeOrderMonth month, DateTime timeOfSubmited) { AssertionConcern.AssertArgumentNotEmptyGuid(id, "Overtime roder id cannot be null."); AssertionConcern.AssertArgumentNotEmptyGuid(staffId, "Overtime order staff id cannot be null."); AssertionConcern.AssertArgumentNotNull(timeOfSubmited, "Time of submited cannot be null."); this.Id = id; this.TimeOfSubmited = timeOfSubmited; this.Status = OvertimeOrderStatus.InApproval; }
public static DepartmentGroup Create(string code, string description) { AssertionConcern.AssertArgumentNotNull(description, "The Department Group description must be provided."); AssertionConcern.AssertArgumentLength(description, 100, "The Department Group description maximum is 100 characters."); var obj = new DepartmentGroup { Code = code, Description = description }; return(obj); }
public void Validar() { AssertionConcern.AssertArgumentNotEquals(new DateTime(), DataVencimento, string.Format(Erros.InvalidParameter, "DataVencimento")); AssertionConcern.AssertArgumentNotEquals(0.0M, ValorDocumento, string.Format(Erros.NotZeroParameter, "ValorDocumento")); AssertionConcern.AssertArgumentNotEquals(StatusContaReceber, StatusContaReceberEnum.None, string.Format(Erros.InvalidParameter, "StatusContaReceber")); AssertionConcern.AssertArgumentNotNull(Venda, Erros.SaleNotSet); }