示例#1
0
        public async Task <ActionResult> mtdActualizaLugar(int id, [FromBody] Lugares lugares)
        {
            try
            {
                var response = await context.tblugares.FirstOrDefaultAsync(x => x.id == id);

                if (response.id != id)
                {
                    return(BadRequest());
                }

                response.last_modified_date = DateTime.Now;
                response.last_modified_by   = lugares.last_modified_by;
                response.str_latitud        = lugares.str_latitud;
                response.str_longitud       = lugares.str_longitud;
                response.str_lugar          = lugares.str_lugar;
                response.int_id_zona_id     = response.int_id_zona_id;
                response.intidconcesion_id  = response.intidconcesion_id;
                await context.SaveChangesAsync();

                return(Ok());
            }
            catch (Exception ex)
            {
                //ModelState.AddModelError("token", ex.Message);
                //return BadRequest(ModelState);
                return(Json(new { token = ex.Message }));
            }
        }
示例#2
0
        public bool crearLugar(Lugares lugar)

        {
            var values = new Dictionary <string, string>
            {
                { "Nombre", lugar.Nombre },
            };

            var content      = new FormUrlEncodedContent(values);
            var responseTask = conexion.client.PostAsync("Lugar/", content);

            responseTask.Wait();
            var result = responseTask.Result;

            if (result.IsSuccessStatusCode)
            {
                var readTask = result.Content.ReadAsStringAsync();
                readTask.Wait();
                JavaScriptSerializer serializer = new JavaScriptSerializer();

                var lugares = serializer.Deserialize <List <Lugares> >(readTask.Result);

                return(true);
            }
            return(false);
        }
示例#3
0
        private async Task Agregar_marcadores()
        {
            if (GlobalValues.arr_lugares.Count > 0)
            {
                LatLngBounds.Builder         builder = new LatLngBounds.Builder();
                List <Manboss_mandados_ruta> puntos  = new List <Manboss_mandados_ruta>();
                foreach (Lugares aux in GlobalValues.arr_lugares)
                {
                    MarkerOptions markerOpt1 = new MarkerOptions();
                    LatLng        lugar      = new LatLng(aux.Latitud, aux.Longitud);
                    builder.Include(lugar);
                    markerOpt1.SetPosition(lugar);
                    markerOpt1.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.mandado));
                    _map.AddMarker(markerOpt1);
                    Manboss_mandados_ruta posicion = new Manboss_mandados_ruta();
                    posicion.Latitud  = aux.Latitud;
                    posicion.Longitud = aux.Longitud;
                    puntos.Add(posicion);
                }
                //polyline
                await Obtener_direcciones(puntos);

                //Mover camera
                LatLngBounds bounds       = builder.Build();
                CameraUpdate cameraUpdate = CameraUpdateFactory.NewLatLngBounds(bounds, 300);
                _map.MoveCamera(cameraUpdate);
                //Revisar mínimo de ubicaciones
                Lugares primero = GlobalValues.arr_lugares.First();
                if (GlobalValues.arr_lugares.Count >= primero.Min)
                {
                    btn_pagar_mandado.Visibility = ViewStates.Visible;
                }
            }
        }
示例#4
0
        public async Task <ActionResult <Lugares> > mtdIngresarLugar([FromBody] Lugares lugares)
        {
            try
            {
                var response = await context.tblugares.FirstOrDefaultAsync(x => x.str_lugar == lugares.str_lugar);

                if (response == null)
                {
                    lugares.created_date       = DateTime.Now;
                    lugares.last_modified_date = DateTime.Now;
                    context.tblugares.Add(lugares);
                    await context.SaveChangesAsync();

                    return(Ok());
                }
                //ModelState.AddModelError("token", "El registro ya existe");
                //return BadRequest(ModelState);
                return(Json(new { token = "El registro ya existe" }));
            }

            catch (Exception ex)
            {
                //ModelState.AddModelError("token", ex.Message);
                //return BadRequest(ModelState);
                return(Json(new { token = ex.Message }));
            }
        }
示例#5
0
 public IActionResult Create([FromBody] Lugares item)
 {
     if (item == null)
     {
         return(BadRequest());
     }
     _repo.Add(item);
     return(CreatedAtRoute("GetLugares", new { controller = "Lugares", id = item.Id }, item));
 }
示例#6
0
 public ActionResult Edit([Bind(Include = "IdLugar,Nombre")] Lugares lugar)
 {
     if (ModelState.IsValid)
     {
         NLugares temp = new NLugares();
         temp.actualizarLugar(lugar);
         return(RedirectToAction("Index"));
     }
     return(View(lugar));
 }
