// GET: CaseStudy public ActionResult Index() { // 30/08/2015 var choosenList2 = _iScheduleService.GetAllSchedule().Where(x => x.Date <new DateTime(2015, 8, 30, 23, 59, 59) && x.Date> new DateTime(2015, 8, 30, 0, 0, 0)).Select(x => x.ProgramCode).Distinct().ToList(); List <ViewModelProgram> progamList2 = _iProgramService.GetAllProgramsHaveQuantity(new DateTime(2015, 8, 30)).Where(x => choosenList2.Contains(x.ProgramCode)).ToList(); ViewBag.realProgram = progamList2; List <ViewModelProgram> progamList1 = _iProgramService.GetAllProgram().Where(x => choosenList2.Contains(x.ProgramCode)).ToList(); ViewBag.originalProgram = progamList1; // 31/08/2015 var choosenList2next = _iScheduleService.GetAllSchedule().Where(x => x.Date <new DateTime(2015, 8, 31, 23, 59, 59) && x.Date> new DateTime(2015, 8, 31, 0, 0, 0)).Select(x => x.ProgramCode).Distinct().ToList(); List <ViewModelProgram> progamList2next = _iProgramService.GetAllProgramsHaveQuantity(new DateTime(2015, 8, 31)).Where(x => choosenList2next.Contains(x.ProgramCode)).ToList(); ViewBag.realProgramnext = progamList2next; List <ViewModelProgram> progamList1next = _iProgramService.GetAllProgram().Where(x => choosenList2next.Contains(x.ProgramCode)).ToList(); ViewBag.originalProgramnext = progamList1next; // predict 31/08/2015 var result = _iMakeScheduleService.makeSchedule(progamList2next, new DateTime(2015, 8, 31, 10, 30, 0), new DateTime(2015, 8, 31)); ViewBag.predictResult = result; // real result 31/08/2015 var realResult = _iProgramService.GetProgramQuantity(progamList2next, new DateTime(2015, 8, 31)); ViewBag.realresult = realResult; // compare var compare = new List <ViewModelProgram>(); for (int i = 0; i < result.Count(); i++) { if (result[i].quantityList.FirstOrDefault().NoTimes == realResult[i].quantityList.FirstOrDefault().NoTimes) { var temp = new ViewModelProgram(); temp.ProgramCode = result[i].ProgramCode; temp.Name = result[i].Name; temp.quantityList = new List <ViewModelQuantity>(); ViewModelQuantity a1 = new ViewModelQuantity() { NoTimes = result[i].quantityList.FirstOrDefault().NoTimes, quantity = result[i].quantityList.FirstOrDefault().quantity - realResult[i].quantityList.FirstOrDefault().quantity }; temp.quantityList.Add(a1); temp.quantityList.Add(result[i].quantityList.FirstOrDefault()); temp.quantityList.Add(realResult[i].quantityList.FirstOrDefault()); compare.Add(temp); } } ViewBag.compare = compare; // use the total real schedule to predict return(View()); }
// GET: MakeSchedule public ActionResult BroadcastSchedule(List <ViewModelCheckBox> list) { var choosenList = list.Where(x => x.Checked == true).Select(x => x.Id).ToList(); List <ViewModelProgram> progamList = _iProgramService.GetAllProgramsHaveProduct().Where(x => choosenList.Contains(x.Id)).ToList(); var result = _iMakeScheduleService.makeSchedule(progamList, new DateTime(2015, 9, 1, 9, 0, 0), new DateTime(2015, 9, 1)); return(View(result)); }