예제 #1
0
        public void Backend_ReportBackend_CalculateDurationInOutStatus_Valid_Report_CheckIn_Late_Should_Pass()
        {
            //arrange
            var reportBackend = ReportBackend.Instance;
            var testReport    = new MonthlyReportViewModel();
            var testStudent   = DataSourceBackend.Instance.StudentBackend.GetDefault();

            testReport.Student   = testStudent;
            testReport.StudentId = testStudent.Id;
            var testStudentAttendance1 = new AttendanceModel
            {
                In = _5051.Backend.UTCConversionsBackend.KioskTimeToUtc(new DateTime(2018, 1, 15, 12, 0, 0))
            };

            testStudent.Attendance.Add(testStudentAttendance1);
            testReport.Stats.DaysPresent = 1;
            testReport.DateEnd           = DateTime.UtcNow;

            //act
            var result = reportBackend.GenerateOverallReport(testReport);

            //reset
            DataSourceBackend.Instance.Reset();

            //assert
            Assert.IsNotNull(result, TestContext.TestName);
        }
예제 #2
0
        // GET: Report
        /// <summary>
        /// Returns an individual monthly report for a student
        /// </summary>
        /// <param name="id">Student ID to generate Report for</param>
        /// <returns>Report data</returns>
        public ActionResult MonthlyReport(string id = null)
        {
            var CurrentId = DataSourceBackend.Instance.IdentityBackend.GetCurrentStudentID(HttpContext);

            if (DataSourceBackend.Instance.IdentityBackend.BlockExecptForRole(CurrentId, UserRoleEnum.TeacherUser))
            {
                return(RedirectToAction("Login", "Admin"));
            }

            var myStudent = DataSourceBackend.Instance.StudentBackend.Read(id);

            if (myStudent == null)
            {
                return(RedirectToAction("Error", "Home"));
            }


            var myReport = new MonthlyReportViewModel()
            {
                StudentId       = id,
                SelectedMonthId = 1
            };

            var myReturn = ReportBackend.Instance.GenerateMonthlyReport(myReport);

            return(View(myReturn));
        }
예제 #3
0
        public ActionResult MonthlyReport()
        {
            var dt = DateTime.Now;
            MonthlyReportViewModel model = new MonthlyReportViewModel(Convert.ToDateTime(dt), Convert.ToDateTime(dt.AddMonths(-1)));

            return(View(model));
        }
예제 #4
0
        public void Models_MonthlyReportViewModel_Default_Instantiate_Should_Pass()
        {
            // Act
            var result = new MonthlyReportViewModel();

            // Assert
            Assert.IsNotNull(result, TestContext.TestName);
        }
예제 #5
0
        /// <summary>
        /// Index Page
        /// </summary>
        /// <param name="id">Student Id</param>
        /// <returns>Student Record as a Student View Model</returns>
        // GET: Portal
        public ActionResult Index(string id = null)
        {
            var CurrentId = DataSourceBackend.Instance.IdentityBackend.GetCurrentStudentID(HttpContext);

            // Todo: Remove when identity is fully hooked up
            // Hack, to keep the current system working, while the identity system is slowly hooked up everywhere.  If the user is not logged in, then the passed in user will work, if the user is logged in, then the passed in user is ignored.
            if (string.IsNullOrEmpty(CurrentId))
            {
                CurrentId = id;
            }

            ViewBag.StudentId = CurrentId;  //TODO: Remove this when identity is fully hooked up

            if (DataSourceBackend.Instance.IdentityBackend.BlockExecptForRole(CurrentId, UserRoleEnum.StudentUser))
            {
                return(RedirectToAction("Roster", "Portal"));
            }

            var myStudent = DataSourceBackend.Instance.StudentBackend.Read(CurrentId);

            if (myStudent == null)
            {
                return(RedirectToAction("Roster", "Portal"));
            }

            var myReturn = new StudentDisplayViewModel(myStudent);

            //Set the last log in time and emotion status img uri
            if (myReturn.Attendance.Any())
            {
                myReturn.LastLogIn = UTCConversionsBackend.UtcToKioskTime(myReturn.Attendance.OrderByDescending(m => m.In).FirstOrDefault().In);
            }

            var myWeeklyReport = new WeeklyReportViewModel()
            {
                StudentId      = CurrentId,
                SelectedWeekId = 1
            };

            var myMonthlyReport = new MonthlyReportViewModel()
            {
                StudentId       = CurrentId,
                SelectedMonthId = 1
            };

            myReturn.WeeklyAttendanceScore  = ReportBackend.Instance.GenerateWeeklyReport(myWeeklyReport).Stats.PercAttendedHours;
            myReturn.MonthlyAttendanceScore = ReportBackend.Instance.GenerateMonthlyReport(myMonthlyReport).Stats.PercAttendedHours;

            return(View(myReturn));
        }
