//public IActionResult LoadCalendar() //{ // try // { // StringBuilder sbJson = new StringBuilder(); // var CalendarList = _ICalendar.GetUserCalendarList().GroupBy(a => new { a.CalendarId, a.PresenterId, a.Presenter, a.StartDate, a.EndDate, a.Training }); // sbJson.Append("["); // if (CalendarList.Count() > 0) // { // foreach (var vAll in CalendarList) // { // //sbJson.Append(@"{""Id"":""" + vAll.Key.CalendarId + @""",""startDate"": new Date(2020, 1 , 1),""endDate"": new Date(2020, 1, 1),""startTime"": """ + vAll.Key.EndDate.ToString("HH:mm") + @""",""name"": """ + vAll.Key.Training + @""",""presenter"": """ + vAll.Key.Presenter + @""",""attendee"":"""); // //sbJson.Append(@"{""Id"":""" + vAll.Key.CalendarId + @""",""startDate"": new Date('" + vAll.Key.StartDate.ToString("yyyy-MM-dd") + @"'),""endDate"": new Date('" + vAll.Key.EndDate.ToString("yyyy-MM-dd") + @"'),""startTime"": """ + vAll.Key.EndDate.ToString("HH:mm") + @""",""name"": """ + vAll.Key.Training + @""",""presenter"": """ + vAll.Key.Presenter + @""",""attendee"":"""); // sbJson.Append(@"{""Id"":""" + vAll.Key.CalendarId + @""",""startDate"": """ + vAll.Key.StartDate.ToString("yyyy-MM-dd") + @""",""endDate"": """ + vAll.Key.EndDate.ToString("yyyy-MM-dd") + @""",""startTime"": """ + vAll.Key.StartDate.ToString("HH:mm") + @""",""name"": """ + vAll.Key.Training + @""",""presenter"": """ + vAll.Key.Presenter + @""",""attendee"":"""); // foreach (var v in vAll) // { // sbJson.Append(@"" + v.Attendee + ", "); // } // sbJson.Remove(sbJson.Length - 2, 2); // sbJson.Append(@"""},"); // } // sbJson.Remove(sbJson.Length - 1, 1); // } // sbJson.Append("]"); // //Returning Json Data // return Json(new { caldata = sbJson.ToString() }); // //return Json(sbJson.ToString()); // } // catch (Exception) // { // throw; // } //} public IActionResult LoadCalendar() { try { StringBuilder sbJson = new StringBuilder(); var CalendarList = _ICalendar.GetUserCalendarList().GroupBy(a => new { a.CalendarId, a.PresenterId, a.Presenter, a.StartDate, a.EndDate, a.Training }); sbJson.Append("["); if (CalendarList.Count() > 0) { foreach (var vAll in CalendarList) { sbJson.Append(@"{""Id"":""" + vAll.Key.CalendarId + @""",""startDate"": """ + vAll.Key.StartDate.ToString("yyyy-MM-dd") + @""",""endDate"": """ + vAll.Key.EndDate.ToString("yyyy-MM-dd") + @""",""startTime"": """ + vAll.Key.StartDate.ToString("HH:mm") + @""",""name"": """ + vAll.Key.Training + @""",""presenterid"": """ + vAll.Key.PresenterId + @""",""presenter"": """ + vAll.Key.Presenter + @""",""attendees"":["); foreach (var v in vAll) { sbJson.Append(@"{""attendeeid"":""" + v.AttendeeId + @""", ""attended"":""" + v.Attended + @""", ""attendee"":""" + v.Attendee + @"""},"); } sbJson.Remove(sbJson.Length - 1, 1); sbJson.Append(@"]},"); } sbJson.Remove(sbJson.Length - 1, 1); } sbJson.Append("]"); //Returning Json Data return(Json(new { caldata = sbJson.ToString() })); //return Json(sbJson.ToString()); } catch (Exception) { throw; } }
public IActionResult LoadUserTrainingReport(int Id) { try { List <UserTrainingCalendar> userTrainingCalendarList = new List <UserTrainingCalendar>(); var UserTrainingList = _ITraining.GetUserTrainingList(Id); var UserCalendarList = _ICalendar.GetUserCalendarList(Id); foreach (var v in UserTrainingList) { UserTrainingCalendar entry = new UserTrainingCalendar(); entry.Training = v.TrainingCode + " - " + v.Training; entry.TrainingCategory = v.TrainingCategory; entry.Priority = v.Priority; if (v.IsPrimary) { entry.IsPrimary = "Primary Skills"; } else { entry.IsPrimary = "Secondary Skills"; } var data = UserCalendarList.Where(a => a.TrainingId == v.TrainingId).FirstOrDefault(); if (data != null) { if (data.Attended) { entry.Status = "Attended on " + data.StartDate.ToString("dd-MM-yyyy"); entry.Color = "#5cb85c"; } else { entry.Status = "Not Attended " + data.StartDate.ToString("dd-MM-yyyy"); entry.Color = "#D9534F"; } } else { entry.Status = "Not yet scheduled"; entry.Color = "#aaa"; } userTrainingCalendarList.Add(entry); } //total number of rows counts var recordsTotal = userTrainingCalendarList.Count; //Returning Json Data return(Json(new { recordsFiltered = recordsTotal, recordsTotal = recordsTotal, data = userTrainingCalendarList })); } catch (Exception) { throw; } }