public bool find_user(string email, string pass)
 {
     using (english_projectEntities db = new english_projectEntities())
     {
         bool user_found = db.users.Any(us => us.email == email && us.pass == pass);
         return(user_found);
     }
 }
Exemple #2
0
 public string get_next_question(int users_id, int?technos_id)
 {
     using (english_projectEntities db = new english_projectEntities())
     {
         if (technos_id == null)
         {
             technos_id = db.get_random_techno(users_id).FirstOrDefault();
         }
         var question = db.get_next_question(users_id, technos_id);
         return(Newtonsoft.Json.JsonConvert.SerializeObject(question));
     }
 }
        //[System.Web.Http.Route("api/users")]
        //[System.Web.Http.HttpGet]
        public string Get()
        {
            IQueryable <users> usuarios;
            List <string>      lista = new List <String>();

            using (english_projectEntities db = new english_projectEntities())
            {
                usuarios = db.users;
                foreach (var item in usuarios)
                {
                    lista.Add($"Usuario: {item.username}, email: {item.email}");
                }
            }
            return(lista[0]);
        }
 public bool delete_techno(int id)
 {
     using (english_projectEntities db = new english_projectEntities())
     {
         technos t = db.technos.Find(id);
         try
         {
             db.technos.Remove(t);
             db.SaveChanges();
         }
         catch
         {
             return(false);
         }
         return(true);
     }
 }
Exemple #5
0
 public bool delete_word(int id)
 {
     using (english_projectEntities db = new english_projectEntities())
     {
         words w = db.words.Find(id);
         try
         {
             db.words.Remove(w);
             db.SaveChanges();
         }
         catch
         {
             return(false);
         }
         return(true);
     }
 }
 public bool add_techno(string techno_name, bool techno_status, int users_id)
 {
     using (english_projectEntities db = new english_projectEntities())
     {
         technos x = db.technos.Add(new technos {
             techno_name = techno_name, techno_status = techno_status, users_id = users_id
         });
         try
         {
             db.SaveChanges();
         }
         catch
         {
             return(false);
         }
         return(true);
     }
 }
Exemple #7
0
 public bool add_word(int users_id, int technos_id, string word, string translation)
 {
     using (english_projectEntities db = new english_projectEntities())
     {
         db.words.Add(new words {
             users_id = users_id, technos_id = technos_id, word = word, translation = translation
         });
         try
         {
             db.SaveChanges();
         }
         catch
         {
             return(false);
         }
         return(true);
     }
 }
Exemple #8
0
 public bool add_test(int users_id, int correct, int total)
 {
     using (english_projectEntities db = new english_projectEntities())
     {
         tests x = db.tests.Add(new tests {
             users_id = users_id, correct = correct, total = total, created_datetime = DateTime.Now
         });
         try
         {
             db.SaveChanges();
         }
         catch
         {
             return(false);
         }
         return(true);
     }
 }
 public bool add_user(string username, string email, string pass)
 {
     using (english_projectEntities db = new english_projectEntities())
     {
         users x = db.users.Add(new users {
             username = username, email = email, pass = pass
         });
         try
         {
             db.SaveChanges();
         }
         catch
         {
             return(false);
         }
         return(true);
     }
 }
 public bool update_techno(int id, string techno_name, bool techno_status, int users_id)
 {
     using (english_projectEntities db = new english_projectEntities())
     {
         technos t = db.technos.Find(id);
         t.techno_name   = techno_name;
         t.techno_status = techno_status;
         t.users_id      = users_id;
         try
         {
             db.SaveChanges();
         }
         catch
         {
             return(false);
         }
         return(true);
     }
 }
Exemple #11
0
 public bool update_word(int id, int technos_id, string word, string translation)
 {
     using (english_projectEntities db = new english_projectEntities())
     {
         words w = db.words.Find(id);
         w.technos_id  = technos_id;
         w.word        = word;
         w.translation = translation;
         try
         {
             db.SaveChanges();
         }
         catch
         {
             return(false);
         }
         return(true);
     }
 }
