Example #1
0
        public async Task <ActionResult> Post([FromBody] CidadeModel value, [FromServices] ICidadeService cidadeService)
        {
            if (value != null)
            {
                var cidadesFronteira = new List <Cidade>();

                if (value.Fronteiras != null && value.Fronteiras.Any())
                {
                    foreach (var cidade in value.Fronteiras)
                    {
                        var cidadeFronteira = await cidadeService.GetById(cidade);

                        if (cidadeFronteira == null)
                        {
                            return(NotFound("Cidade fronteira não encontrada"));
                        }

                        cidadesFronteira.Add(cidadeFronteira);
                    }
                }

                var novaCidade = await cidadeService.Add(new Cidade
                {
                    Habitantes = value.Habitantes,
                    Nome       = value.Nome,
                    Fronteiras = cidadesFronteira
                });
            }
            return(Ok());
        }
Example #2
0
        public ActionResult ShortPath([FromServices] ICidadeService cidadeService, [FromServices] IFronteiraService fronteiraService, int inicio, int final)
        {
            var cidadeInicio = cidadeService.GetById(inicio).Result;

            if (cidadeInicio == null)
            {
                return(NotFound(new { success = false, msg = "Cidade inicial não informada" }));
            }

            var cidadeFim = cidadeService.GetById(final).Result;

            if (cidadeInicio == null)
            {
                return(NotFound(new { success = false, msg = "Cidade final não informada" }));
            }

            var vertices   = cidadeService.GetAll().Result.ToArray();
            var fronteiras = fronteiraService.GetAll().Result.ToArray();
            var edges      = new List <Tuple <Cidade, Cidade> >();

            foreach (var fronteira in fronteiras)
            {
                var cidade1 = cidadeService.GetById(fronteira.Cidade1);
                var cidade2 = cidadeService.GetById(fronteira.Cidade2);
                edges.Add(Tuple.Create(cidade1.Result, cidade2.Result));
            }

            // var grafo = new Graph<int>(vertices, edges.ToArray());
            var grapho       = new Graph <Cidade>(vertices, edges);
            var menorCaminho = BuscaMenorCaminho.ShortestPathFunction(grapho, cidadeInicio);

            // var menorCaminho = BuscaMenorCaminho.ShortestPathFunction(grafo, inicio);
            return(Json(new { result = _mapper.Map <IEnumerable <CidadeViewModel> >(menorCaminho(cidadeFim)) }));
            // return Json(new { result = menorCaminho(final) });
        }
Example #3
0
 public EstadoController(
     ILogger <EstadoController> logger,
     ICidadeService cidadeService)
 {
     _logger        = logger;
     _cidadeService = cidadeService;
 }
 public CidadeCachingService(
     IMemoryCache cache,
     ICidadeService decoratedService
     )
 {
     _cache            = cache;
     _decoratedService = decoratedService;
 }
Example #5
0
 public PacientesController(IPacienteService pacienteService, IPaisService paisService, IEstadoService estadoService,
                            ICidadeService cidadeService)
 {
     _pacienteService = pacienteService;
     _paisService     = paisService;
     _estadoService   = estadoService;
     _cidadeService   = cidadeService;
 }
 public CidadesController(IMapper mapper,
                          ICidadeService cidadeService,
                          IUriService uriService,
                          INotificador notificador,
                          IUser user) : base(mapper, uriService, notificador, user)
 {
     _mapper        = mapper;
     _cidadeService = cidadeService;
 }
Example #7
0
        public async Task <IActionResult> Put(int id, [FromBody] Cidade cidade, [FromServices] ICidadeService cidadeService)
        {
            if (cidade == null || id != cidade.Id)
            {
                return(BadRequest());
            }

            await cidadeService.Update(cidade);

            return(Ok());
        }
Example #8
0
        public async Task <IActionResult> GetTotalHabitantes(int[] listaInteiros, [FromServices] ICidadeService cidadeService)
        {
            if (listaInteiros == null || listaInteiros.Length == 0)
            {
                return(BadRequest());
            }

            var total = await cidadeService.GetTotalHabitantes(listaInteiros);

            return(Ok(total));
        }