예제 #6
0
        public void Controller_Admin_Monthly_Report_Post_Data_Is_Null_Should_Return_Error_Page()
        {
            // Arrange
            AdminController        controller = new AdminController();
            MonthlyReportViewModel data       = null;

            var context = CreateMoqSetupForCookie();

            controller.ControllerContext = new ControllerContext(context, new RouteData(), controller);

            // Act
            var result = (RedirectToRouteResult)controller.MonthlyReport(data);

            // Assert
            Assert.AreEqual("Error", result.RouteValues["action"], TestContext.TestName);
        }
예제 #7
0
        public ActionResult MonthlyReport([Bind(Include =
                                                    "StudentId," +
                                                    "SelectedMonthId" +
                                                    "")] MonthlyReportViewModel data)
        {
            if (data == null)
            {
                // Send to error page
                return(RedirectToAction("Error", "Home"));
            }

            //generate the report
            var myReturn = ReportBackend.Instance.GenerateMonthlyReport(data);

            return(View(myReturn));
        }
예제 #8
0
        public IActionResult Report()
        {
            var vm    = new MonthlyReportViewModel();
            var count = 0;

            foreach (var month in Months)
            {
                var allExpenses = _budgetRepo.GetExpensesByMonth(month);

                if (allExpenses.Any())
                {
                    vm.MonthlyExpenses[count] = allExpenses.Sum();
                }

                count++;
            }

            return(View(vm));
        }
예제 #9
0
        public MonthlyReportView()
        {
            InitializeComponent();
            string targetPercentage = (string)Application.Current.FindResource("targetPercentage");
            string product          = (string)Application.Current.FindResource("Product");
            string sales            = (string)Application.Current.FindResource("Sales");

            if (this.DataContext != null && this.DataContext is MonthlyReportViewModel)
            {
                MonthlyReportViewModel vm = this.DataContext as MonthlyReportViewModel;
                txtBox.Text  = vm.userName + " \n\n";
                txtBox.Text += vm.TodayDate.ToString("dd/MM/yyyy") + " \n\n";

                foreach (var saleInfo in vm.salesInfos)
                {
                    txtBox.Text += product + " :  " + saleInfo.productReference + " \n";
                    txtBox.Text += sales + " :  " + saleInfo.TotalSaleMonth + " / " + saleInfo.MonthTarget + "             " + targetPercentage + " :  " + saleInfo.TargetPourcentageMonth + " %\n\n";
                }
            }
        }
예제 #10
0
        public void Controller_Admin_Monthly_Report_Post_Data_Is_Valid_Should_Pass()
        {
            // Arrange
            AdminController        controller = new AdminController();
            MonthlyReportViewModel data       = new MonthlyReportViewModel()
            {
                StudentId       = DataSourceBackend.Instance.StudentBackend.GetDefault().Id,
                SelectedMonthId = 2
            };

            var context = CreateMoqSetupForCookie();

            controller.ControllerContext = new ControllerContext(context, new RouteData(), controller);

            // Act
            var result = controller.MonthlyReport(data);

            // Assert
            Assert.IsNotNull(result, TestContext.TestName);
        }