Exemple #12
0
 public string get_tests(int users_id)
 {
     using (english_projectEntities db = new english_projectEntities())
     {
         List <string> user_tests = new List <string>();
         user_tests = (from ts in db.tests
                       where ts.users_id == users_id
                       orderby ts.id
                       select new testModel
         {
             id = ts.id,
             users_id = ts.users_id,
             correct = ts.correct,
             total = ts.total,
             created_datetime = ts.created_datetime
         }).ToList <testModel>().
                      Select(i => Newtonsoft.Json.JsonConvert.SerializeObject(i)).
                      ToList <string>();
         return(Newtonsoft.Json.JsonConvert.SerializeObject(user_tests));
     }
 }
Exemple #13
0
 public string get_words(int users_id, bool sort_by_word)
 {
     using (english_projectEntities db = new english_projectEntities())
     {
         List <string> ws = new List <string>();
         if (sort_by_word)
         {
             ws = (from w in db.words
                   where w.users_id == users_id
                   orderby w.word
                   select new wordModel {
                 id = w.id,
                 users_id = w.users_id,
                 technos_id = w.technos_id,
                 word = w.word,
                 translation = w.translation
             }).ToList <wordModel>().
                  Select(i => Newtonsoft.Json.JsonConvert.SerializeObject(i)).
                  ToList <string>();
         }
         else
         {
             ws = (from w in db.words
                   where w.users_id == users_id
                   orderby w.id
                   select new wordModel
             {
                 id = w.id,
                 users_id = w.users_id,
                 technos_id = w.technos_id,
                 word = w.word,
                 translation = w.translation
             }).ToList <wordModel>().
                  Select(i => Newtonsoft.Json.JsonConvert.SerializeObject(i)).
                  ToList <string>();
         }
         return(Newtonsoft.Json.JsonConvert.SerializeObject(ws));
     }
 }
 public string get_technos(int users_id, bool sort_by_name)
 {
     using (english_projectEntities db = new english_projectEntities())
     {
         List <string> ts = new List <string>();
         if (sort_by_name)
         {
             ts = (from t in db.technos
                   where t.users_id == users_id
                   orderby t.techno_name
                   select new technoModel
             {
                 id = t.id,
                 users_id = t.users_id,
                 techno_name = t.techno_name,
                 techno_status = t.techno_status
             }).ToList <technoModel>().
                  Select(i => Newtonsoft.Json.JsonConvert.SerializeObject(i)).
                  ToList <string>();
         }
         else
         {
             ts = (from t in db.technos
                   where t.users_id == users_id
                   orderby t.id
                   select new technoModel
             {
                 id = t.id,
                 users_id = t.users_id,
                 techno_name = t.techno_name,
                 techno_status = t.techno_status
             }).ToList <technoModel>().
                  Select(i => Newtonsoft.Json.JsonConvert.SerializeObject(i)).
                  ToList <string>();
         }
         return(Newtonsoft.Json.JsonConvert.SerializeObject(ts));
     }
 }
        public string search_technos(string techno_name, bool?techno_status, int users_id, int search)
        {
            using (english_projectEntities db = new english_projectEntities())
            {
                List <string> ts = new List <string>();
                if (search == 0)
                {
                    ts = (from t in db.technos
                          where t.users_id == users_id &&
                          (techno_name == null || t.techno_name == techno_name) &&
                          (techno_status == null || t.techno_status == techno_status)
                          select new technoModel
                    {
                        id = t.id,
                        users_id = t.users_id,
                        techno_name = t.techno_name,
                        techno_status = t.techno_status
                    }).ToList <technoModel>().
                         Select(i => Newtonsoft.Json.JsonConvert.SerializeObject(i)).
                         ToList <string>();
                }
                else if (search == 1)
                {
                    ts = (from t in db.technos
                          where t.users_id == users_id &&
                          (techno_name == null || t.techno_name.Contains(techno_name)) &&
                          (techno_status == null || t.techno_status == techno_status)
                          select new technoModel
                    {
                        id = t.id,
                        users_id = t.users_id,
                        techno_name = t.techno_name,
                        techno_status = t.techno_status
                    }).ToList <technoModel>().
                         Select(i => Newtonsoft.Json.JsonConvert.SerializeObject(i)).
                         ToList <string>();
                }
                else if (search == 2)
                {
                    ts = (from t in db.technos
                          where t.users_id == users_id &&
                          (techno_name == null || t.techno_name.StartsWith(techno_name)) &&
                          (techno_status == null || t.techno_status == techno_status)
                          select new technoModel
                    {
                        id = t.id,
                        users_id = t.users_id,
                        techno_name = t.techno_name,
                        techno_status = t.techno_status
                    }).ToList <technoModel>().
                         Select(i => Newtonsoft.Json.JsonConvert.SerializeObject(i)).
                         ToList <string>();
                }
                else if (search == 3)
                {
                    ts = (from t in db.technos
                          where t.users_id == users_id &&
                          (techno_name == null || t.techno_name.EndsWith(techno_name)) &&
                          (techno_status == null || t.techno_status == techno_status)
                          select new technoModel
                    {
                        id = t.id,
                        users_id = t.users_id,
                        techno_name = t.techno_name,
                        techno_status = t.techno_status
                    }).ToList <technoModel>().
                         Select(i => Newtonsoft.Json.JsonConvert.SerializeObject(i)).
                         ToList <string>();
                }

                return(Newtonsoft.Json.JsonConvert.SerializeObject(ts));
            }
        }
