public ActionResult ByDate(int seasonId, int?bettingType, int?moneyType) { List <ByDate> model = new List <ByDate>(); SeasonBets tempModel = new SeasonBets(); List <DateTime> betDates = new List <DateTime>(); tempModel.VersionThree((AppStatic.Seasons)seasonId, AppStatic.BettingSetup.MoneyLine); betDates = tempModel.Bets.SelectMany(b => b.BetGames).GroupBy(g => g.GameDate).OrderBy(g => g.Key).Select(g => g.Key).ToList(); foreach (DateTime gameDate in betDates) { ByDate day = new ByDate(); day.Date = gameDate; day.ACount = tempModel.Bets.Where(b => b.WinA && b.BetADate <= gameDate).Count(); day.BCount = tempModel.Bets.Where(b => b.WinB && b.BetBDate <= gameDate).Count(); day.CCount = tempModel.Bets.Where(b => b.WinC && b.BetCDate <= gameDate).Count(); day.DCount = tempModel.Bets.Where(b => b.WinD && b.BetDDate <= gameDate).Count(); day.Loss = tempModel.Bets.Where(b => b.Loss && b.LossDate <= gameDate).Count(); //day.TotalBets = tempModel.Bets.Where(b => b.Loss && b.BetDDate <= gameDate).Count(); model.Add(day); } return(View("~/Views/Sports/NBA/ByDate.cshtml", model)); }
public string ToPrettyString() { return("DepartmentParticipation {" + ($"\n{nameof(ByDate)}: {ByDate.ToPrettyString()}," + $"\n{nameof(ByCategory)}: {ByCategory.ToPrettyString()}").Indent(4) + "\n}"); }
private async Task TestByDate(ActionModel model, string expectedResponse) { ByDate city = new ByDate(model, new RegexService()); string result = await city.GetSubFolder(new FolderFormatters()); //Asserts Assert.AreEqual(expectedResponse, result); }
public async Task <ActionResult <IEnumerable <Transaction> > > searchData(ByDate data) { var query = from wo in _context.Transactions select wo; if (data.startDate != null && data.endDate != null) { var startDate = DateTime.ParseExact(data.startDate, "dd-MM-yyyy", null); var endDate = DateTime.ParseExact(data.endDate, "dd-MM-yyyy", null); query = query.Where(q => q.TransDate >= startDate && q.TransDate <= endDate); } query = query.OrderByDescending(q => q.TransDate); var transaction = await query.ToListAsync <Transaction>(); if (transaction == null) { return(NotFound()); } else { return(transaction); } }
protected void Page_Load(object sender, EventArgs e) { SqlConnection vid = new SqlConnection("Data Source=(local);Initial Catalog=Ring;Integrated Security=True"); SqlCommand info = new SqlCommand("SELECT firstname, lastname, email FROM dbo.Customers WHERE email = @email", vid); info.Parameters.AddWithValue("@email", Session["username"]); vid.Open(); SqlDataReader pinfo = info.ExecuteReader(); pinfo.Read(); Label txtLabel1 = new Label(); txtLabel1.Text = (string)pinfo[0]; txtLabel1.Style.Add("Color", "Black"); firstn.Controls.Add(txtLabel1); Label txtLabel2 = new Label(); txtLabel2.Text = (string)pinfo[1]; txtLabel2.Style.Add("Color", "Black"); lastn.Controls.Add(txtLabel2); Label txtLabel3 = new Label(); txtLabel3.Text = (string)pinfo[2]; txtLabel3.Style.Add("Color", "Black"); lblusername.Text = (string)pinfo[2]; vid.Close(); if (!IsPostBack) { ByPrice.AppendDataBoundItems = true; ByDate.AppendDataBoundItems = true; ByJewel.AppendDataBoundItems = true; ByPrice1.AppendDataBoundItems = true; String strRingConnectionString = ConfigurationManager.ConnectionStrings["RingConnectionString"].ConnectionString; String strQuery = "Select jewel_ID, month, year, price FROM dbo.Orders WHERE email = @email ORDER BY price DESC"; SqlConnection con = new SqlConnection(strRingConnectionString); SqlCommand cmd = new SqlCommand(); cmd.Parameters.AddWithValue("@email", lblusername.Text); cmd.CommandType = CommandType.Text; cmd.CommandText = strQuery; cmd.Connection = con; //ByDate.AppendDataBoundItems = true; //ByPrice.AppendDataBoundItems = true; //String strQuery2 = "Select jewel_ID, month, year, price FROM dbo.Orders WHERE email = @email ORDER BY price DESC"; //SqlCommand cmd2 = new SqlCommand(); //cmd2.Parameters.AddWithValue("@email", lblusername.Text); //cmd2.CommandType = CommandType.Text; //cmd2.CommandText = strQuery2; //cmd2.Connection = con; try { con.Open(); ByPrice.DataSource = cmd.ExecuteReader(); ByPrice.DataTextField = "month"; ByPrice.DataBind(); con.Close(); con.Open(); ByDate.DataSource = cmd.ExecuteReader(); ByDate.DataTextField = "year"; ByDate.DataBind(); con.Close(); con.Open(); ByJewel.DataSource = cmd.ExecuteReader(); ByJewel.DataTextField = "jewel_ID"; ByJewel.DataBind(); con.Close(); con.Open(); ByPrice1.DataSource = cmd.ExecuteReader(); ByPrice1.DataTextField = "price"; ByPrice1.DataBind(); } catch (Exception ex) { throw ex; } finally { con.Close(); con.Dispose(); } } }
public void OnGet() { TotalEarnings = orderData.GetAllOrders().Sum(x => x.OrderTotal); TotalOrders = orderData.GetAllOrders().Count(); ProductSold = orderDetailData.GetOrderDetails().Sum(x => x.Quantity); NumberOfUsers = userManager.Users.Count(); ProgressBarMetod = new ProgressBar(); ProductsWithLowestQuantity = productData.GetFirstFiveProductsWithLowestQuantity(); var byDate = orderData.GetAllOrders().GroupBy(x => x.DateOrdered); foreach (var item in byDate) { var x = 0; foreach (var oD in item) { x += oD.OrderDetails.Sum(x => x.Quantity); } ByDate.Add(new StatisticsCore { DateTime = item.Key, NumberOfProducts = x }); } var proQuantity = orderData.GetAllOrders().GroupBy(x => x.OrderDetails); List <StatisticsCore> productQuantity = new List <StatisticsCore>(); foreach (var item in proQuantity) { foreach (var item1 in item.Key) { productQuantity.Add(new StatisticsCore { ProductName = item1.Product.Name, NumberOfProducts = item1.Quantity }); } } var tempPQ = productQuantity.GroupBy(x => x.ProductName); foreach (var item in tempPQ) { ProductQuantity.Add(new StatisticsCore { ProductName = item.Key, NumberOfProducts = item.Sum(x => x.NumberOfProducts) });; } Top3 = ProductQuantity.OrderByDescending(x => x.NumberOfProducts).Take(3); List <StatisticsCore> categoryQuantity = new List <StatisticsCore>(); foreach (var item in proQuantity) { foreach (var item1 in item.Key) { categoryQuantity.Add(new StatisticsCore { CategoryName = item1.Product.Category.Type, NumberOfProducts = item1.Quantity }); } } var tempCQ = categoryQuantity.GroupBy(x => x.CategoryName); foreach (var item in tempCQ) { ByCategory.Add(new StatisticsCore { CategoryName = item.Key, NumberOfProducts = item.Sum(x => x.NumberOfProducts) });; } var tempMemberships = userManager.Users.Include(x => x.Membership); List <StatisticsCore> tempUserMember = new List <StatisticsCore>(); foreach (var item in tempMemberships) { if (item.Membership != null) { tempUserMember.Add(new StatisticsCore { MembershipType = item.Membership.Type, NumberOfUsers = 1 }); } } foreach (var item in tempUserMember.GroupBy(x => x.MembershipType)) { UserMemberships.Add(new StatisticsCore { MembershipType = item.Key, NumberOfUsers = item.Sum(x => x.NumberOfUsers) }); } }