public ActionResult Index(User currentUser, int year, int month) { Require.NotNull(currentUser, "currentUser"); Require.Ge(year, 2000, "year"); Require.Ge(month, 1, "month"); Require.Le(month, 12, "month"); DateTime firstDayOfMonth = new DateTime(year, month, 1); /*Ab Montag der Woche des ersten Tages des Monats.*/ DateTime from = firstDayOfMonth.GetFirstDayOfWeek(); /*Bis Sonntag der Woche des letzten Tages Monats*/ DateTime to = firstDayOfMonth .AddMonths(1) // 1. des nächsten Monats .AddDays(-1) // letzter des aktuellen Monats .GetFirstDayOfWeek() // Montag der letzten Woche .AddDays(6); // Sonntag der letzten Woche IPage <PeanutParticipation> peanutParticipations = PeanutService.FindParticipationsOfUser(PageRequest.All, currentUser, from, to); IPage <Peanut> attendablePeanuts = PeanutService.FindAttendablePeanutsForUser(PageRequest.All, currentUser, from, to); IDictionary <DateTime, IList <PeanutParticipation> > peanutParticipationsByDate = peanutParticipations.GroupBy(participation => participation.Peanut.Day) .ToDictionary(g => g.Key, g => (IList <PeanutParticipation>)g.ToList()); IDictionary <DateTime, IList <Peanut> > attendablePeanutsByDate = attendablePeanuts.GroupBy(peanut => peanut.Day) .ToDictionary(g => g.Key, g => (IList <Peanut>)g.ToList()); return(View("Index", new PeanutsIndexViewModel(year, month, peanutParticipationsByDate, attendablePeanutsByDate))); }
public async Task <ActionResult> Index(User currentUser) { IPage <UserGroupMembership> memberships = UserGroupService.FindMembershipsByUser(PageRequest.All, currentUser, new List <UserGroupMembershipType> { UserGroupMembershipType.Administrator, UserGroupMembershipType.Member }); IPage <Payment> pendingPayments = PaymentService.FindPendingPaymentsByUser(PageRequest.First, currentUser); IPage <Payment> declinedPayments = PaymentService.FindDeclinedPaymentsByUser(PageRequest.First, currentUser); IPage <PeanutParticipation> peanutParticipations = PeanutService.FindParticipationsOfUser(PageRequest.All, currentUser, DateTime.Today, DateTime.Today); IPage <Bill> declinedBills = BillService.FindDeclinedCreditorBillsByUser(PageRequest.All, currentUser); List <Bill> unsettledBills = BillService.FindCreditorBillsForUser(PageRequest.All, currentUser, false).ToList(); unsettledBills.AddRange(BillService.FindDebitorBillsForUser(PageRequest.All, currentUser, false).ToList()); return(View("Index", new IndexViewModel(peanutParticipations, memberships, unsettledBills, declinedBills, pendingPayments, declinedPayments, currentUser.DisplayName))); }
public ActionResult Day(int year, int month, int day, User currentUser) { DateTime date = new DateTime(year, month, day); IPage <PeanutParticipation> peanutParticipations = PeanutService.FindParticipationsOfUser(PageRequest.All, currentUser, date, date, new [] { PeanutParticipationState.Confirmed }); IPage <Peanut> attendablePeanuts = PeanutService.FindAttendablePeanutsForUser(PageRequest.All, currentUser, date, date); if (peanutParticipations.TotalElements == 1 && attendablePeanuts.TotalElements == 0) { /*Wenn es an diesem Tag nur diesen einen Peanut gibt, dann diesen anzeigen*/ return(RedirectToAction("Show", "Peanut", new { peanut = peanutParticipations.Single().Peanut.BusinessId })); } else { return(View("List", new PeanutsListViewModel(date, date, peanutParticipations.ToList(), attendablePeanuts.ToList()))); } }