Exemple #16
0
        public string search_words(int?users_id, int?technos_id, string word, string translation, int search)
        {
            using (english_projectEntities db = new english_projectEntities())
            {
                List <string> ws = new List <string>();
                if (search == 0)
                {
                    ws = (from w in db.words
                          where w.users_id == users_id &&
                          (technos_id == null || w.technos_id == technos_id) &&
                          (word == null || w.word == word) &&
                          (translation == null || w.translation == translation)
                          select new wordModel
                    {
                        id = w.id,
                        users_id = w.users_id,
                        technos_id = w.technos_id,
                        word = w.word,
                        translation = w.translation
                    }).ToList <wordModel>().
                         Select(i => Newtonsoft.Json.JsonConvert.SerializeObject(i)).
                         ToList <string>();
                }
                else if (search == 1)
                {
                    ws = (from w in db.words
                          where w.users_id == users_id &&
                          (technos_id == null || w.technos_id == technos_id) &&
                          (word == null || w.word.Contains(word)) &&
                          (translation == null || w.translation.Contains(translation))
                          select new wordModel
                    {
                        id = w.id,
                        users_id = w.users_id,
                        technos_id = w.technos_id,
                        word = w.word,
                        translation = w.translation
                    }).ToList <wordModel>().
                         Select(i => Newtonsoft.Json.JsonConvert.SerializeObject(i)).
                         ToList <string>();
                }
                else if (search == 2)
                {
                    ws = (from w in db.words
                          where w.users_id == users_id &&
                          (technos_id == null || w.technos_id == technos_id) &&
                          (word == null || w.word.StartsWith(word)) &&
                          (translation == null || w.translation.StartsWith(translation))
                          select new wordModel
                    {
                        id = w.id,
                        users_id = w.users_id,
                        technos_id = w.technos_id,
                        word = w.word,
                        translation = w.translation
                    }).ToList <wordModel>().
                         Select(i => Newtonsoft.Json.JsonConvert.SerializeObject(i)).
                         ToList <string>();
                }
                else if (search == 3)
                {
                    ws = (from w in db.words
                          where w.users_id == users_id &&
                          (technos_id == null || w.technos_id == technos_id) &&
                          (word == null || w.word.EndsWith(word)) &&
                          (translation == null || w.translation.EndsWith(translation))
                          select new wordModel
                    {
                        id = w.id,
                        users_id = w.users_id,
                        technos_id = w.technos_id,
                        word = w.word,
                        translation = w.translation
                    }).ToList <wordModel>().
                         Select(i => Newtonsoft.Json.JsonConvert.SerializeObject(i)).
                         ToList <string>();
                }

                return(Newtonsoft.Json.JsonConvert.SerializeObject(ws));
            }
        }