Пример #1
0
 public List<Key> GetKeys()
 {
     using (GoKeyboardDbContext context = new GoKeyboardDbContext())
     {
         return context.Keys.ToList();
     }
 }
Пример #2
0
 public List<Lesson> GetLessons(int chapterId)
 {
     using (GoKeyboardDbContext context = new GoKeyboardDbContext())
     {
         return context.Lessons/*.Include("Chapter")*/.Where(l => l.Chapter.Id == chapterId).ToList();
     }
 }
Пример #3
0
 public User GetUserByEmail(string email)
 {
     using (GoKeyboardDbContext context = new GoKeyboardDbContext())
     {
         User userFromDb = context.Users.Where(u => u.Email == email).FirstOrDefault();
         return userFromDb;
     }
 }
Пример #4
0
 public Lesson Retrieve(int id)
 {
     using (GoKeyboardDbContext context = new GoKeyboardDbContext())
     {
         Lesson lessonFromDb = context.Lessons.Include(c => c.WorkedChars).Include(c => c.KnownChars).FirstOrDefault(u => u.LessonId == id);
         return lessonFromDb;
     }
 }
Пример #5
0
 public List<Chapter> GetChapters()
 {
     using (GoKeyboardDbContext context = new GoKeyboardDbContext())
     {
         Log.Info("LessonDal", context.ObjectContext.Connection.ConnectionString);
         return context.Chapters.ToList();
     }
 }
Пример #6
0
        public User Retrieve(int id)
        {
            using (GoKeyboardDbContext context = new GoKeyboardDbContext())
            {
                User UserFromDb = context.Users.Where(u => u.Id == id).FirstOrDefault();

                return UserFromDb;
            }
        }
Пример #7
0
 public User Create(User inputObject)
 {
     using (GoKeyboardDbContext context = new GoKeyboardDbContext())
     {
         context.Users.Add(inputObject);
         context.SaveChanges();
         return inputObject;
     }
 }
Пример #8
0
        public User Update(User inputObject)
        {
            using (GoKeyboardDbContext context = new GoKeyboardDbContext())
            {
                context.Users.Attach(inputObject);
                context.Entry(inputObject).State = EntityState.Modified;

                    context.SaveChanges();
                    return inputObject;
            }
        }
Пример #9
0
 public void Delete(int id)
 {
     using (GoKeyboardDbContext context = new GoKeyboardDbContext())
     {
         User UserFromDb = context.Users.Where(u => u.Id == id).FirstOrDefault();
         if (UserFromDb == null)
             throw new KeyboardDalException("Utilisateur introuvable en base de données");
         context.Users.Remove(UserFromDb);
         context.SaveChanges();
     }
 }