public Reader Get(Expression <Func <Reader, bool> > expression)
 {
     using (IPrompterDbContext context = _dbContextFactory.Create())
     {
         return(context.Readers.Where(expression).FirstOrDefault());
     }
 }
 public IEnumerable <Reader> GetMany(Expression <Func <Reader, bool> > expression)
 {
     using (IPrompterDbContext context = _dbContextFactory.Create())
     {
         return(context.Readers.Where(expression).ToList());
     }
 }
 public IEnumerable <Reader> GetAll()
 {
     using (IPrompterDbContext context = _dbContextFactory.Create())
     {
         return(context.Readers.ToList());
     }
 }
Example #4
0
 public IEnumerable <Preference> GetAll()
 {
     using (IPrompterDbContext context = _dbContextFactory.Create())
     {
         return(context.Preferences.ToList());
     }
 }
 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();
     }
 }
Example #7
0
 public void Post(Preference preference)
 {
     using (IPrompterDbContext context = _dbContextFactory.Create())
     {
         context.Preferences.Add(preference);
         context.SaveChanges();
     }
 }
Example #8
0
 public IList <User> FetchUsers()
 {
     using (IPrompterDbContext context = _dbContextFactory.Create())
     {
         return(context.Users
                .Include(user => user.Role)
                .ToList());
     }
 }
Example #9
0
 public IList <User> FetchAllPrompters()
 {
     using (IPrompterDbContext context = _dbContextFactory.Create())
     {
         return(context.Users
                .Include(user => user.Role)
                .Where(user => !user.Disabled &&
                       user.RoleId == Prompter)
                .ToList());
     }
 }
 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();
     }
 }
Example #11
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();
     }
 }
Example #12
0
 public Preference Get(Expression <Func <Preference, bool> > expression)
 {
     using (IPrompterDbContext context = _dbContextFactory.Create())
     {
         try
         {
             return(context.Preferences.Where(expression).FirstOrDefault());
         }
         catch
         {
             return(null);
         }
     }
 }
Example #13
0
 public IEnumerable <Preference> GetMany(Expression <Func <Preference, bool> > expression)
 {
     using (IPrompterDbContext context = _dbContextFactory.Create())
     {
         try
         {
             return(context.Preferences.Where(expression).ToList());
         }
         catch
         {
             return(null);
         }
     }
 }
Example #14
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();
         }
     }
 }
 public Script FetchScriptById(int scriptId)
 {
     using (IPrompterDbContext context = _dbContextFactory.Create())
     {
         var selectedScript = context.Scripts
                              .Where(script => script.ScriptId == scriptId)
                              .Include(script => script.Options)
                              .Include(script => script.Sections)
                              .FirstOrDefault();
         if (selectedScript != null)
         {
             selectedScript.Sections = selectedScript.Sections
                                       .OrderBy(c => c.Order)
                                       .ToList();
         }
         return(selectedScript);
     }
 }
        public IList <Script> FetchAllScripts()
        {
            using (IPrompterDbContext context = _dbContextFactory.Create())
            {
                var scripts = context.Scripts
                              .Include(script => script.Sections)
                              .Include(script => script.Options)
                              .ToList();

                foreach (var script in scripts)
                {
                    script.Sections = script.Sections
                                      .OrderBy(c => c.Order)
                                      .ToList();
                }

                return(scripts);
            }
        }
Example #17
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);
     }
 }