// GET: Statistic public async Task <ActionResult> Index(string fromDatePie, string toDatePie, string fromDateWorks, string toDateWorks, string groupId, string fromDateUserWorks, string toDateUserWorks) { string accessToken = Session["MicrosoftAccessToken"] as string; if (String.IsNullOrWhiteSpace(accessToken)) { return(RedirectToAction("Login", "Account")); } const string dateFormatString = "yyyy-MM-dd"; ViewBag.FromDatePie = !String.IsNullOrWhiteSpace(fromDatePie) ? fromDatePie : DateTime.Today.AddDays(-7).ToString(dateFormatString); ViewBag.ToDatePie = !String.IsNullOrWhiteSpace(toDatePie) ? toDatePie : DateTime.Today.AddDays(1).ToString(dateFormatString); ViewBag.FromDateWorks = !String.IsNullOrWhiteSpace(fromDateWorks) ? fromDateWorks : DateTime.Today.AddDays(-7).ToString(dateFormatString); ViewBag.ToDateWorks = !String.IsNullOrWhiteSpace(toDateWorks) ? toDateWorks : DateTime.Today.AddDays(1).ToString(dateFormatString); ViewBag.FromDateUserWorks = !String.IsNullOrWhiteSpace(fromDateUserWorks) ? fromDateUserWorks : DateTime.Today.AddDays(-7).ToString(dateFormatString); ViewBag.ToDateUserWorks = !String.IsNullOrWhiteSpace(toDateUserWorks) ? toDateUserWorks : DateTime.Today.AddDays(1).ToString(dateFormatString); UserGroupService userGroupService = new UserGroupService(accessToken); var usrGroup = await userGroupService.GetGroupForUser(Session["UserId"] as string); var defaultGroup = usrGroup.SingleOrDefault(g => g.GroupName.Contains("Default group for user")); var selectedGroupId = String.IsNullOrWhiteSpace(groupId) ? defaultGroup.Id : groupId; ViewBag.GroupID = new SelectList(usrGroup, "Id", "GroupNameTruncated", selectedGroupId); ViewBag.SelectedGroupID = selectedGroupId; return(View()); }
public async Task <SelectList> SetGroupForStatstic(string accessToken) { UserGroupService userGroupService = new UserGroupService(accessToken); var usrGroup = await userGroupService.GetGroupForUser(Session["UserId"] as string); var defaultGroup = usrGroup.SingleOrDefault(g => g.GroupName.Contains("Default group for user")); //ViewBag.GroupId = new SelectList(usrGroup, "Id", "GroupNameTruncated", defaultGroup); return(new SelectList(usrGroup, "Id", "GroupNameTruncated", defaultGroup)); }