예제 #11
0
        public void Models_MonthlyReportViewModel_Get_Set_Check_All_Fields_Should_Pass()
        {
            // Arrange

            // Act
            // Set all the fields for a BaseReportViewModel
            var test = new MonthlyReportViewModel
            {
                SelectedMonthId = 1,
                Months          = new List <SelectListItem>()
            };

            var expectedSelectedWeekId = 1;

            // Assert

            //Check each value
            Assert.AreEqual(test.SelectedMonthId, expectedSelectedWeekId, "SelectedWeekId " + TestContext.TestName);

            Assert.IsNotNull(test.Months, "Weeks " + TestContext.TestName);
        }
예제 #12
0
        public MonthlyReportViewModel GetMonthlyReportViewModel(DateTime startDate, DateTime endDate)
        {
            ReportDateFrom  = startDate;
            ReportDateTo    = endDate;
            MarketingYearId = _marketingYearService.GetMarketingYearByDate(ReportDateFrom);

            MarketingYearModel marketingYearModel = _marketingYearService.GetMarketingYearModel(MarketingYearId);

            var monthlyReportModel = new MonthlyReportViewModel
            {
                MonthlyReportBigGameModel   = GetMonthlyReportData(GameType.Big),
                MonthlyReportSmallGameModel = GetMonthlyReportData(GameType.Small),
                MonthlyReportFodderModel    = GetMonthlyReportFodderModel(),
                MonthlyReportLaborModel     = GetMonthlyReportLaborModel(),
                ReportDateFrom     = ReportDateFrom,
                ReportDateTo       = ReportDateTo,
                MarketingYearModel = marketingYearModel
            };

            SetFallowDeerAndMouflonData(monthlyReportModel.MonthlyReportBigGameModel);

            return(monthlyReportModel);
        }
예제 #13
0
        public ActionResult MonthlyReport([Bind(Include =
                                                    "StudentId," +
                                                    "SelectedMonthId" +
                                                    "")] MonthlyReportViewModel data)
        {
            var CurrentId = DataSourceBackend.Instance.IdentityBackend.GetCurrentStudentID(HttpContext);

            if (DataSourceBackend.Instance.IdentityBackend.BlockExecptForRole(CurrentId, UserRoleEnum.TeacherUser))
            {
                return(RedirectToAction("Login", "Admin"));
            }

            if (data == null)
            {
                // Send to error page
                return(RedirectToAction("Error", "Home"));
            }

            //generate the report
            var myReturn = ReportBackend.Instance.GenerateMonthlyReport(data);

            return(View(myReturn));
        }
예제 #14
0
        public void Backend_ReportBackend_GenerateMonthlyReport_Valid_Report_Should_Pass()
        {
            //arrange
            var reportBackend = ReportBackend.Instance;
            var testReport    = new MonthlyReportViewModel
            {
                SelectedMonthId = 1
            };
            var testStudent = DataSourceBackend.Instance.StudentBackend.GetDefault();

            testReport.Student   = testStudent;
            testReport.StudentId = testStudent.Id;
            var testStudentAttendance1 = new AttendanceModel
            {
                In = new DateTime(2018, 1, 15)
            };

            testStudent.Attendance.Add(testStudentAttendance1);
            var testStudentAttendance2 = new AttendanceModel
            {
                In = DateTime.UtcNow
            };

            testStudent.Attendance.Add(testStudentAttendance2);
            testReport.Stats.DaysPresent = 2;
            testReport.DateEnd           = DateTime.UtcNow;


            //act
            var result = reportBackend.GenerateMonthlyReport(testReport);

            //reset
            DataSourceBackend.Instance.Reset();

            //assert
            Assert.IsNotNull(result, TestContext.TestName);
        }
예제 #15
0
        public ActionResult GetMonthlyReport()
        {
            var i                = 1;
            var data             = new MonthlyReportViewModel();
            var record           = new List <MonthlyReportViewModel.Record>();
            var companyId        = OperatorProvider.Provider.GetCurrent().CompanyId;
            var reportCyde       = DateTime.Now.AddMonths(-1).ToString("yyyyMM");
            var reportStatistics = _reportStatisticsApp.GetFormByReportCyde(reportCyde, companyId);

            data.data = new[] { reportStatistics.Sum(x => x.F_SumDosage), reportStatistics.Sum(x => x.F_SumBill), reportStatistics.Sum(x => x.F_SumPay) };
            var costList = _statisticsApp.GetCustomerStatisticsList(reportCyde, companyId).GroupBy(x => x.F_CustomerName);

            foreach (var item in costList)
            {
                record.Add(new MonthlyReportViewModel.Record
                {
                    serial  = i++,
                    name    = item.Key,
                    sumcost = item.Sum(x => x.F_ThisMonthBill)
                });
            }
            data.record = record.ToArray();
            return(Content(data.ToJson()));
        }
