public int Add(PatientEntity patient) { try { using (var db = new CroceRossaEntities()) { db.Per.Add(patient.ToPer()); db.SaveChanges(); return(0); } } catch (Exception e) { string message = e.Message; return(-1); } }
public int Update(PatientEntity patient) { try { using (var db = new CroceRossaEntities()) { Per per = db.Per.First(x => x.PerOwnId == patient.Id); if (per != null) { per = patient.ToPer(per); db.SaveChanges(); } return(0); } } catch (Exception) { return(-1); } }