コード例 #1
0
 public void Post(Preference preference)
 {
     using (IPrompterDbContext context = _dbContextFactory.Create())
     {
         context.Preferences.Add(preference);
         context.SaveChanges();
     }
 }
コード例 #2
0
 public void Put(Reader reader)
 {
     using (IPrompterDbContext context = _dbContextFactory.Create())
     {
         context.Entry(reader).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
コード例 #3
0
 public void Post(Reader reader)
 {
     using (IPrompterDbContext context = _dbContextFactory.Create())
     {
         context.Readers.Add(reader);
         context.SaveChanges();
     }
 }
コード例 #4
0
 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();
     }
 }
コード例 #5
0
 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();
     }
 }
コード例 #6
0
 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();
         }
     }
 }
コード例 #7
0
 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);
     }
 }