// GET: Reports public ActionResult Index() { if (!Globals.LOGIN_STATUS) { return(RedirectToAction("Login", "Home")); } else { ReportsHomeVM model = new ReportsHomeVM(); GetDAL get = new GetDAL(); get.OpenConnection(); model.LstAllRehearsalParts = get.GetAllRehearsalParts(); model.LstAllEvents = get.GetEventsByUser(Globals.LOGGED_IN_USER.IntUserID); model.LstAllRehearsals = new List <Rehearsal>(); foreach (Event e in model.LstAllEvents) { get.CloseConnection(); get.OpenConnection(); model.LstAllRehearsals.AddRange(get.GetRehearsalsByEvent(e)); } get.CloseConnection(); foreach (Rehearsal r in model.LstAllRehearsals) { r.DateWithEvent = r.Event.StrName + " " + r.DtmStartDateTime; } return(View("ReportsHome", model)); } }
////add text to GenerateReport.cshtml public ActionResult MakeReport(ReportsHomeVM vm) { ReportsHomeVM model = new ReportsHomeVM(); if (vm.ChosenRehearsal == null) { vm.ChosenRehearsal = new Rehearsal(Globals.rID); } GetDAL get = new GetDAL(); get.OpenConnection(); Rehearsal r = get.GetRehearsalByID(vm.ChosenRehearsal.IntRehearsalID); Globals.rID = r.IntRehearsalID; //Rehearsal r = vm.ChosenRehearsal; List <RehearsalPart> rehearsalPartsForToday = get.GetRehearsalPartsByRehearsal(r); model.EventName = r.Event.StrName;; model.GroupName = r.Event.Group.StrName; model.Location = r.StrLocation; model.StartTime = r.DtmStartDateTime.ToString(); model.EndTime = r.DtmEndDateTime.ToString(); model.RehearsalDate = r.DtmStartDateTime.Date.ToString(); foreach (RehearsalPart rp in rehearsalPartsForToday) { rp.AttendancePlanned = get.GetAttendancePlannedByRehearsalPart(rp); rp.AttendanceActual = new List <AttendanceActual>(); foreach (AttendancePlanned ap in rp.AttendancePlanned) { rp.AttendanceActual = rp.AttendanceActual.Concat(get.GetAttendanceActualByPlanned(ap)).ToList(); } } model.Notes = r.StrNotes; model.LstAllRehearsalParts = rehearsalPartsForToday; get.CloseConnection(); Globals.PDF = model; return(View("GenerateReport", model)); }