Пример #1
0
        public ActionResult ExcluirDemanda(long idDemanda)
        {
            PontoEntrega     pontoEntrega_bd     = UnitOfWork.PontoEntregaRepository.Get(p => p.IdPontoEntrega == idDemanda && p.DataExclusao == null).FirstOrDefault();
            VaosDemandaPoste vaosDemandaPoste_bd = UnitOfWork.VaosDemandaPosteRepository.Get(v => v.IdPontoEntrega == idDemanda && pontoEntrega_bd.DataExclusao == null).FirstOrDefault();

            if (vaosDemandaPoste_bd != null)
            {
                vaosDemandaPoste_bd.DataExclusao = DateTime.Now;
                UnitOfWork.VaosDemandaPosteRepository.Update(vaosDemandaPoste_bd);
                UnitOfWork.Save();
            }
            if (pontoEntrega_bd != null)
            {
                pontoEntrega_bd.DataExclusao = DateTime.Now;
                UnitOfWork.PontoEntregaRepository.Update(pontoEntrega_bd);
                UnitOfWork.Save();

                return(Json(new ResponseView()
                {
                    Status = Status.OK, Result = Resources.Messages.Save_OK
                }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new ResponseView()
                {
                    Status = Status.NotFound, Result = Resources.Messages.Poste_Not_Found
                }, JsonRequestBehavior.AllowGet));
            }
        }
Пример #2
0
        public VaosDemandasView VaoToVaoView(VaosDemandaPoste vaos_bd)
        {
            //Poste poste = UnitOfWork.PosteRepository.Get(p => p.IdPoste == vaos_bd.IdPoste).FirstOrDefault();
            Cidade cidade = UnitOfWork.CidadeRepository.Get(c => c.IdCidade == vaos_bd.IdCidade).FirstOrDefault();

            ConverterUtmToLatLon converter = new ConverterUtmToLatLon(cidade.Datum, cidade.NorteOuSul, cidade.Zona);
            LatLon LatiLong1 = converter.Convert(vaos_bd.X1, vaos_bd.Y1);
            LatLon LatiLong2 = converter.Convert(vaos_bd.X2, vaos_bd.Y2);

            VaosDemandasView vaos = new VaosDemandasView();

            vaos.X1 = LatiLong1.Lat;
            vaos.Y1 = LatiLong1.Lon;
            vaos.X2 = LatiLong2.Lat;
            vaos.Y2 = LatiLong2.Lon;

            return(vaos);
        }
