initial commit
[CPE_learningsite] / CPE / CPE.Utilities / Result.cs
1 ´╗┐using System;
2 using System.Collections.Generic;
3 using System.Configuration;
4 using System.Linq;
5 using System.Text;
6 using System.Threading.Tasks;
7 using System.Web.UI.WebControls.WebParts;
8 using Microsoft.SqlServer.Server;
9
10 namespace CPE.Utilities
11 {
12     public static class Result
13     {
14         public static string PassResultText
15         {
16             get
17             {
18                 string path = "~/static/doc/PassResultText.html";
19                 string filePath = System.Web.HttpContext.Current.Server.MapPath(path);
20                 return System.IO.File.ReadAllText(filePath);
21             }
22         }
23         public static string FailResultText
24         {
25             get
26             {
27                 string path = "~/static/doc/FailResultText.html";
28                 string filePath = System.Web.HttpContext.Current.Server.MapPath(path);
29                 return System.IO.File.ReadAllText(filePath);
30             }
31         }
32         public static string IneligibleResultText
33         {
34             get
35             {
36                 string path = "~/static/doc/IneligibleResultText.html";
37                 string filePath = System.Web.HttpContext.Current.Server.MapPath(path);
38                 return System.IO.File.ReadAllText(filePath);
39             }
40         }
41         public static string WonkyResultText
42         {
43             get
44             {
45                 string path = "~/static/doc/WonkyResultText.html";
46                 string filePath = System.Web.HttpContext.Current.Server.MapPath(path);
47                 return System.IO.File.ReadAllText(filePath);
48             }
49         }
50
51         //public static string RenderPassResult(int principalid, string certURl)
52         //{
53         //    string html = PassResultText;
54         //    html = html.Replace("[principalid]", principalid.ToString());
55         //    html = html.Replace("certUrl", certURl);
56         //    return html;
57         //}
58
59         public static string RenderPassResult(int principalid)
60         {
61             string html = PassResultText;
62             html = html.Replace("[principalid]", principalid.ToString());
63             return html;
64         }
65
66         public static string RenderCertLink(int meetingSco, DateTime purchaseDate, string ticket)
67         {
68             string meetingUrl = meetingSco.ToString();
69             var certLink = ConfigurationManager.AppSettings["CertLink"];
70             var certURl = string.Format(certLink, meetingUrl, purchaseDate.ToString("yyyyMMdd"), ticket);
71             return certURl;
72         }
73
74         public static string RenderFailResult(int principalid)
75         {
76             string html = FailResultText;
77             html = html.Replace("[principalid]", principalid.ToString());
78             return html;
79         }
80
81         public static string RenderIneligibleResult(int principalid)
82         {
83             string html = IneligibleResultText;
84             html = html.Replace("[principalid]", principalid.ToString());
85             return html;
86         }
87
88         public static string RenderWonkyResult()
89         {
90             string html = WonkyResultText;
91             return html;
92         }
93     }
94 }