public ActionResult Index(PagerParameters pagerParameters, PayoutsViewModel adminViewModel, string filter = "") { var payouts = _payoutService.GetAllPayouts(); List<History> list; if (payouts != null) { if (filter == "1") list = payouts.Select(s => new History { Id = s.Id, Date = s.Date, Event = s.Event, Amount = s.Amount, IsPlus = s.IsPlus, UserId = s.UserId, Status = s.Status }).Where(s => s.Status == "Pending" && s.IsPlus == true).ToList(); else if (filter == "2") list = payouts.Select(s => new History { Id = s.Id, Date = s.Date, Event = s.Event, Amount = s.Amount, IsPlus = s.IsPlus, UserId = s.UserId, Status = s.Status }).Where(s => s.Status == "Completed" && s.IsPlus == true).ToList(); else list = payouts.Select(s => new History { Id = s.Id, Date = s.Date, Event = s.Event, Amount = s.Amount, IsPlus = s.IsPlus, UserId = s.UserId, Status = s.Status }).Where(s => s.IsPlus == true).ToList(); var entriesProjection = list.Select(e => { return Shape.FaqEntry( Date: e.Date, Id: e.Id, Event: e.Event, Amount: e.Amount, UserId: e.UserId, IsPlus: e.IsPlus, CampaignAlias: _campService.GetCampaignByAlias(e.Event.Substring(0, (e.Event.IndexOf(" ") < 0 ? 1 : e.Event.IndexOf(" ")))) != null ? _campService.GetCampaignByAlias(e.Event.Substring(0, e.Event.IndexOf(" "))).Alias : string.Empty, CampaignName: _campService.GetCampaignByAlias(e.Event.Substring(0, (e.Event.IndexOf(" ") < 0 ? 1 : e.Event.IndexOf(" ")))) != null ? _campService.GetCampaignByAlias(e.Event.Substring(0, e.Event.IndexOf(" "))).Title : string.Empty, CampaignId: _campService.GetCampaignByAlias(e.Event.Substring(0, (e.Event.IndexOf(" ") < 0 ? 1 : e.Event.IndexOf(" ")))) != null ? _campService.GetCampaignByAlias(e.Event.Substring(0, e.Event.IndexOf(" "))).Id : 0, SellerEmail: _contentManager.Query<UserPart, UserPartRecord>().List().FirstOrDefault(user => user.Id == e.UserId) != null ? _contentManager.Query<UserPart, UserPartRecord>().List().FirstOrDefault(user => user.Id == e.UserId).Email : string.Empty ); }); //foreach(var tranz in entriesProjection){ // string alias = tranz.Event.Substring(0, tranz.Event.IndexOf(" ")); // var camp = _campService.GetCampaignByAlias(alias); // var usr = _contentManager.Query<UserPart, UserPartRecord>().List().FirstOrDefault(user => user.Id == tranz.UserId); // tranz.Event = tranz.Event.Substring(tranz.Event.IndexOf(" "), tranz.Event.Length - alias.Length); // tranz.CampaignAlias = camp.Alias; // tranz.CampaignName = camp.Title; // tranz.CampaignId = camp.Id; // tranz.SellerEmail = usr.Email; //} var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters.Page, pagerParameters.PageSize); var entries = entriesProjection.Skip(pager.GetStartIndex()).Take(pager.PageSize); var pagerShape = Shape.Pager(pager).TotalItemCount(entriesProjection.Count()); return View("Index", new PayoutsViewModel { Transacts = entries.ToArray(), Pager = pagerShape }); } return View("Index", new PayoutsViewModel { Transacts = null, Pager = null }); }
public ActionResult Payouts(PagerParameters pagerParameters, PayoutsViewModel adminViewModel, string filter = "") { var payouts = _payoutService.GetAllPayouts(); List<History> list; if (payouts != null) { if (filter == "1") list = payouts.Select(s => new History { Id = s.Id, Date = s.Date, Event = s.Event, Amount = s.Amount, IsPlus = s.IsPlus, UserId = s.UserId, Status = s.Status }).Where(s => s.Status == "Pending" && s.IsPlus == false).ToList(); else if (filter == "2") list = payouts.Select(s => new History { Id = s.Id, Date = s.Date, Event = s.Event, Amount = s.Amount, IsPlus = s.IsPlus, UserId = s.UserId, Status = s.Status }).Where(s => s.Status == "Completed" && s.IsPlus == false).ToList(); else list = payouts.Select(s => new History { Id = s.Id, Date = s.Date, Event = s.Event, Amount = s.Amount, IsPlus = s.IsPlus, UserId = s.UserId, Status = s.Status }).Where(s => s.IsPlus == false).ToList(); var entriesProjection = list.Select(e => { return Shape.FaqEntry( Date: e.Date, Id: e.Id, Event: e.Event, Amount: e.Amount, Status: e.Status, UserId: e.UserId, IsPlus: e.IsPlus ); }); var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters.Page, pagerParameters.PageSize); var entries = entriesProjection.Skip(pager.GetStartIndex()).Take(pager.PageSize); var pagerShape = Shape.Pager(pager).TotalItemCount(entriesProjection.Count()); return View("Payouts", new PayoutsViewModel { Transacts = entries.ToArray(), Pager = pagerShape }); } return View("Payouts", new PayoutsViewModel { Transacts = null, Pager = null }); }