Esempio n. 1
0
        public IEnumerable <Deposito> GetDepositosComGeoCoordenadas(string cdUnidadeNegocio)
        {
            using (var dapperConnection = AbreConexao())
            {
                PersistenceDataContext persistence = new PersistenceDataContext();

                dapperConnection.Open();

                var depositosUnidadeNegocio = dapperConnection
                                              .Query <Deposito>(@"SELECT * FROM OPMDM.TB_DEPOSITO Deposito
                                    INNER JOIN OPMDM.TB_PONTO_INTERESSE PontoInteresse ON PontoInteresse.CdPontoInteresse = Deposito.CdPontoInteresse
                                    WHERE Deposito.CdUnidadeNegocio = @CdUnidadeNegocio",
                                                                new[]
                {
                    typeof(Deposito),
                    typeof(PontoInteresse)
                },
                                                                objects =>
                {
                    Deposito Deposito             = objects[0] as Deposito;
                    PontoInteresse PontoInteresse = objects[1] as PontoInteresse;

                    if (Deposito != null)
                    {
                        Deposito.PontoInteresse = PontoInteresse;
                    }

                    return(Deposito);
                },
                                                                splitOn: "CdPontoInteresse",
                                                                param: new { CdUnidadeNegocio = cdUnidadeNegocio }).AsList();

                return(depositosUnidadeNegocio);
            }
        }
        public async Task <IActionResult> Index([Bind("Id")] PontoInteresse pontoInteresse)
        {
            var applicationDbContext = await _context.PontoInteresse.SingleOrDefaultAsync(c => c.Id.Equals(pontoInteresse.Id));

            ViewBag.Pontos = new SelectList(_context.PontoInteresse, "Id", "Nome");
            return(View(applicationDbContext));
        }