Пример #3
0
        public ActionResult SalvarPontoEntregaNovo(PontoEntregaView PontoEntregaReceived)
        {
            Cidade Cidade = UnitOfWork.CidadeRepository.Get(c => c.IdCidade == PontoEntregaReceived.IdCidade).FirstOrDefault();

            if (Cidade != null)
            {
                double latPonto = Double.Parse(PontoEntregaReceived.LatitudeTexto, System.Globalization.CultureInfo.InvariantCulture);
                double lonPonto = Double.Parse(PontoEntregaReceived.LongitudeTexto, System.Globalization.CultureInfo.InvariantCulture);

                //double latPoste = Double.Parse(PontoEntregaReceived.LatitudePosteTexto, System.Globalization.CultureInfo.InvariantCulture);
                //  double lonPoste = Double.Parse(PontoEntregaReceived.LongitudePosteTexto, System.Globalization.CultureInfo.InvariantCulture);

                OrdemDeServico ordemServico = UnitOfWork.OrdemDeServicoRepository.Get(or => or.NumeroOS == PontoEntregaReceived.IdOrdemServicoTexto).FirstOrDefault();

                ConverterLatLonToUtm converter = new ConverterLatLonToUtm(Cidade.Datum, Cidade.NorteOuSul, Cidade.Zona);
                UTM utmPonto = converter.Convert(latPonto, lonPonto);
                //    UTM utmPoste = converter.Convert(latPoste, lonPoste);

                PontoEntrega new_ponto_entrega = new PontoEntrega();

                new_ponto_entrega.IdCidade     = PontoEntregaReceived.IdCidade;
                new_ponto_entrega.IdPoste      = PontoEntregaReceived.IdPoste;
                new_ponto_entrega.CodigoGeoBD  = PontoEntregaReceived.CodigoGeoBD;
                new_ponto_entrega.Complemento1 = PontoEntregaReceived.Complemento1;
                // new_ponto_entrega.ClasseAtendimento = PontoEntregaReceived.ClasseAtendimento;
                // new_ponto_entrega.TipoConstrucao = PontoEntregaReceived.TipoConstrucao;
                new_ponto_entrega.Numero       = PontoEntregaReceived.Numero;
                new_ponto_entrega.ClasseSocial = PontoEntregaReceived.ClasseSocial;
                // new_ponto_entrega.Logradouro = PontoEntregaReceived.Logradouro;
                // new_ponto_entrega.Fase = PontoEntregaReceived.Fase;
                // new_ponto_entrega.EtLigacao = PontoEntregaReceived.EtLigacao;
                // new_ponto_entrega.Observacao = PontoEntregaReceived.Observacao;
                new_ponto_entrega.X = utmPonto.X;
                new_ponto_entrega.Y = utmPonto.Y;
                new_ponto_entrega.IdOrdemDeServico = ordemServico.IdOrdemDeServico;
                new_ponto_entrega.DataInclusao     = DateTime.Now;

                new_ponto_entrega.Classificacao             = PontoEntregaReceived.Classificacao;
                new_ponto_entrega.Ocorrencia                = PontoEntregaReceived.Ocorrencia;
                new_ponto_entrega.QtdDomicilio              = PontoEntregaReceived.QtdDomicilio;
                new_ponto_entrega.QtdSalas                  = PontoEntregaReceived.QtdDomicilioComercio;
                new_ponto_entrega.NumeroAndaresEdificio     = PontoEntregaReceived.NumeroAndaresEdificio;
                new_ponto_entrega.TotalApartamentosEdificio = PontoEntregaReceived.TotalApartamentosEdificio;
                new_ponto_entrega.NomeEdificio              = PontoEntregaReceived.NomeEdificio;
                new_ponto_entrega.QtdBlocos                 = PontoEntregaReceived.QtdBlocos;
                new_ponto_entrega.TipoComercio              = PontoEntregaReceived.ClassificacaoComercio;


                /// Atualizando o Ponto Entrega
                UnitOfWork.PontoEntregaRepository.Insert(new_ponto_entrega);

                /*  if (PontoEntregaReceived.Medidores != null)
                 * {
                 *    foreach (MedidorView medidor_view in PontoEntregaReceived.Medidores)
                 *    {
                 *        /// Inserindo os Medidores
                 *        UnitOfWork.MedidoresRepository.Insert(new Medidor
                 *        {
                 *            IdPontoEntrega = new_ponto_entrega.IdPontoEntrega,
                 *            NumeroMedidor = medidor_view.NumeroMedidor,
                 *            ComplementoResidencial = medidor_view.ComplementoResidencial
                 *        });
                 *    }
                 * }*/

                /*   foreach (FotoPontoEntregaView foto in PontoEntregaReceived.Fotos)
                 * {
                 *     /// Nao deve Vim foto_view.DataFoto vazio mas se vim nao quebra o codigo
                 *     DateTime DataDiretorio = foto.DataFoto != String.Empty ? Convert.ToDateTime(foto.DataFoto) : DateTime.Now;
                 *     String Data = DataDiretorio.ToString("ddMMyyyy");
                 *
                 *     FotoPontoEntrega novaFoto = new FotoPontoEntrega();
                 *     novaFoto.CodigoGeoBD = -1;
                 *     novaFoto.DataFoto = Convert.ToDateTime(foto.DataFoto);
                 *     novaFoto.IdPontoEntrega = new_ponto_entrega.IdPontoEntrega;
                 *     novaFoto.NumeroFoto = foto.NumeroFoto.Trim();
                 *     novaFoto.DataExclusao = null;
                 *     novaFoto.Path = string.Format(ConfigurationManager.AppSettings["NewPathFotos"], Cidade.CidadeDiretorio, Data, User.Identity.Name.ToUpper(), foto.NumeroFoto.Trim().ToUpper());
                 *     novaFoto.PontoEntrega = new_ponto_entrega;
                 *
                 *     UnitOfWork.FotoPontoEntregaRepository.Insert(novaFoto);
                 * }*/
                UnitOfWork.Save();
                PontoEntrega pontoEntrega = UnitOfWork.PontoEntregaRepository.Get(p => p.IdPontoEntrega == new_ponto_entrega.IdPontoEntrega).FirstOrDefault();

                Poste Poste = UnitOfWork.PosteRepository.Get(p => p.IdPoste == PontoEntregaReceived.IdPoste).FirstOrDefault();
                if (Poste != null)
                {
                    VaosDemandaPoste vaosDemandaPoste = new VaosDemandaPoste
                    {
                        IdCidade         = PontoEntregaReceived.IdCidade,
                        IdOrdemDeServico = ordemServico.IdOrdemDeServico,
                        IdPoste          = PontoEntregaReceived.IdPoste,
                        IdPontoEntrega   = new_ponto_entrega.IdPontoEntrega,
                        X1 = Poste.X,
                        Y1 = Poste.Y,
                        X2 = utmPonto.X,
                        Y2 = utmPonto.Y,
                    };
                    UnitOfWork.VaosDemandaPosteRepository.Insert(vaosDemandaPoste);
                    UnitOfWork.Save();

                    VaosDemandaPoste VaosDemandaPoste = UnitOfWork.VaosDemandaPosteRepository.Get(v => v.IdVaosDemandaPoste == vaosDemandaPoste.IdVaosDemandaPoste).FirstOrDefault();

                    //                return Json(new MetodosPontoEntregaView().PontoEntregaToPontoEntregaView(PontoEntrega), JsonRequestBehavior.AllowGet);

                    return(Json(new
                    {
                        Demanda = new MetodosPontoEntregaView().PontoEntregaToPontoEntregaView(pontoEntrega),
                        VaoDemandaPoste = new VaosDemandasPaginadoView().VaoToVaoView(VaosDemandaPoste)
                    }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new
                    {
                        Demanda = new MetodosPontoEntregaView().PontoEntregaToPontoEntregaView(pontoEntrega)
                    },
                                JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                return(Json(new ResponseView()
                {
                    Status = Status.NotFound, Result = "Cidade nao encontrada"
                }, JsonRequestBehavior.AllowGet));
            }
        }