Ejemplo n.º 1
0
        public ActionResult CreateReport(CourseMonitoringReport acr, String waiting)
        {
            
            if (ModelState.IsValid)
            {
                CRMContext db = new CRMContext();

                if (waiting != null)
                {
                    acr.approveStatusId = 2;
                    var userName = User.Identity.Name;
                    var user = db.Accounts.SingleOrDefault(u => u.userName == userName);
                    var AnnualCourse = db.AnnualCourses.SingleOrDefault(a => a.annualCourseId == acr.annualCourseId);
                    int CMId = (int)AnnualCourse.Course.Faculty.cmAccount;
                    var Cm = db.Accounts.SingleOrDefault(u => u.accountId == CMId);
                    db.CourseMonitoringReports.Add(acr);
                    db.SaveChanges();
                    int ID = db.CourseMonitoringReports.Max(item => item.CourseMonitoringReportId);

                    var body = "<p>Email From: {0} ({1})</p><p>Message: {2}</p><p>Link: {3}</p>";
                    var uri = HttpContext.Request.Url;
                    String url = uri.GetLeftPart(UriPartial.Authority);

                    url = url + "/CM/Detail?reportId=" +ID;
                    var message = string.Format(body, user.Profile.name, user.Profile.email, "There is a report that you need to approve", url);
                    Task.Run(async () => await CustomHtmlHelpers.Helpers.sendMail(Cm.Profile.email, message));

                }else{
                    db.CourseMonitoringReports.Add(acr);
                    db.SaveChanges();
                }
                return RedirectToAction("ReportList");
            }
            return View();
        }
Ejemplo n.º 2
0
 public ActionResult CreateScoreChart(CourseMonitoringReport acr)
 {
     String scoreA = acr.markA.ToString();
     String scoreB = acr.markB.ToString();
     String scoreC = acr.markC.ToString();
     String scoreD = acr.markD.ToString();
     //Create bar chart
     var chart = new Chart(width: 300, height: 200, theme: ChartTheme.Blue)
     .AddTitle("Score Statistic")
     .AddLegend()
     .AddSeries(chartType: "pie",
                     xValue: new[] { "Excellent", "Good", "Ok", "NG" },
                     yValues: new[] { scoreA, scoreB, scoreC, scoreD })
                     .GetBytes("png");
     return File(chart, "image/bytes");
 }
Ejemplo n.º 3
0
        public ActionResult CreateResultChart(CourseMonitoringReport acr)
        {
            String scoreA = acr.markA.ToString();
            String scoreB = acr.markB.ToString();
            String scoreC = acr.markC.ToString();
            String scoreD = acr.markD.ToString();

            String pass = (acr.markA + acr.markB + acr.markC).ToString();
            String fail = acr.markD.ToString();
            //Create bar chart
            var chart = new Chart(width: 300, height: 200, theme: ChartTheme.Blue)
            .AddTitle("Result Statistic")
            .AddLegend()
            .AddSeries(chartType: "pie",
                            xValue: new[] { "Passed", "Failed" },
                            yValues: new[] { pass, fail })
                            .GetBytes("png");
            return File(chart, "image/bytes");
        }
Ejemplo n.º 4
0
        public async Task<ActionResult> EditReport(CourseMonitoringReport acr, String waiting)
        {
            CRMContext db = new CRMContext();
            if (ModelState.IsValid)
            {
                if (waiting != null)
                {
                    acr.approveStatusId=2;

                    var userName = User.Identity.Name;
                    var user = db.Accounts.SingleOrDefault(u => u.userName == userName);
                    var AnnualCourse = db.AnnualCourses.SingleOrDefault(a => a.annualCourseId == acr.annualCourseId);
                    int CMId =(int) AnnualCourse.Course.Faculty.cmAccount;
                    var Cm = db.Accounts.SingleOrDefault(u => u.accountId == CMId);

                    var body = "<p>Email From: {0} ({1})</p><p>Message:</p><p>{2}</p><p>Link: {3}</p>";
                    var uri = HttpContext.Request.Url;
                    String url = uri.GetLeftPart(UriPartial.Authority);
                    url = url + "/CM/Detail?reportId=" + acr.CourseMonitoringReportId;
                    var message = new MailMessage();
                    message.To.Add(new MailAddress(Cm.Profile.email));
                    message.Subject = "Course Monitoring Report";
                    message.Body = string.Format(body, user.Profile.name, user.Profile.email, "There is a report That you need to approve", url);
                    message.IsBodyHtml = true;
                    using (var smtp = new SmtpClient())
                    {
                        await smtp.SendMailAsync(message);

                    }
                }
                db.Entry(acr).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("ReportList");
            }
            return View(acr);
        }