public async Task <IHttpActionResult> PostClaseAlumno(ClaseAlumno claseAlumno) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.ClasesAlumnos.Add(claseAlumno); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (ClaseAlumnoExists(claseAlumno.AlumnoId)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = claseAlumno.AlumnoId }, claseAlumno)); }
public async Task <IHttpActionResult> PutClaseAlumno(int id, ClaseAlumno claseAlumno) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != claseAlumno.AlumnoId) { return(BadRequest()); } db.Entry(claseAlumno).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ClaseAlumnoExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void jsonTest(int id, string nombre, string apellidos, string dni, Guid guid) { ClaseAlumno alumno1 = new ClaseAlumno(id, nombre, apellidos, dni, guid); Assert.IsTrue(guid == alumno1.GUID); Assert.IsTrue(id == alumno1.ID); Assert.IsTrue(nombre == alumno1.NOMBRE); Assert.IsTrue(apellidos == alumno1.APELLIDOS); Assert.IsTrue(dni == alumno1.DNI); }
public async Task <IHttpActionResult> GetClaseAlumno(int id) { ClaseAlumno claseAlumno = await db.ClasesAlumnos.FindAsync(id); if (claseAlumno == null) { return(NotFound()); } return(Ok(claseAlumno)); }
public async Task <IHttpActionResult> DeleteClaseAlumno(int id) { ClaseAlumno claseAlumno = await db.ClasesAlumnos.FindAsync(id); if (claseAlumno == null) { return(NotFound()); } db.ClasesAlumnos.Remove(claseAlumno); await db.SaveChangesAsync(); return(Ok(claseAlumno)); }
public async void Execute(object control) { if (control.Equals("Nuevo")) { LimpiarCampos(); ActivarControles(); this._accion = ACCION.NUEVO; } else if (control.Equals("Eliminar")) { if (Elemento != null) { MessageDialogResult resultado = await this._dialogCoordinator.ShowMessageAsync( this, "Eliminar ClaseAlumno", "Esta seguro de eliminar el registro?", MessageDialogStyle.AffirmativeAndNegative); if (resultado == MessageDialogResult.Affirmative) { try { _db.ClasesAlumnos.Remove(Elemento); _db.SaveChanges(); this.ListaClasesAlumnos.Remove(Elemento); LimpiarCampos(); } catch (Exception ex) { await this._dialogCoordinator.ShowMessageAsync( this, "Eliminar ClaseAlumno", ex.Message); } } } else { await this._dialogCoordinator.ShowMessageAsync( this, "Eliminar ClaseAlumno", "Debe seleccionar un elemento"); } } else if (control.Equals("Guardar")) { switch (this._accion) { case ACCION.NINGUNO: break; case ACCION.NUEVO: try { var registro = new ClaseAlumno { Alumno = this.AlumnoSeleccionado, Clase = this.ClaseSeleccionada, FechaAsignacion = this.FechaAsignacion }; _db.ClasesAlumnos.Add(registro); _db.SaveChanges(); this.ListaClasesAlumnos.Add(registro); } catch (Exception ex) { await this._dialogCoordinator.ShowMessageAsync( this, "Guardar ClasesAlumnos", ex.Message); } finally { DesactivarControles(); this._accion = ACCION.NINGUNO; } break; case ACCION.GUARDAR: try { int posicion = ListaClasesAlumnos.IndexOf(Elemento); var registro = _db.ClasesAlumnos.Find(Elemento.AlumnoId); if (registro != null) { registro.Alumno = this.AlumnoSeleccionado; registro.Clase = this.ClaseSeleccionada; registro.FechaAsignacion = this.FechaAsignacion; _db.Entry(registro).State = EntityState.Modified; _db.SaveChanges(); ListaClasesAlumnos.RemoveAt(posicion); ListaClasesAlumnos.Insert(posicion, registro); } } catch (Exception ex) { await this._dialogCoordinator.ShowMessageAsync( this, "Editar ClaseAlumno", ex.Message); } finally { DesactivarControles(); this._accion = ACCION.NINGUNO; } break; default: break; } } else if (control.Equals("Editar")) { if (Elemento != null) { ActivarControles(); this._accion = ACCION.GUARDAR; } else { await this._dialogCoordinator.ShowMessageAsync( this, "Editar ClaseAlumno", "Debe seleccionar un elemento"); } } else if (control.Equals("Cancelar")) { DesactivarControles(); this._accion = ACCION.NINGUNO; } }