public void Post(Preference preference) { using (IPrompterDbContext context = _dbContextFactory.Create()) { context.Preferences.Add(preference); context.SaveChanges(); } }
public void Put(Reader reader) { using (IPrompterDbContext context = _dbContextFactory.Create()) { context.Entry(reader).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
public void Post(Reader reader) { using (IPrompterDbContext context = _dbContextFactory.Create()) { context.Readers.Add(reader); context.SaveChanges(); } }
public void Delete(IEnumerable <int> ids) { using (IPrompterDbContext context = _dbContextFactory.Create()) { foreach (var id in ids) { context.Readers.Remove(context.Readers.Where(read => read.Id == id).FirstOrDefault()); } context.SaveChanges(); } }
public void Delete(Expression <Func <Preference, bool> > expression) { using (IPrompterDbContext context = _dbContextFactory.Create()) { IEnumerable <Preference> delList = context.Preferences.Where(expression).ToList(); foreach (var Preference in delList) { context.Preferences.Remove(Preference); } context.SaveChanges(); } }
public void Put(Preference preference) { using (IPrompterDbContext context = _dbContextFactory.Create()) { preference.Id = 0; Preference pref = this.Get(temp => preference.ReaderId == temp.ReaderId && preference.ScriptId == temp.ScriptId); if (pref == null) { this.Post(preference); } else { preference.Id = pref.Id; context.Entry(preference).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } } }
public void ChangePrompterStatus(int id, string status) { using (IPrompterDbContext context = _dbContextFactory.Create()) { User prompter = context.Users .Include(user => user.Role) .FirstOrDefault(user => user.UserId == id && !user.Disabled && user.RoleId == Prompter); if (prompter == null) { //throw new ArgumentNullException(Prompter.ToString()); return; } prompter.PrompterStatus = status; prompter.EntityState = EntityState.Modified; context.Attach(prompter); context.SaveChanges(); _events.RaiseOnPrompterChange(this); } }