Example #9
0
        public void Init()
        {
            // Create the container builder.
            var servicesColletcion = new ServiceCollection();

            servicesColletcion.AddTransient <IUnitOfWork, UnitOfWork>();
            servicesColletcion.AddDbContext <SisLogFreteContext>(
                options => options.UseSqlServer(@"Server="));
            servicesColletcion.AddTransient <ICidadeService, CidadeService>();

            _provider      = servicesColletcion.BuildServiceProvider();
            _unitOfWork    = _provider.GetService <IUnitOfWork>();
            _cidadeService = _provider.GetService <ICidadeService>();
        }
 public EmpresaService(
     IEmpresaRepository empresaRepository,
     ICidadeService cidadeService,
     IEnderecoRepository enderecoRepository,
     IOptions <ConnectionStrings> connectionStrings,
     IPrestadorService prestadorService,
     IUnitOfWork unitOfWork)
 {
     _empresaRepository  = empresaRepository;
     _cidadeService      = cidadeService;
     _enderecoRepository = enderecoRepository;
     _unitOfWork         = unitOfWork;
     _connectionStrings  = connectionStrings;
     _prestadorService   = prestadorService;
 }
Example #11
0
 public CidadeController(ICidadeService service)
 {
     this.service = service;
 }
Example #12
0
 public CidadeController(ICidadeService service) : base(service)
 {
 }
Example #13
0
 public CidadeController(ICidadeService cidadeService,
                         IAutenticacaoService autenticacaoService)
 {
     this._autenticacaoService = autenticacaoService;
     this._cidadeService       = cidadeService;
 }
 public UsuarioController(IUsuarioService usuarioService, ICidadeService cidadeService)
 {
     _usuarioService = usuarioService;
     _cidadeService  = cidadeService;
 }
Example #15
0
 public CidadeAppService(ICidadeService CidadeService) : base(CidadeService)
 {
     _cidadeService = CidadeService;
 }
Example #16
0
 public CidadeAppService(ICidadeService serviceBase) : base(serviceBase)
 {
     _cidadeService = serviceBase;
 }
Example #17
0
 public CidadeController(
     ICidadeService cidadeService
     )
 {
     _cidadeService = cidadeService;
 }
 public CidadeApplicationService(ICidadeService cidadeService) : base(cidadeService)
 {
     _cidadeService = cidadeService;
 }
Example #19
0
 public async Task <CidadeViewModel> GetByName([FromServices] ICidadeService cidadeService,
                                               string nomeCidade)
 {
     return(_mapper.Map <CidadeViewModel>(await cidadeService.GetByNameAsync(nomeCidade)));
 }
Example #20
0
 public async Task <CidadeViewModel> GetByIdFronteira([FromServices] ICidadeService cidadeService, int id)
 {
     return(_mapper.Map <CidadeViewModel>(await cidadeService.GetByIdFronteiras(id)));
 }
Example #21
0
        public async Task <IEnumerable <CidadeViewModel> > GetAll([FromServices] ICidadeService cidadeService)
        {
            var cidades = _mapper.Map <IEnumerable <CidadeViewModel> >(await cidadeService.GetAllFronteira());

            return(cidades);
        }
 public AlunoController(IAlunoService alunoService, ICidadeService cidadeService)
 {
     _alunoService  = alunoService;
     _cidadeService = cidadeService;
 }
Example #23
0
 public CidadeApp(ICidadeService cidadeService, IUnitOfWork unitOfWork) : base(unitOfWork)
 {
     _cidadeService = cidadeService;
 }
 public CidadeController(ICidadeService cidadeService, IEnderecoService enderecoService)
 {
     _cidadeService   = cidadeService;
     _enderecoService = enderecoService;
 }
 public CidadesController(Notifications notifications, ICidadeService cidadeService)
 {
     _notifications = notifications;
     _cidadeService = cidadeService;
 }
 public CidadeServiceApp(ICidadeService service, IUnitOfWork uow) : base(uow)
 {
     this.service = service;
 }
Example #27
0
 public CidadeAppService(ICidadeService cidadeService)
 {
     _cidadeService = cidadeService;
 }
Example #28
0
 public CidadeController(ICidadeService cidadeService, INotify notify, IMapper mapper)
 {
     _cidadeService = cidadeService;
     _notify        = notify;
     _mapper        = mapper;
 }
 public CidadeAppServicos(ICidadeService cidadeServicos, IUnitofWork uow) : base(uow)
 {
     _cIdadeServicos = cidadeServicos;
 }
Example #30
0
 public CidadeController(DominioDbContext contextDominio, ApiDbContext context)
 {
     _service = new CidadeService(contextDominio, context);
 }