/// <summary> /// this function get all clue for password /// </summary> /// <param name="x">password lenght</param> /// <param name="record">password</param> /// <returns>list of clue for password</returns> private List <string> SubClueList(int x, string record) { var subcluelist = new List <string>(); if (x == 3) { using (KrzyzowkiTabele.MyContext context = new KrzyzowkiTabele.MyContext()) { var query = from st in context.Hasla3s where st.haslo == record select st; foreach (var record1 in query) { subcluelist.Add(record1.podpowiedz); } return(subcluelist); } } if (x == 4) { using (KrzyzowkiTabele.MyContext context = new KrzyzowkiTabele.MyContext()) { var query = from st in context.Hasla4s where st.haslo == record select st; foreach (var record1 in query) { subcluelist.Add(record1.podpowiedz); } return(subcluelist); } } if (x == 5) { using (KrzyzowkiTabele.MyContext context = new KrzyzowkiTabele.MyContext()) { var query = from st in context.Hasla5s where st.haslo == record select st; foreach (var record1 in query) { subcluelist.Add(record1.podpowiedz); } return(subcluelist); } } if (x == 6) { using (KrzyzowkiTabele.MyContext context = new KrzyzowkiTabele.MyContext()) { var query = from st in context.Hasla6s where st.haslo == record select st; foreach (var record1 in query) { subcluelist.Add(record1.podpowiedz); } return(subcluelist); } } if (x == 7) { using (KrzyzowkiTabele.MyContext context = new KrzyzowkiTabele.MyContext()) { var query = from st in context.Hasla7s where st.haslo == record select st; foreach (var record1 in query) { subcluelist.Add(record1.podpowiedz); } return(subcluelist); } } if (x == 8) { using (KrzyzowkiTabele.MyContext context = new KrzyzowkiTabele.MyContext()) { var query = from st in context.Hasla8s where st.haslo == record select st; foreach (var record1 in query) { subcluelist.Add(record1.podpowiedz); } return(subcluelist); } } if (x == 9) { using (KrzyzowkiTabele.MyContext context = new KrzyzowkiTabele.MyContext()) { var query = from st in context.Hasla9s where st.haslo == record select st; foreach (var record1 in query) { subcluelist.Add(record1.podpowiedz); } return(subcluelist); } } if (x == 10) { using (KrzyzowkiTabele.MyContext context = new KrzyzowkiTabele.MyContext()) { var query = from st in context.Hasla10s where st.haslo == record select st; foreach (var record1 in query) { subcluelist.Add(record1.podpowiedz); } return(subcluelist); } } if (x == 11) { using (KrzyzowkiTabele.MyContext context = new KrzyzowkiTabele.MyContext()) { var query = from st in context.Hasla11s where st.haslo == record select st; foreach (var record1 in query) { subcluelist.Add(record1.podpowiedz); } return(subcluelist); } } if (x == 12) { using (KrzyzowkiTabele.MyContext context = new KrzyzowkiTabele.MyContext()) { var query = from st in context.Hasla12s where st.haslo == record select st; foreach (var record1 in query) { subcluelist.Add(record1.podpowiedz); } return(subcluelist); } } if (x == 13) { using (KrzyzowkiTabele.MyContext context = new KrzyzowkiTabele.MyContext()) { var query = from st in context.Hasla13s where st.haslo == record select st; foreach (var record1 in query) { subcluelist.Add(record1.podpowiedz); } return(subcluelist); } } if (x == 14) { using (KrzyzowkiTabele.MyContext context = new KrzyzowkiTabele.MyContext()) { var query = from st in context.Hasla14s where st.haslo == record select st; foreach (var record1 in query) { subcluelist.Add(record1.podpowiedz); } return(subcluelist); } } if (x == 15) { using (KrzyzowkiTabele.MyContext context = new KrzyzowkiTabele.MyContext()) { var query = from st in context.Hasla15s where st.haslo == record select st; foreach (var record1 in query) { subcluelist.Add(record1.podpowiedz); } return(subcluelist); } } if (x == 1) { subcluelist.Add("Across"); return(subcluelist); } if (x == 2) { subcluelist.Add("Down"); return(subcluelist); } return(subcluelist); }
/// <summary> /// this function get password that can be placed on board /// </summary> /// <param name="x">lenght</param> /// <param name="slowo">letters which password must contain</param> /// <returns>one password which met requirements if no password is found then return empty string</returns> string GetPassword(int x, string slowo) { if (x == 3) { Random rand = new Random(); using (KrzyzowkiTabele.MyContext context = new KrzyzowkiTabele.MyContext()) { var a = (from st in context.Hasla3Distincts orderby st.ID where DbFunctions.Like(st.haslo, slowo) select st); if (a.Count() == 0) { return(""); } int toSkip = rand.Next(0, a.Count()); var b = a.Skip(toSkip).Take(1).First(); return(b.haslo); } } if (x == 4) { Random rand = new Random(); using (KrzyzowkiTabele.MyContext context = new KrzyzowkiTabele.MyContext()) { var a = (from st in context.Hasla4Distincts orderby st.ID where DbFunctions.Like(st.haslo, slowo) select st); if (a.Count() == 0) { return(""); } int toSkip = rand.Next(0, a.Count()); var b = a.Skip(toSkip).Take(1).First(); return(b.haslo); } } if (x == 5) { Random rand = new Random(); using (KrzyzowkiTabele.MyContext context = new KrzyzowkiTabele.MyContext()) { var a = (from st in context.Hasla5Distincts orderby st.ID where DbFunctions.Like(st.haslo, slowo) select st); if (a.Count() == 0) { return(""); } int toSkip = rand.Next(0, a.Count()); var b = a.Skip(toSkip).Take(1).First(); return(b.haslo); } } if (x == 6) { Random rand = new Random(); using (KrzyzowkiTabele.MyContext context = new KrzyzowkiTabele.MyContext()) { var a = (from st in context.Hasla6Distincts orderby st.ID where DbFunctions.Like(st.haslo, slowo) select st); if (a.Count() == 0) { return(""); } int toSkip = rand.Next(0, a.Count()); var b = a.Skip(toSkip).Take(1).First(); return(b.haslo); } } if (x == 7) { Random rand = new Random(); using (KrzyzowkiTabele.MyContext context = new KrzyzowkiTabele.MyContext()) { var a = (from st in context.Hasla7Distincts orderby st.ID where DbFunctions.Like(st.haslo, slowo) select st); if (a.Count() == 0) { return(""); } int toSkip = rand.Next(0, a.Count()); var b = a.Skip(toSkip).Take(1).First(); return(b.haslo); } } if (x == 8) { Random rand = new Random(); using (KrzyzowkiTabele.MyContext context = new KrzyzowkiTabele.MyContext()) { var a = (from st in context.Hasla8Distincts orderby st.ID where DbFunctions.Like(st.haslo, slowo) select st); if (a.Count() == 0) { return(""); } int toSkip = rand.Next(0, a.Count()); var b = a.Skip(toSkip).Take(1).First(); return(b.haslo); } } if (x == 9) { Random rand = new Random(); using (KrzyzowkiTabele.MyContext context = new KrzyzowkiTabele.MyContext()) { var a = (from st in context.Hasla9Distincts orderby st.ID where DbFunctions.Like(st.haslo, slowo) select st); if (a.Count() == 0) { return(""); } int toSkip = rand.Next(0, a.Count()); var b = a.Skip(toSkip).Take(1).First(); return(b.haslo); } } if (x == 10) { Random rand = new Random(); using (KrzyzowkiTabele.MyContext context = new KrzyzowkiTabele.MyContext()) { var a = (from st in context.Hasla10Distincts orderby st.ID where DbFunctions.Like(st.haslo, slowo) select st); if (a.Count() == 0) { return(""); } int toSkip = rand.Next(0, a.Count()); var b = a.Skip(toSkip).Take(1).First(); return(b.haslo); } } if (x == 11) { Random rand = new Random(); using (KrzyzowkiTabele.MyContext context = new KrzyzowkiTabele.MyContext()) { var a = (from st in context.Hasla11Distincts orderby st.ID where DbFunctions.Like(st.haslo, slowo) select st); if (a.Count() == 0) { return(""); } int toSkip = rand.Next(0, a.Count()); var b = a.Skip(toSkip).Take(1).First(); return(b.haslo); } } if (x == 12) { Random rand = new Random(); using (KrzyzowkiTabele.MyContext context = new KrzyzowkiTabele.MyContext()) { var a = (from st in context.Hasla12Distincts orderby st.ID where DbFunctions.Like(st.haslo, slowo) select st); if (a.Count() == 0) { return(""); } int toSkip = rand.Next(0, a.Count()); var b = a.Skip(toSkip).Take(1).First(); return(b.haslo); } } if (x == 13) { Random rand = new Random(); using (KrzyzowkiTabele.MyContext context = new KrzyzowkiTabele.MyContext()) { var a = (from st in context.Hasla13Distincts orderby st.ID where DbFunctions.Like(st.haslo, slowo) select st); if (a.Count() == 0) { return(""); } int toSkip = rand.Next(0, a.Count()); var b = a.Skip(toSkip).Take(1).First(); return(b.haslo); } } if (x == 14) { Random rand = new Random(); using (KrzyzowkiTabele.MyContext context = new KrzyzowkiTabele.MyContext()) { var a = (from st in context.Hasla14Distincts orderby st.ID where DbFunctions.Like(st.haslo, slowo) select st); if (a.Count() == 0) { return(""); } int toSkip = rand.Next(0, a.Count()); var b = a.Skip(toSkip).Take(1).First(); return(b.haslo); } } if (x == 15) { Random rand = new Random(); using (KrzyzowkiTabele.MyContext context = new KrzyzowkiTabele.MyContext()) { var a = (from st in context.Hasla15Distincts orderby st.ID where DbFunctions.Like(st.haslo, slowo) select st); if (a.Count() == 0) { return(""); } int toSkip = rand.Next(0, a.Count()); var b = a.Skip(toSkip).Take(1).First(); return(b.haslo); } } return(""); }