public static OrganizerModel GetOrg(string name) { OrganizerModel om = new OrganizerModel(); string query = $"SELECT * from organizers WHERE Name='{name}' LIMIT 1"; try { using (IDbConnection cnn = new SQLiteConnection(Database.instance.LoadConnectionString())) { var output = cnn.Query <OrganizerModel>($"SELECT * from organizers WHERE Name='{name}' LIMIT 1", new DynamicParameters()); //Console.WriteLine($"GET ORG: {output.ToList()[0]}"); om = output.ToList()[0]; } } catch (Exception e) { Console.WriteLine($"Get Org by Name Exception, {e.Message}"); } return(om); }
public static string AddOrg(string name) { string response = "true"; try { using (IDbConnection cnn = new SQLiteConnection(Database.instance.LoadConnectionString())) { OrganizerModel org = new OrganizerModel(); org.Name = name; cnn.Execute($"insert into organizers (name) values (@Name)", org); Console.WriteLine($"Add Org: {name}"); } } catch (Exception e) { Console.WriteLine($"Insert Org by Name Exception, {e.Message}"); response = e.Message; } return(response); }
public static List <OrganizerModel> NextOrgs(int i) { List <OrganizerModel> organizers = new List <OrganizerModel>(); int b = 0; try { Random rnd = new Random(); organizers = OrganizerModel.GetOrgs(); Console.WriteLine($"COUNTER {i}"); int hk = organizers[4].Hack; for (int k = 5; k < organizers.Count; k++) { if (organizers[k].Hack <= hk) { int op = rnd.Next(0, 5); if (organizers[op].Hack >= organizers[k].Hack) { OrganizerModel tp = organizers[op]; organizers[op] = organizers[k]; organizers[k] = tp; } } } foreach (OrganizerModel ok in organizers) { Console.WriteLine("PURE:" + ok.Name); } if (i < 2) { foreach (OrganizerModel om in organizers) { Console.WriteLine("LOOKING: " + om.Name); if (om.Name.Contains("Bereket Y")) { b = organizers.IndexOf(om); break; } } if (b >= 5 && organizers[b].Hack == 1) { int tk = rnd.Next(0, 5); OrganizerModel tpp = organizers[tk]; organizers[tk] = organizers[b]; organizers[b] = tpp; } } int tkt = rnd.Next(3, 5); int tkk = rnd.Next(0, 3); OrganizerModel tppt = organizers[tkt]; organizers[tkt] = organizers[tkk]; organizers[tkk] = tppt; return(organizers.GetRange(0, 5)); } catch (Exception e) { Console.WriteLine($"Next Orgs Exception {e.Message}"); return(organizers); } }