public AvaliacaoProfessorValidador(IProfessorServico professorServico, IUsuarioServico usuarioServico, IAulaServico aulaServico, IResourceLocalizer resource) { _professorServico = professorServico; _aulaServico = aulaServico; _usuarioServico = usuarioServico; _resource = resource; RuleFor(x => x.Nota) .NotNull() .NotEmpty() .Must(x => x <= 10 && x > 0) .WithMessage(_resource.GetString("RATING_REQUIRED")); RuleFor(x => x.ProfessorId) .NotEmpty() .NotNull() .WithMessage(string.Format(_resource.GetString("FIELD_REQUIRED"), "Id do Professor")) .Must(x => _professorServico.ObterProfessores(x).Count == 1) .WithMessage(string.Format(_resource.GetString("INEXISTENT_ID"), "Professor")); RuleFor(x => x.AlunoId) .NotEmpty() .NotNull() .WithMessage(string.Format(_resource.GetString("FIELD_REQUIRED"), "Id do Aluno")) .Must(x => _usuarioServico.ObterPorId(x) != null) .WithMessage(string.Format(_resource.GetString("INEXISTENT_ID"), "Aluno")); RuleFor(x => x.AulaId) .NotEmpty() .NotNull() .WithMessage(string.Format(_resource.GetString("FIELD_REQUIRED"), "Id da Aula")) .Must(x => _aulaServico.ObterAulaParaAvaliarPorId(x) != null) .WithMessage(string.Format(_resource.GetString("INEXISTENT_ID"), "Professor")); }
public ContratoAulaValidador(IResourceLocalizer resource, IUsuarioServico usuarioServico, IProfessorServico professorServico) { _resource = resource; _usuarioServico = usuarioServico; _professorServico = professorServico; RuleFor(x => x.DataInicioPrestacao) .NotNull() .NotEmpty() .WithMessage(string.Format(_resource.GetString("FIELD_REQUIRED"), "Data da aula")) .Must(x => x.Value.Date > DateTime.Now.Date) .WithMessage(_resource.GetString("AULA_PRESTACAO_RESTRICT")); RuleFor(x => x.AlunoId) .Must(alunoId => _usuarioServico.ObterPorId(alunoId, true) != null) .WithMessage(string.Format(_resource.GetString("INEXISTENT_ID"), "Aluno")); RuleFor(x => x.ProfessorId) .Must(professorId => _professorServico.ObterProfessores(professorId).Count == 1) .WithMessage(string.Format(_resource.GetString("INEXISTENT_ID"), "Professor")); RuleFor(x => x.ValorHora) .NotNull() .NotEmpty() .WithMessage(string.Format(_resource.GetString("FIELD_REQUIRED"), "Valor por Hora")) .Must(x => x >= 10 && x <= 200) .WithMessage(string.Format(_resource.GetString("VALUE_HOUR_RULE"), "10", "200")); RuleFor(x => x.HorasContratadas) .NotNull() .NotEmpty() .WithMessage(string.Format(_resource.GetString("FIELD_REQUIRED"), "Horas Contratadas")) .Must(x => x > 1) .WithMessage(string.Format(_resource.GetString("MINIMUM_HOUR_RESTRICT"), "1")); }
public ActionResult <List <ProfessorViewModel> > ObterProfessores(long id = 0, string nome = null, string disciplina = null) { _logger.LogDebug("ObterProfessores"); var resultado = _servico.ObterProfessores(id, nome, disciplina); return(resultado.Count > 0 ? (ActionResult)Ok(resultado.Select(r => _mapper.Map <ProfessorViewModel>(r)).ToList()) : NoContent()); }