private async void Agregarlesion_Clicked(object sender, EventArgs e) { //creamos la lesion var lesion = new Lesion { clavedeportista = deportistaa.IDDeportista, Lugar = pickerlugar.SelectedItem.ToString(), Tipo = pickertipo.SelectedItem.ToString(), NumLesiones = int.Parse(numeroLesionesEntry.Text), }; //insertamos el deportista en la base de datos using (var datos = new DataAccess()) { datos.InsertLesion(lesion); //listaListView.ItemsSource = datos.GetDeportistas(); } //await DisplayAlert("Confirmación", "Lesion agregada", "Aceptar"); DependencyService.Get <IMessage>().LongAlert("Lesión añadida"); //new NavigationPage(new Trabajo.Paginas.Inicio()); // await Navigation.PushAsync(new Trabajo.LesionesView(deportistaa)); // await Navigation.PopAsync(); // new NavigationPage(new LesionesView(deportistaa)); //await Navigation.PushAsync(new LesionesView(deportistaa)); PopUntilDestination(typeof(LesionesView)); }
public async Task SaveLesionDetails(Lesion lesion, Suggestion suggestion) { await _dbContext.Lesions.AddAsync(lesion); await _dbContext.Suggestions.AddAsync(suggestion); await _dbContext.SaveChangesAsync(); }
public async Task <IActionResult> SaveSuggestion([FromBody] LesionViewModel model) { var userId = _httpContextAccessor.HttpContext.User.GetLoggedInUserId <string>(); Lesion lesion = _mapper.Map <Lesion>(model); lesion.UserId = Guid.Parse(userId); lesion.Id = Guid.NewGuid(); Suggestion suggestion = _mapper.Map <Suggestion>(model); suggestion.Id = Guid.NewGuid(); suggestion.LesionId = lesion.Id; await _lesionService.SaveLesionDetails(lesion, suggestion); return(Ok()); }
public EditLesion(Lesion lesion) { InitializeComponent(); this.lesionn = lesion; this.Padding = Device.OnPlatform( new Thickness(10, 20, 10, 10), new Thickness(10, 10, 10, 10), new Thickness(10, 10, 10, 10)); pickerlugar.Text = lesion.Lugar; pickertipo.Text = lesion.Tipo; numeroLesionesEntry.Text = lesion.NumLesiones.ToString(); actualizarlesion.Clicked += Actualizarlesion_Clicked; borrarlesion.Clicked += Borrarlesion_Clicked; }
//eliminar public void DeleteLesion(Lesion lesion) { connection.Delete(lesion); }
//actualizar public void UpdateLesion(Lesion lesion) { connection.Update(lesion); }
//ENTRENADOR BASE DE DATOS//////////////// /* * //insertar ENTRENADOR * public void InsertEntrenador(Entrenador entrenador) * { * connection.Insert(entrenador); * } * //actualizar * public void UpdateEntrenador(Entrenador entrenador) * { * connection.Update(entrenador); * } * //eliminar * public void DeleteEntrenador(Entrenador entrenador) * { * connection.Delete(entrenador); * } * //obtener deportista * public Entrenador GetEntrenador(int IDEntrenador) * { * return connection.Table<Entrenador>().FirstOrDefault(c => c.IDEntrenador == IDEntrenador); * } * //obtener lista ordenada por apellidos * public List<Entrenador> GetEntrenadores() * { * return connection.Table<Entrenador>().OrderBy(c => c.Apellidos).ToList(); * } */ //insertar LESION public void InsertLesion(Lesion lesion) { connection.Insert(lesion); }