private void CreateTheDatesAndTheRatesAtDigit(BrainGameDBEntities3 context) { for (int i = 1; i <= numberOfDigits; i++) // 4 signs >> + , - , x , / { var selectDirect = from results in context.Results where results.UserId == this.userId select new { FirstNumber = results.FirstNumber, SecondNumber = results.SecondNumber, Date = results.Date }; var selected = from results in selectDirect.AsEnumerable() where NumberOfDigitsEqualsWith(Math.Max((int)results.FirstNumber, (int)results.SecondNumber), i) select results.Date; List <DateTime> currentDateTimeList = selected.ToList(); currentDateTimeList = currentDateTimeList.Distinct().ToList(); currentDateTimeList = currentDateTimeList.OrderBy(x => x.Date).ToList(); List <int> currentRateList = new List <int>(); foreach (DateTime currentDay in currentDateTimeList) { var selectedTwoDirect = from results in context.Results where results.Date == currentDay where results.UserId == this.userId select new { FirstNumber = results.FirstNumber, SecondNumber = results.SecondNumber, Succeeded = results.Succeeded }; var selectedTwo = from results in selectedTwoDirect.AsEnumerable() where NumberOfDigitsEqualsWith(Math.Max((int)results.FirstNumber, (int)results.SecondNumber), i) select results.Succeeded; List <bool> currentBoolList = new List <bool>(); foreach (bool currentBool in selectedTwo) { currentBoolList.Add(currentBool); } int currentRate = GetTheRate(currentBoolList); currentRateList.Add(currentRate); } DailyRate currentDailyRateDigit = new DailyRate(); currentDailyRateDigit.Dates = currentDateTimeList; currentDailyRateDigit.Rates = currentRateList; this.DailyRateDigit.Add(currentDailyRateDigit); } }
private void CreateTheDatesAndTheRatesAtOperator(BrainGameDBEntities3 context) { for (int i = 1; i <= 4; i++) // 4 signs >> + , - , x , / { var selected = from results in context.Results where results.Operation == i where results.UserId == this.userId select results.Date; List <DateTime> currentDateTimeList = selected.ToList(); currentDateTimeList = currentDateTimeList.Distinct().ToList(); currentDateTimeList = currentDateTimeList.OrderBy(x => x.Date).ToList(); List <int> currentRateList = new List <int>(); foreach (DateTime currentDay in currentDateTimeList) { var selectedTwo = from results in context.Results where results.Operation == i where results.Date == currentDay where results.UserId == this.userId select results.Succeeded; List <bool> currentBoolList = new List <bool>(); foreach (bool currentBool in selectedTwo) { currentBoolList.Add(currentBool); } int currentRate = GetTheRate(currentBoolList); currentRateList.Add(currentRate); } DailyRate currentDailyRateOperator = new DailyRate(); currentDailyRateOperator.Dates = currentDateTimeList; currentDailyRateOperator.Rates = currentRateList; this.DailyRateOperator.Add(currentDailyRateOperator); } }
private void CreateTheDatesAndTheRatesAtOperator(BrainGameDBEntities3 context) { for (int i = 1; i <= 4; i++) // 4 signs >> + , - , x , / { var selected = from results in context.Results where results.Operation == i where results.UserId == this.userId select results.Date; List<DateTime> currentDateTimeList = selected.ToList(); currentDateTimeList = currentDateTimeList.Distinct().ToList(); currentDateTimeList = currentDateTimeList.OrderBy(x => x.Date).ToList(); List<int> currentRateList = new List<int>(); foreach (DateTime currentDay in currentDateTimeList) { var selectedTwo = from results in context.Results where results.Operation == i where results.Date == currentDay where results.UserId == this.userId select results.Succeeded; List<bool> currentBoolList = new List<bool>(); foreach (bool currentBool in selectedTwo) { currentBoolList.Add(currentBool); } int currentRate = GetTheRate(currentBoolList); currentRateList.Add(currentRate); } DailyRate currentDailyRateOperator = new DailyRate(); currentDailyRateOperator.Dates = currentDateTimeList; currentDailyRateOperator.Rates = currentRateList; this.DailyRateOperator.Add(currentDailyRateOperator); } }
private void CreateTheDatesAndTheRatesAtDigit(BrainGameDBEntities3 context) { for (int i = 1; i <= numberOfDigits; i++) // 4 signs >> + , - , x , / { var selectDirect = from results in context.Results where results.UserId == this.userId select new { FirstNumber = results.FirstNumber, SecondNumber = results.SecondNumber, Date = results.Date }; var selected = from results in selectDirect.AsEnumerable() where NumberOfDigitsEqualsWith(Math.Max((int)results.FirstNumber, (int)results.SecondNumber), i) select results.Date; List<DateTime> currentDateTimeList = selected.ToList(); currentDateTimeList = currentDateTimeList.Distinct().ToList(); currentDateTimeList = currentDateTimeList.OrderBy(x => x.Date).ToList(); List<int> currentRateList = new List<int>(); foreach (DateTime currentDay in currentDateTimeList) { var selectedTwoDirect = from results in context.Results where results.Date == currentDay where results.UserId == this.userId select new { FirstNumber = results.FirstNumber, SecondNumber = results.SecondNumber, Succeeded = results.Succeeded }; var selectedTwo = from results in selectedTwoDirect.AsEnumerable() where NumberOfDigitsEqualsWith(Math.Max((int)results.FirstNumber, (int)results.SecondNumber), i) select results.Succeeded; List<bool> currentBoolList = new List<bool>(); foreach (bool currentBool in selectedTwo) { currentBoolList.Add(currentBool); } int currentRate = GetTheRate(currentBoolList); currentRateList.Add(currentRate); } DailyRate currentDailyRateDigit = new DailyRate(); currentDailyRateDigit.Dates = currentDateTimeList; currentDailyRateDigit.Rates = currentRateList; this.DailyRateDigit.Add(currentDailyRateDigit); } }