public examination edit(examination acc) { try { var entry = _context.Entry <examination>(acc); if (entry.State == System.Data.Entity.EntityState.Detached) { var set = _context.Set <examination>(); examination attachedEntity = set.Local.SingleOrDefault(e => e.id == acc.id); // You need to have access to key if (attachedEntity != null) { var attachedEntry = _context.Entry(attachedEntity); attachedEntry.CurrentValues.SetValues(acc); } else { entry.State = System.Data.Entity.EntityState.Modified; // This should attach entity } } } catch (Exception e) { Logger.Log(e.ToString(), LogType.Error); } return(acc); }
public examination get(Guid?id) { if (id == null) { id = Guid.Empty; } examination acc = _context.examinations.FirstOrDefault(o => o.id == (id)); return(acc); }
public examination delete(examination acc) { try { _context.Entry(acc).State = System.Data.Entity.EntityState.Deleted; _context.SaveChanges(); } catch (Exception e) { Logger.Log(e.ToString(), LogType.Error); } return(acc); }
public examination add(examination acc) { try { _context.examinations.Add(acc); _context.SaveChanges(); } catch (Exception e) { Logger.Log(e.ToString(), LogType.Error); } return(acc); }