public ActionResult EventsFeed(DateTime?startParam, DateTime?endParam, string timezoneParam) { var events = _eventsRepository.GetAll(); var result = events.Select(e => new { id = e.Id, color = e.Color, title = e.Name, start = Globalization.GetLocalDateTime(e.StartDate), end = Globalization.GetLocalDateTime(e.EndDate) }); return(Json(result)); }
public ActionResult EventsSidebar() { var events = _eventsRepository.GetAll(); var model = new CalendarEventsSidebarViewModel(); var localNow = Globalization.GetLocalDateTime(DateTime.UtcNow); model.UpcomingEvents = events.Where(e => Globalization.GetLocalDateTime(e.StartDate.Date) >= localNow.Date ).OrderBy(e => Globalization.GetLocalDateTime(e.StartDate.DateTime) ).ToList(); return(PartialView(model)); }
public ActionResult Statistics() { var model = new ContactStatistics(); var contacts = _contactsRepository.GetAll(); // Count model.Count = contacts.Count(); // Latest model.Latest = contacts.OrderByDescending(c => c.Id).Take(3).Select(i => new { name = i.Name, image = _imageService.BuildUrl(i.ImageBlob?.Name, i.Name, 40, 40), creationDate = Globalization.GetLocalDateTime(i.UTCCreation).DateTime.ToLongDateString(), navigationPath = Url.Action(nameof(ContactsController.Edit), nameof(ContactsController).RemoveControllerSuffix(), new { @id = i.Id }) }).Cast <object>().ToList(); // Weekly data var maxDate = DateTime.UtcNow; var minDate = maxDate.AddDays(-7); contacts = contacts.Where(c => c.UTCCreation.Date >= minDate.Date); contacts = contacts.Where(c => c.UTCCreation.Date <= maxDate.Date); var items = new List <object>(); for (DateTime date = minDate.Date; date <= maxDate.Date; date = date.AddDays(1)) { var dayName = date.ToString("MMM/dd"); var dayValue = contacts.Where(c => c.UTCCreation.Date.Equals(date)).Count(); items.Add(new List <object>() { dayName, dayValue }); } model.WeeklyRegistrations = items; return(Json(model)); }
public ActionResult Statistics() { var model = new EventTrackingStatistics(); var entity = _eventtrackingRepository.GetAll(); // Count model.Count = entity.Count(); // Latest model.Latest = entity.OrderByDescending(c => c.Id).Take(3).Select(i => new { name = i.Name, creationDate = Globalization.GetLocalDateTime(i.UTCCreation).DateTime.ToLongDateString(), }).Cast <object>().ToList(); // Weekly data var maxDate = DateTime.UtcNow; var minDate = maxDate.AddDays(-7); entity = entity.Where(c => c.UTCCreation.Date >= minDate.Date); entity = entity.Where(c => c.UTCCreation.Date <= maxDate.Date); var items = new List <object>(); for (DateTime date = minDate.Date; date <= maxDate.Date; date = date.AddDays(1)) { var dayName = date.ToString("MMM/dd"); var dayValue = entity.Where(c => c.UTCCreation.Date.Equals(date)).Count(); items.Add(new List <object>() { dayName, dayValue }); } model.WeeklyRegistrations = items; return(Json(model)); }