예제 #16
0
        // GET: Report
        /// <summary>
        /// Returns an individual monthly report for a student
        /// </summary>
        /// <param name="id">Student ID to generate Report for</param>
        /// <returns>Report data</returns>
        public ActionResult MonthlyReport(string id = null)
        {
            var CurrentId = DataSourceBackend.Instance.IdentityBackend.GetCurrentStudentID(HttpContext);

            // Todo: Remove when identity is fully hooked up
            // Hack, to keep the current system working, while the identity system is slowly hooked up everywhere.  If the user is not logged in, then the passed in user will work, if the user is logged in, then the passed in user is ignored.
            if (string.IsNullOrEmpty(CurrentId))
            {
                CurrentId = id;
            }

            ViewBag.StudentId = CurrentId;  //TODO: Remove this when identity is fully hooked up

            if (DataSourceBackend.Instance.IdentityBackend.BlockExecptForRole(CurrentId, UserRoleEnum.StudentUser))
            {
                return(RedirectToAction("Roster", "Portal"));
            }

            var myStudent = DataSourceBackend.Instance.StudentBackend.Read(CurrentId);

            if (myStudent == null)
            {
                return(RedirectToAction("Error", "Home"));
            }


            var myReport = new MonthlyReportViewModel()
            {
                StudentId       = CurrentId,
                SelectedMonthId = 1
            };

            var myReturn = ReportBackend.Instance.GenerateMonthlyReport(myReport);

            return(View(myReturn));
        }
예제 #17
0
        public ActionResult MonthlyReport(DateTime dateFrom, DateTime dateTo)
        {
            MonthlyReportViewModel monthlyReportsModel = _reportService.GetMonthlyReportViewModel(dateFrom, dateTo);

            return(View(monthlyReportsModel));
        }
예제 #18
0
        public JsonResult GetMonthlyReportJsonData(DateTime dateFrom, DateTime dateTo)
        {
            MonthlyReportViewModel monthlyReportsModel = _reportService.GetMonthlyReportViewModel(dateFrom, dateTo);

            return(Json(monthlyReportsModel, JsonRequestBehavior.AllowGet));
        }
예제 #19
0
        public ActionResult MonthlyReport(string dateTxtFrom, string dateTxtTo)
        {
            MonthlyReportViewModel model = new MonthlyReportViewModel(Convert.ToDateTime(dateTxtFrom), Convert.ToDateTime(dateTxtTo));

            return(View(model));
        }
