Пример #1
0
        public void addMissingPerson()
        {
            MissingPersonListContext db = new MissingPersonListContext();

            db.MissingPersons.Add(this);
            db.SaveChanges();
        }
Пример #2
0
        private void createUser()
        {
            MissingPersonListContext db = new MissingPersonListContext();

            UserType = Int32.Parse(ConfigurationManager.AppSettings["NORMAL_USER"]);

            db.Users.Add(this);
            db.SaveChanges();
        }
Пример #3
0
        public static void changeUserActiveStatus(int userId)
        {
            MissingPersonListContext db = new MissingPersonListContext();
            User   user   = db.Users.Single(u => u.Id == userId);
            String active = user.Active == true ? "0" : "1";
            String query  = "Update Users SET active = " + active + " WHERE Id = " + user.Id.ToString();

            db.Database.ExecuteSqlCommand(query);
            db.SaveChanges();
        }
Пример #4
0
        public static void changeUserType(int userId)
        {
            MissingPersonListContext db = new MissingPersonListContext();
            User   user  = db.Users.Single(u => u.Id == userId);
            int    type  = user.UserType == Int32.Parse(ConfigurationManager.AppSettings["ADMIN_USER"]) ? Int32.Parse(ConfigurationManager.AppSettings["NORMAL_USER"]) : Int32.Parse(ConfigurationManager.AppSettings["ADMIN_USER"]);
            String query = "Update Users SET UserType = " + type + " WHERE Id = " + user.Id.ToString();

            Debug.WriteLine(query);
            db.Database.ExecuteSqlCommand(query);
            db.SaveChanges();
        }