Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public examination get(Guid?id)
        {
            if (id == null)
            {
                id = Guid.Empty;
            }
            examination acc = _context.examinations.FirstOrDefault(o => o.id == (id));

            return(acc);
        }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
 public examination add(examination acc)
 {
     try
     {
         _context.examinations.Add(acc);
         _context.SaveChanges();
     }
     catch (Exception e)
     {
         Logger.Log(e.ToString(), LogType.Error);
     }
     return(acc);
 }