예제 #20
0
        public void Backend_ReportBackend_GenerateOverallReport_Valid_Report_Should_Pass()
        {
            //arrange
            var reportBackend = ReportBackend.Instance;
            var testReport    = new MonthlyReportViewModel();
            var testStudent   = DataSourceBackend.Instance.StudentBackend.GetDefault();

            testReport.Student   = testStudent;
            testReport.StudentId = testStudent.Id;

            var dayNow = UTCConversionsBackend.UtcToKioskTime(DateTime.UtcNow).Date;               //today's date

            var thisMonday = dayNow.AddDays(-7 - ((dayNow.DayOfWeek - DayOfWeek.Monday + 7) % 7)); //this Monday's date

            var attendanceMon = new AttendanceModel
            {
                In      = UTCConversionsBackend.KioskTimeToUtc(thisMonday.AddHours(8)),
                Out     = UTCConversionsBackend.KioskTimeToUtc(thisMonday.AddHours(9)),
                Emotion = EmotionStatusEnum.VeryHappy
            };
            var attendanceTue = new AttendanceModel
            {
                In      = UTCConversionsBackend.KioskTimeToUtc(thisMonday.AddDays(1).AddHours(10)),
                Out     = UTCConversionsBackend.KioskTimeToUtc(thisMonday.AddDays(1).AddHours(12)),
                Emotion = EmotionStatusEnum.Happy
            };
            var attendanceWed = new AttendanceModel
            {
                In      = UTCConversionsBackend.KioskTimeToUtc(thisMonday.AddDays(2).AddHours(10)),
                Out     = UTCConversionsBackend.KioskTimeToUtc(thisMonday.AddDays(2).AddHours(12)),
                Emotion = EmotionStatusEnum.Neutral
            };
            var attendanceThu = new AttendanceModel
            {
                In      = UTCConversionsBackend.KioskTimeToUtc(thisMonday.AddDays(3).AddHours(10)),
                Out     = UTCConversionsBackend.KioskTimeToUtc(thisMonday.AddDays(3).AddHours(12)),
                Emotion = EmotionStatusEnum.Sad
            };
            var attendanceFri = new AttendanceModel
            {
                In      = UTCConversionsBackend.KioskTimeToUtc(thisMonday.AddDays(4).AddHours(10)),
                Out     = UTCConversionsBackend.KioskTimeToUtc(thisMonday.AddDays(4).AddHours(12)),
                Emotion = EmotionStatusEnum.VerySad
            };

            testStudent.Attendance.Add(attendanceMon);
            testStudent.Attendance.Add(attendanceTue);
            testStudent.Attendance.Add(attendanceWed);
            testStudent.Attendance.Add(attendanceThu);
            testStudent.Attendance.Add(attendanceFri);

            testReport.DateEnd = DateTime.UtcNow;

            //act
            var result = reportBackend.GenerateOverallReport(testReport);

            //reset
            DataSourceBackend.Instance.Reset();

            //assert
            Assert.IsNotNull(result, TestContext.TestName);
        }
예제 #21
0
        /// <summary>
        /// Generate monthly report
        /// </summary>
        /// <param name="report"></param>
        /// <returns></returns>
        public MonthlyReportViewModel GenerateMonthlyReport(MonthlyReportViewModel report)
        {
            //set student
            report.Student = DataSourceBackend.Instance.StudentBackend.Read(report.StudentId);

            //to generate month selection drop down, make a list item for every month between first and last day of school
            var dayFirst = DataSourceBackend.Instance.SchoolDismissalSettingsBackend.GetDefault().DayFirst.Date;
            var dayLast  = DataSourceBackend.Instance.SchoolDismissalSettingsBackend.GetDefault().DayLast.Date;

            var dayNow = UTCConversionsBackend.UtcToKioskTime(DateTimeHelper.Instance.GetDateTimeNowUTC()).Date;

            //The first valid month for the dropdown
            var monthFirst = new DateTime(dayFirst.Year, dayFirst.Month, 1);
            //The last valid month for the dropdown
            var monthLast = new DateTime(dayLast.Year, dayLast.Month, 1);
            //The month of today
            var monthNow = new DateTime(dayNow.Year, dayNow.Month, 1);

            //do not go beyond the month of today
            if (monthLast > monthNow)
            {
                monthLast = monthNow;
            }

            //Set the current month (loop variable) to the last valid month
            var currentMonth = monthLast;

            //initialize the dropdownlist
            report.Months = new List <SelectListItem>();

            // the month id
            int monthId = 1;

            //loop backwards in time so that the month select list items are in time reversed order
            while (currentMonth >= monthFirst)
            {
                //make a list item for the current month
                var month = new SelectListItem {
                    Value = "" + monthId, Text = currentMonth.ToString("MMMM yyyy")
                };

                //add to the select list
                report.Months.Add(month);

                //if current month is the selected month, set the start date and end date for this report
                if (monthId == report.SelectedMonthId)
                {
                    //set start date and end date
                    report.DateStart = currentMonth;
                    report.DateEnd   = new DateTime(currentMonth.Year, currentMonth.Month, DateTime.DaysInMonth(currentMonth.Year, currentMonth.Month));
                }

                monthId++;
                currentMonth = currentMonth.AddMonths(-1);
            }


            //Generate report for this month
            GenerateReportFromStartToEnd(report);

            return(report);
        }