-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi_student.ashx
More file actions
65 lines (60 loc) · 2.69 KB
/
api_student.ashx
File metadata and controls
65 lines (60 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<%@ WebHandler Language="C#" Class="api_student" %>
using System;
using System.Web;
using MldOnLine.TableHelper;
using EricLib.Utility;
public class api_student : IHttpHandler
{
public void ProcessRequest(HttpContext context) {
context.Response.ContentType = "text/plain";
try
{
var _returnString = string.Empty;
var tblStudent = new TblStudentProfile();
var tblUserLogin = new TblUserLogin();
switch (context.Request.Params["action"])
{
case "get_all":
_returnString = tblStudent.GetAll();
break;
case "get_all_encode":
_returnString = tblStudent.GetAll(true);
//_returnString = objStudent.GetAllWithEncryptedName();
break;
case "add":
_returnString = JsonHelper.GetEasyUiJsonStr(tblStudent.Create(context), tblStudent.successMsg, tblStudent.errorMsg);
break;
case "save":
_returnString = JsonHelper.GetEasyUiJsonStr(tblStudent.Update(Convert.ToInt32(context.Request.QueryString["id"]), context), tblStudent.successMsg, tblStudent.errorMsg);
break;
case "delete":
_returnString = JsonHelper.GetEasyUiJsonStr(tblStudent.Delete(Convert.ToInt32(context.Request.Params["id"])), tblStudent.successMsg, tblStudent.errorMsg);
break;
case "register":
if (tblStudent.Create(context))
{
string userEmail = context.Request.Params["Email"];
string userPwd = context.Request.Params["Password"];
_returnString = JsonHelper.GetEasyUiJsonStr(tblUserLogin.Create(userEmail, userPwd, UserRole.Student), tblStudent.successMsg, tblStudent.errorMsg);
}
else _returnString = JsonHelper.GetEasyUiJsonStr(false, tblStudent.successMsg, tblStudent.errorMsg);
break;
case "reset_id":
_returnString = TblStudentProfile.ResetAutoNumber();
break;
default:
_returnString = "[action] is null";
break;
}
context.Response.Write(_returnString);
}
catch (Exception ex) { context.Response.Write(string.Format("錯誤訊息: {0}", ex.Message)); }
}
public bool IsReusable
{
get
{
return false;
}
}
}