Esempio n. 3
0
        public ActionResult DeleteConfirmed(int id)
        {
            PontoInteresse pontoInteresse = db.PontosInteresse.Find(id);

            if (pontoInteresse.CoordenadasPoligono != null)
            {
                foreach (var coordenada in pontoInteresse.CoordenadasPoligono.ToList())
                {
                    db.Coordenadas.Remove(coordenada);
                }
            }
            if (pontoInteresse.CoordenadaIcon != null)
            {
                db.Coordenadas.Remove(pontoInteresse.CoordenadaIcon);
            }
            if (pontoInteresse.Imagens != null)
            {
                foreach (var imagem in pontoInteresse.Imagens.ToList())
                {
                    db.Imagens.Remove(imagem);
                }
            }

            db.PontosInteresse.Remove(pontoInteresse);
            try
            {
                db.SaveChanges();
            }
            catch (Exception)
            {
                return(View("ErroKey"));
            }
            return(RedirectToAction("Index"));
        }
        public async Task <IActionResult> Edit(int id, [Bind("PontoInteresseId,Nome,Local,DescricaoCurta")] PontoInteresse pontoInteresse)
        {
            if (id != pontoInteresse.PontoInteresseId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(pontoInteresse);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PontoInteresseExists(pontoInteresse.PontoInteresseId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                ViewBag.message = "Ponto de Interesse alterado com sucesso!";
                ViewBag.type    = "alert-sucess";
                // Volta para a página de Pontos de Interesse
                ViewBag.redirect = "/pontoInteresses/Index";
                // todo: inform the user that the author was successfully edited
                return(View("ConfirmaEditar"));
            }
            return(View(pontoInteresse));
        }
Esempio n. 5
0
        public ActionResult DeleteConfirmed(int id)
        {
            PontoInteresse pontoInteresse = db.PontosInteresse.Find(id);

            db.PontosInteresse.Remove(pontoInteresse);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 6
0
 public PontoApiDetalheModel(PontoInteresse ponto)
 {
     Localizacao = ponto.Localizacao;
     Autor       = ponto.Autor;
     Ano         = ponto.Ano;
     Descricao   = ponto.Descricao;
     Imagens     = ponto.Imagens.Select(i => new ImagensApiModel(i));
 }
 public PontoApiModel(PontoInteresse ponto)
 {
     Id                  = ponto.Id;
     Nome                = ponto.Nome;
     TipoEdificio        = ponto.TipoEdificio;
     CoordenadasPoligono = ponto.CoordenadasPoligono.Select(i => new CoordenadasPoligonoApiModel(i));
     LatitudeIcone       = ponto.CoordenadaIcon.Latitude;
     LongitudeIcone      = ponto.CoordenadaIcon.Longitude;
 }
Esempio n. 8
0
 public ActionResult Edit([Bind(Include = "Id,Nome,Descricao,MyProperty")] PontoInteresse pontoInteresse)
 {
     if (ModelState.IsValid)
     {
         db.Entry(pontoInteresse).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(pontoInteresse));
 }
Esempio n. 9
0
        public ActionResult Create([Bind(Include = "Id,Nome,Descricao,MyProperty")] PontoInteresse pontoInteresse)
        {
            if (ModelState.IsValid)
            {
                db.PontosInteresse.Add(pontoInteresse);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(pontoInteresse));
        }
Esempio n. 10
0
        public PontoApiDetalheModel GetPontoInteresse(int id)
        {
            PontoInteresse pontoInteresse = db.PontosInteresse.Find(id);

            if (pontoInteresse == null)
            {
                return(null);
            }

            return(new PontoApiDetalheModel(pontoInteresse));
        }
 public CreateEditPontoInteresseViewModel()
 {
     PontoInteresse = new PontoInteresse();
     TiposEdificios = new List <SelectListItem>
     {
         new SelectListItem {
             Value = "Edifício Publico", Text = "Edifício Público"
         },
         new SelectListItem {
             Value = "Edifício de Arquitectura Doméstica", Text = "Edifício de Arquitectura Doméstica"
         }
     };
 }
        public async Task <IActionResult> Create([Bind("PontoInteresseId,Nome,Local,DescricaoCurta")] PontoInteresse pontoInteresse, IFormFile photoFile, IFormFile photoFile2)
        {
            if (ModelState.IsValid)
            {
                if (photoFile != null && photoFile.Length > 0)
                {
                    using (var memFile = new MemoryStream())
                    {
                        photoFile.CopyTo(memFile);
                        //photoFile2.CopyTo(memFile);
                        pontoInteresse.Photo = memFile.ToArray();
                        //pontoInteresse.Photo2 = memFile.ToArray();
                    }
                }

                if (ModelState.IsValid)
                {
                    if (photoFile2 != null && photoFile2.Length > 0)
                    {
                        using (var memFile2 = new MemoryStream())
                        {
                            photoFile2.CopyTo(memFile2);
                            //pontoInteresse.Photo = memFile2.ToArray();
                            pontoInteresse.Photo2 = memFile2.ToArray();
                        }
                    }
                }
                //else if (photoFile != null && photoFileMap.Length > 0)
                //{
                //    using (var memFile = new MemoryStream())
                //    {
                //        photoFileMap.CopyTo(memFile);
                //        pontoInteresse.Photo2 = memFile.ToArray();
                //    }
                //}

                _context.Add(pontoInteresse);
                await _context.SaveChangesAsync();

                //return RedirectToAction(nameof(Index));

                ViewBag.message = "Ponto de Interesse adicionado com sucesso!";
                ViewBag.type    = "alert-sucess";
                //Volta para a página de Pontos de Interesse
                ViewBag.redirect = "/pontoInteresses/Index";

                // todo: inform the user that the author was successfully created
                return(View("ConfirmaInserir"));
            }
            return(View(pontoInteresse));
        }
Esempio n. 13
0
        // GET: PontoInteresses/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PontoInteresse pontoInteresse = db.PontosInteresse.Find(id);

            if (pontoInteresse == null)
            {
                return(HttpNotFound());
            }
            return(View(pontoInteresse));
        }
Esempio n. 14
0
        private IEnumerable <Ocorrencia> GetOcorrenciasCompletas(long cdRota, string query)
        {
            using (var dapperConnection = AbreConexao())
            {
                dapperConnection.Open();

                // Multi-Mapping
                List <Ocorrencia> ocorrencias = dapperConnection.Query <Ocorrencia>(query,
                                                                                    new[]
                {
                    typeof(Ocorrencia),
                    typeof(Parada),
                    typeof(PontoInteresse),
                    typeof(CategoriaPontoInteresse)
                },
                                                                                    objects =>
                {
                    Ocorrencia Ocorrencia         = objects[0] as Ocorrencia;
                    Parada Parada                 = objects[1] as Parada;
                    PontoInteresse PontoInteresse = objects[2] as PontoInteresse;
                    CategoriaPontoInteresse CategoriaPontoInteresse = objects[3] as CategoriaPontoInteresse;

                    if (PontoInteresse != null)
                    {
                        PontoInteresse.CategoriaPontoInteresse = CategoriaPontoInteresse;
                    }

                    if (Parada != null)
                    {
                        Parada.PontoInteresse = PontoInteresse;
                    }

                    if (Ocorrencia != null)
                    {
                        Ocorrencia.Parada = Parada;
                    }

                    return(Ocorrencia);
                },
                                                                                    splitOn: "CdOcorrencia, CdParada, CdPontoInteresse, CdCategoriaPontoInteresse",
                                                                                    param: new { CdRota = cdRota }).AsList();

                return(ocorrencias);
            }
        }
Esempio n. 15
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            PontoInteresse pontoInteresse = db.PontosInteresse.Find(id);

            if (pontoInteresse == null)
            {
                return(HttpNotFound());
            }
            var model = new CreateEditPontoInteresseViewModel();

            model.PontoInteresse = pontoInteresse;

            return(View(model));
        }
