public async Task <string> Get(DateTime startdate, DateTime enddate, int eventid) { object User; HttpContext.Items.TryGetValue("principaluser", out User); var Userinfo = (Payload)User; DashboardRepository dashboardRepository = new DashboardRepository(); EventRespositoryv2 eventRespositoryv2 = new EventRespositoryv2(); OrderRespository orderRespository = new OrderRespository(); //var UserEvents = await eventRespositoryv2.GetUserEvents(Userinfo.UserId); var MonthlystatsTask = eventRespositoryv2.GetMonthlyStats(eventid, startdate.ToUniversalTime(), enddate.ToUniversalTime()); //var getGrossnet = eventid == 0 ? dashboardRepository.GrossNet(Userinfo.UserId) : dashboardRepository.GrossNetPerEvent(Userinfo.UserId,eventid); var aggregateOrderTicketSales = dashboardRepository.AggregateOrderticketsalesPerEvent(Userinfo.UserId, startdate.ToUniversalTime(), enddate.ToUniversalTime(), eventid); //var Balance = dashboardRepository.Balance(Userinfo.UserId); // var EventCategories = await new EventRespositoryv2().EventCategories(); //var orderTicketsaleGrouped = eventid == 0 ? dashboardRepository.OrderTicketSalegrouped(Userinfo.UserId, startdate.ToUniversalTime(), enddate.ToUniversalTime()) : dashboardRepository.OrdeTicketSalegroupedPerEvent(Userinfo.UserId, startdate.ToUniversalTime(), enddate.ToUniversalTime(), eventid); var LatestOrdersTask = orderRespository.GetLatestOrders(); // alltasks.AddRange() try { await Task.WhenAll(LatestOrdersTask, MonthlystatsTask); } catch (Exception ex) { throw; } return(JsonConvert.SerializeObject(new { monthlystats = await MonthlystatsTask, latestorders = await LatestOrdersTask })); }