public TrechoController(VooContext contexto, ITrechoRepository trechoRepositorio, TrechoService trechoService, ILocalRepository localRepository)
 {
     this.contexto          = contexto;
     this.trechoRepositorio = trechoRepositorio;
     this.trechoService     = trechoService;
     this.localRepository   = localRepository;
 }
Exemple #2
0
 public TrechoController(ITrechoRepository trechoRepository,
                         TrechoService trechoService, PassagensContext contexto,
                         ILocalRepository localRepository)
 {
     this.trechoRepository = trechoRepository;
     this.trechoService    = trechoService;
     this.localRepository  = localRepository;
     this.contexto         = contexto;
 }
Exemple #3
0
        public IActionResult Put(int id, [FromBody] TrechoDto trechoRequest)
        {
            var trecho          = MapearDtoParaDominio(trechoRequest);
            var inconsistencias = TrechoService.Validar(trecho);

            if (inconsistencias.Any())
            {
                return(BadRequest(inconsistencias));
            }

            trechoRepository.Editar(id, trecho);
            context.SaveChanges();
            return(Ok());
        }
        public void TestandoDadosDeDestinoFaltando()
        {
            var erros = new List <string>();

            erros.Add("Campo Destino é obrigatorio");

            var origem = new Local("New York", "Ta no meio de Manhattan", 40.76, -73.984);

            var trecho = new Trecho(origem, null);

            var trechoService = new TrechoService();

            var resultado = trechoService.Validar(trecho);

            CollectionAssert.AreEqual(erros, resultado);
        }
        public void TestandoDadosDeOrigemFaltando()
        {
            var erros = new List <string>();

            erros.Add("Campo Origem é obrigatorio");

            var destino = new Local("Roma", "Ta no coliseu de Roma", 41.89, 12.492);

            var trecho = new Trecho(null, destino);

            var trechoService = new TrechoService();

            var resultado = trechoService.Validar(trecho);

            CollectionAssert.AreEqual(erros, resultado);
        }
Exemple #6
0
 public TrechoController(ITrechoRepository trechoRepository, TrechoService trechoService, PassagensAereasContext contexto)
 {
     this.trechoRepository = trechoRepository;
     this.trechoService    = trechoService;
     this.contexto         = contexto;
 }