示例#7
0
        public ActionResult Create([Bind(Include = "Nombre")] Lugares lugar)
        {
            if (ModelState.IsValid)
            {
                NLugares temp = new NLugares();
                temp.crearLugar(lugar);

                return(RedirectToAction("Index"));
            }

            return(View(lugar));
        }
示例#8
0
        public IEnumerable <Lugares> LeerItinerarioLugar(int pNroPedido, int pNroPropuesta, int pNroVersion, int pAnio, int pMes, int pDia)
        {
            string lineagg = "0";

            try
            {
                List <ItinerarioViaje> lstItinerario  = new List <ItinerarioViaje>();
                List <Lugares>         lstLugares     = new List <Lugares>();
                List <Actividades>     lstActividades = new List <Actividades>();

                lineagg += ",1";
                using (SqlConnection con = new SqlConnection(Data.Data.StrCnx_WebsSql))
                {
                    SqlCommand cmd = new SqlCommand("latinamericajourneys.LAJ_Itinerario_Lugar_S", con);

                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@NroPedido", SqlDbType.Int).Value    = pNroPedido;
                    cmd.Parameters.Add("@NroPropuesta", SqlDbType.Int).Value = pNroPropuesta;
                    cmd.Parameters.Add("@NroVersion", SqlDbType.Int).Value   = pNroVersion;
                    cmd.Parameters.Add("@Anio", SqlDbType.Int).Value         = pAnio;
                    cmd.Parameters.Add("@Mes", SqlDbType.Int).Value          = pMes;
                    cmd.Parameters.Add("@Dia", SqlDbType.Int).Value          = pDia;

                    lineagg += ",2";
                    con.Open();
                    cmd.ExecuteNonQuery();
                    SqlDataReader rdr = cmd.ExecuteReader();
                    lineagg += ",3";
                    while (rdr.Read())
                    {
                        lineagg += ",5";

                        Lugares flugar = new Lugares
                        {
                            Lugar = rdr["Lugar"].ToString(),
                        };

                        lstLugares.Add(item: flugar);
                    }

                    lineagg += ",5";
                    con.Close();
                }

                return(lstLugares);
            }
            catch (Exception ex)
            {
                throw new Exception {
                          Source = lineagg
                };
            }
        }
示例#9
0
        // GET: Lugares/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            NLugares lugares = new NLugares();
            Lugares  temp    = lugares.getLugares().Where(x => x.IdLugar == id).FirstOrDefault();

            if (temp == null)
            {
                return(HttpNotFound());
            }
            return(View(temp));
        }
示例#10
0
        private void Agregar_lugar()
        {
            bool    validar     = true;
            string  select      = spinner_servicio.SelectedItem.ToString();
            int     servicio_id = 0;
            Lugares a           = new Lugares();

            foreach (Manboss_servicios aux in servicios)
            {
                if (aux.Nombre.Equals(select))
                {
                    servicio_id = aux.Id;
                    a.Min       = Int32.Parse(aux.Ubicaciones);
                }
            }
            if (servicio_id == 0 || latitud.Equals(Double.NaN) || longitud.Equals(Double.NaN) || calle.Text == "" || numero.Text == "" || comentarios.Text == "")
            {
                validar = false;
            }
            TextView mensaje = FindViewById <TextView>(Resource.Id.mensaje_agregar_lugar);

            if (validar)
            {
                a.Servicio    = servicio_id;
                a.Latitud     = latitud;
                a.Longitud    = longitud;
                a.Calle       = calle.Text;
                a.Numero      = Int32.Parse(numero.Text);
                a.Comentarios = comentarios.Text;
                a.Terminado   = 0;
                a.Direccion   = direccion;
                GlobalValues.addLugar(a);
                mensaje.Visibility = ViewStates.Invisible;
                //Volver al Mapa
                Intent nueva_form = new Intent(this, typeof(InicioActivity));
                StartActivity(nueva_form);
            }
            else
            {
                mensaje.Visibility = ViewStates.Visible;
            }
        }
示例#11
0
        public bool actualizarLugar(Lugares valor)
        {
            var values = new Dictionary <string, string>
            {
                { "Nombre", valor.Nombre },
            };
            var content      = new FormUrlEncodedContent(values);
            var responseTask = conexion.client.PutAsync("Lugar/" + valor.IdLugar.ToString(), content);

            responseTask.Wait();


            var result = responseTask.Result;
            var a      = result.RequestMessage;

            if (result.IsSuccessStatusCode)
            {
                return(true);
            }

            return(false);
        }
        private static XElement CreateBookItem(string titleValue, int numberPagesValue, string isbnValue, Lugares ubicacionValor,  string descripcionValor, int idValue)
        {
            XElement title = new XElement(BooksTitle, titleValue);
            XElement numberOfPages = new XElement(BooksNumberPages, numberPagesValue);
            XElement isbn = new XElement(BooksISBN, isbnValue);
            XElement ubicacion = new XElement(BooksUbicacion, ubicacionValor.ToString());
            XElement descripcion = new XElement(BooksDescription, descripcionValor);
            XElement id = new XElement(BooksID, idValue);

            XElement book = new XElement(BooksElement, title, numberOfPages, isbn, ubicacion, descripcion, id);
            return book;
        }
