public async Task <IHttpActionResult> GetCalendarGridView() { if ((MyConfig == null) || !MyConfig.IsConfigured) { return(new StatusCodeResult(HttpStatusCode.NoContent, Request)); } var targetStartDate = DateTime.Today; var sessionConfig = MyConfig.CalendarGridConfig; sessionConfig.StartDate = targetStartDate; MyConfig.ConfigureGrid(sessionConfig); if (!await MyConfig.Populate()) { return(new StatusCodeResult(HttpStatusCode.InternalServerError, Request)); } using (var sw = new StringWriter()) { var writer = new HtmlTextWriter(sw); await MyConfig.CalendarGrid.Render(writer); return(await Task.FromResult(Ok(sw.GetStringBuilder().ToString()))); } }
public async Task <IHttpActionResult> GetSpecificCalendarGridView([FromBody] int?dateShift) { if ((MyConfig == null) || !MyConfig.IsConfigured) { return(new StatusCodeResult(HttpStatusCode.NoContent, Request)); } var targetStartDate = DateTime.Today; if (dateShift.HasValue) { var dateDiff = DateTime.Today - DateTime.Today.AddDays(dateShift.Value); if (Math.Abs(dateDiff.Days) <= MyConfig.CalendarGridConfig.MaxDaysShift) { targetStartDate = DateTime.Today.AddDays(dateShift.Value); } } var sessionConfig = MyConfig.CalendarGridConfig; sessionConfig.StartDate = targetStartDate; MyConfig.ConfigureGrid(sessionConfig); await MyConfig.Populate(); using (var sw = new StringWriter()) { var writer = new HtmlTextWriter(sw); await MyConfig.CalendarGrid.Render(writer); return(await Task.FromResult(Ok(sw.GetStringBuilder().ToString()))); } }