public AlumnoEntity Add(AlumnoEntity alumnoEntity) { AlumnoEntity alumnoEntityAdded; // Aqui se haria el automapper para pasar a objeto try { Alumno alumnoDM = new Alumno(alumnoEntity.Nombre, alumnoEntity.Apellidos, alumnoEntity.Dni, alumnoEntity.FechaNacimiento, alumnoEntity.Edad); db.Alumno.Add(alumnoDM); db.SaveChanges(); alumnoEntityAdded = MapperInfrastructureAlumno.AlumnoDataModelToAlumnoEntity(alumnoDM); } catch (DbUpdateConcurrencyException ex) { // YOU MUST LOG - Habria que hacer un log throw new VuelingExceptions(ResourceMessage.DbUpdateConcurrencyException, ex); } catch (DbUpdateException ex) { // YOU MUST LOG - Habria que hacer un log throw new VuelingExceptions(ResourceMessage.DbUpdateException, ex); } catch (DbEntityValidationException ex) { // YOU MUST LOG - Habria que hacer un log throw new VuelingExceptions(ResourceMessage.DbEntityValidationException, ex); } catch (NotSupportedException ex) { // YOU MUST LOG - Habria que hacer un log throw new VuelingExceptions(ResourceMessage.NotSupportedException, ex); } catch (ObjectDisposedException ex) { // YOU MUST LOG - Habria que hacer un log throw new VuelingExceptions(ResourceMessage.ObjectDisposedException, ex); } catch (InvalidOperationException ex) { // YOU MUST LOG - Habria que hacer un log throw new VuelingExceptions(ResourceMessage.InvalidOperationException, ex); } return(alumnoEntityAdded); }
public AlumnoEntity GetById(int id) { return(MapperInfrastructureAlumno.AlumnoDataModelToAlumnoEntity(db.Alumno.Find(id))); }
public List <AlumnoEntity> GetAll() { List <Alumno> listaAlumnos = db.Alumno.ToList(); return(MapperInfrastructureAlumno.AlumnoDataModelToAlumnoEntity(listaAlumnos)); }