示例#13
0
        public async void LugarMethod()
        {
            //Se activa el ActivityIndicator
            this.VisibleLugar = true;
            this.RunningLugar = true;

            //Se solicita conexion al servidor
            var connection = await this.apiService.CheckConnection();

            //Se verifica la conexion al servidor
            if (!connection.IsSuccess)
            {
                //Se desactiva el ActivityIndicator
                this.RunningLugar = false;
                this.VisibleLugar = false;

                //Mensaje para el usuario
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    connection.Message,
                    "Aceptar");

                return;
            }
            else
            {
                //Se solicita la lista de lugares
                var response = await this.apiService.GetList <DataLugar>("https://" + Settings.Servidor + "/controladores/", "lugar.controlador.php");

                //Se verifica el correcto recibimiento de los lugares
                if (!response.IsSuccess)
                {
                    //Se desactiva el ActivityIndicator
                    this.RunningLugar = false;
                    this.VisibleLugar = false;

                    //Mensaje para el usuario
                    await Application.Current.MainPage.DisplayAlert(
                        "ERROR",
                        response.Message,
                        "Aceptar");
                }

                //Casteo de la respuesta del servidor para la manipulación dentro del código
                var list = (List <DataLugar>)response.Result;

                //Banderas creadas
                int rows = 0;

                //Reseteo de la instancia de lugares en el XAML
                this.Lugares = new ObservableCollection <string>()
                {
                    "Seleccione un lugar"
                };

                //Agregar los lugares a base de datos
                using (SQLiteConnection conn = new SQLiteConnection(App.DatabaseLocation))
                {
                    //Reseteo de la tabla
                    conn.DropTable <Lugares>();
                    conn.CreateTable <Lugares>();

                    //Inserción de los lugares a la tabla y a la instancia de XAML
                    for (int i = 0; i < list.Count; i++)
                    {
                        Lugares Lugar = new Lugares()
                        {
                            Id    = list[i].Id_Lugar,
                            Lugar = list[i].Nombre_Lugar
                        };

                        this.Lugares.Add(list[i].Nombre_Lugar);

                        rows += conn.Insert(Lugar);
                    }
                }

                //Seleccionar el valor por deafult
                this.LugarSelected = this.Lugares.ElementAt(0);

                //Se desactiva el ActivityIndicator
                this.RunningLugar = false;
                this.VisibleLugar = false;

                //Mensajes de exito y error
                if (rows > 0)
                {
                    await Application.Current.MainPage.DisplayAlert(
                        "EXITO",
                        "Los datos han sido actualizados \n\"DEBE SELECCIONAR UN LUGAR\"",
                        "Aceptar");
                }
                else
                {
                    await Application.Current.MainPage.DisplayAlert(
                        "ERROR",
                        "Los valores recibidos no se almacenaron en el dispositivo",
                        "Aceptar");
                }
            }
        }
示例#14
0
        public IList<Book> GetBooksByFilters(string title, int? numberOfPages, Lugares? ubicacion, string isbn)
        {
            List<Book> result = new List<Book>();

            XDocument xmlDoc = XMLHelper.LoadDocument(XMLBooksFilePath + XMlBooksFileName);

            var query = from book in xmlDoc.Element(BooksRoot).Elements(BooksElement)//
                        where (string.IsNullOrEmpty(title) || book.Element(BooksTitle).Value.ToUpper().Contains(title.ToUpper()))
                              &&
                              (!numberOfPages.HasValue || numberOfPages.Value == Convert.ToInt32(book.Element(BooksNumberPages).Value))
                              &&
                              (!ubicacion.HasValue || ubicacion.Value == (Lugares)Enum.Parse(typeof(Lugares), book.Element(BooksUbicacion).Value))
                              &&
                              (string.IsNullOrEmpty(isbn) || isbn.Equals(book.Element(BooksISBN).Value))

                        select new Book()
                        {
                            ID = Convert.ToInt32(book.Element(BooksID).Value),
                            Title = book.Element(BooksTitle).Value,
                            NumberOfPages = Convert.ToInt32(book.Element(BooksNumberPages).Value),
                            ISBN = book.Element(BooksISBN).Value,
                            Location = (Lugares)Enum.Parse(typeof(Lugares), book.Element(BooksUbicacion).Value),
                            Description = book.Element(BooksDescription).Value
                        };

            result = query.ToList<Book>();

            return result;
        }