public void addMissingPerson() { MissingPersonListContext db = new MissingPersonListContext(); db.MissingPersons.Add(this); db.SaveChanges(); }
private void createUser() { MissingPersonListContext db = new MissingPersonListContext(); UserType = Int32.Parse(ConfigurationManager.AppSettings["NORMAL_USER"]); db.Users.Add(this); db.SaveChanges(); }
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(); }
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(); }