Esempio n. 1
0
 public Milestone CreateOrUpdate(Milestone entity)
 {
     try
     {
         _context.Entry(entity).State = entity.Id == 0 ? EntityState.Added:  EntityState.Modified;
         _context.SaveChanges();
         return(entity);
     }
     catch (Exception ex)
     {
         throw new Exception("Failed.");
     }
 }
Esempio n. 2
0
 public bool Update(T entity, bool autoSave = true)
 {
     _dbContext.Attach(entity);
     _dbContext.Entry(entity).State = EntityState.Modified;
     if (autoSave)
     {
         return(Save());
     }
     else
     {
         return(false);
     }
 }