Esempio n. 16
0
        public IEnumerable <Ocorrencia> GetOcorrencias(long cdRota, string descricaoCategoriaPontoInteresse)
        {
            using (var dapperConnection = AbreConexao())
            {
                dapperConnection.Open();

                // Multi-Mapping
                List <Ocorrencia> ocorrencias = dapperConnection.Query <Ocorrencia>(
                    @"SELECT CAT_PIM.*, PIN.*, PARADA.*, OCORRENCIA.* FROM TB_OCORRENCIA OCORRENCIA
                        LEFT JOIN TB_PARADA PARADA ON OCORRENCIA.CdParada = PARADA.CdParada
                        LEFT JOIN TB_PONTO_INTERESSE PIN ON PARADA.CdPontoInteresse = PIN.CdPontoInteresse
                        LEFT JOIN TB_CATEGORIA_PONTO_INTERESSE CAT_PIN ON PIN.CdCategoriaPontoInteresse = CAT_PIN.CdCategoriaPontoInteresse
                        WHERE OCORRENCIA.CdRota = @CdRota AND CAT_PIN.DsCategoriaPontoInteresse LIKE '%' + @DsCategoriaPontoInteresse  + '%';",
                    new[]
                {
                    typeof(Ocorrencia),
                    typeof(Parada),
                    typeof(PontoInteresse),
                    typeof(CategoriaPontoInteresse)
                },
                    objects =>
                {
                    Ocorrencia Ocorrencia         = objects[0] as Ocorrencia;
                    Parada Parada                 = objects[1] as Parada;
                    PontoInteresse PontoInteresse = objects[2] as PontoInteresse;
                    CategoriaPontoInteresse CategoriaPontoInteresse = objects[3] as CategoriaPontoInteresse;

                    PontoInteresse.CategoriaPontoInteresse = CategoriaPontoInteresse;
                    Parada.PontoInteresse = PontoInteresse;
                    Ocorrencia.Parada     = Parada;

                    return(Ocorrencia);
                },
                    splitOn: "CdParada, CdPontoInteresse, CdCategoriaPontoInteresse",
                    param: new { CdRota = cdRota, DsCategoriaPontoInteresse = descricaoCategoriaPontoInteresse }).AsList();

                return(ocorrencias);
            }
        }