markus / KCOM_API / MarkusService.svc.cs @ a5e5fff6
이력 | 보기 | 이력해설 | 다운로드 (3.55 KB)
1 | cf1cc862 | taeseongkim | using KCOMDataModel.DataModel; |
---|---|---|---|
2 | using System; |
||
3 | c517099d | taeseongkim | using System.Collections.Generic; |
4 | cf1cc862 | taeseongkim | using System.Configuration; |
5 | c517099d | taeseongkim | using System.Linq; |
6 | using System.Runtime.Serialization; |
||
7 | using System.ServiceModel; |
||
8 | using System.ServiceModel.Activation; |
||
9 | using System.ServiceModel.Web; |
||
10 | using System.Text; |
||
11 | |||
12 | namespace KCOM_API |
||
13 | { |
||
14 | [ServiceContract(Namespace = "")] |
||
15 | [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] |
||
16 | public class MarkusService : System.Web.Services.WebService |
||
17 | { |
||
18 | cf1cc862 | taeseongkim | [WebGet(UriTemplate = "AddMember?UserId={UserId}&Name={Name}&Company={Company}&Department={Department}&Position={Position}&email={email}", BodyStyle = WebMessageBodyStyle.Wrapped, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)] |
19 | c517099d | taeseongkim | [OperationContract] |
20 | cf1cc862 | taeseongkim | public AddMemberResults AddMember(string UserId,string Name, string Company, string Department,string Position,string email) |
21 | c517099d | taeseongkim | { |
22 | cf1cc862 | taeseongkim | AddMemberResults results = new AddMemberResults(false,null); |
23 | |||
24 | try |
||
25 | { |
||
26 | string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
||
27 | using (CIEntities _ci = new CIEntities(sCIConnString)) |
||
28 | { |
||
29 | if (_ci.MEMBER.Count(x => x.ID == UserId) == 0) |
||
30 | { |
||
31 | _ci.AddToMEMBER(new MEMBER |
||
32 | { |
||
33 | ID = UserId, |
||
34 | NAME = Name, |
||
35 | COMPANY = Company, |
||
36 | DEPARTMENT = Department, |
||
37 | POSITION = Position, |
||
38 | EMAIL_ADDRESS = email, |
||
39 | MODIFIED_DATETIME = DateTime.Now, |
||
40 | CREATE_DATETIME = DateTime.Now |
||
41 | }); |
||
42 | |||
43 | _ci.SaveChanges(); |
||
44 | |||
45 | results.IsSuccess = true; |
||
46 | } |
||
47 | else |
||
48 | { |
||
49 | results.Message = "User already exists."; |
||
50 | } |
||
51 | } |
||
52 | } |
||
53 | catch (Exception ex) |
||
54 | { |
||
55 | results.Message = "system Error"; |
||
56 | } |
||
57 | finally |
||
58 | { |
||
59 | |||
60 | } |
||
61 | |||
62 | return results; |
||
63 | c517099d | taeseongkim | } |
64 | |||
65 | cf1cc862 | taeseongkim | [WebInvoke(UriTemplate = "GetMembers",Method ="POST", BodyStyle = WebMessageBodyStyle.Wrapped, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)] |
66 | c517099d | taeseongkim | [OperationContract] |
67 | cf1cc862 | taeseongkim | public GetMembersResults GetMembers() |
68 | c517099d | taeseongkim | { |
69 | cf1cc862 | taeseongkim | GetMembersResults results = new GetMembersResults(); |
70 | c517099d | taeseongkim | |
71 | cf1cc862 | taeseongkim | try |
72 | c517099d | taeseongkim | { |
73 | cf1cc862 | taeseongkim | string sCIConnString = ConfigurationManager.ConnectionStrings["CIConnectionString"].ConnectionString; |
74 | using (CIEntities _ci = new CIEntities(sCIConnString)) |
||
75 | c517099d | taeseongkim | { |
76 | cf1cc862 | taeseongkim | if (_ci.MEMBER.Count() > 0) |
77 | { |
||
78 | results.Members = _ci.MEMBER.Select(m => new Member |
||
79 | { |
||
80 | ID = m.ID, |
||
81 | NAME = m.NAME, |
||
82 | COMPANY = m.COMPANY, |
||
83 | DEPARTMENT = m.DEPARTMENT, |
||
84 | POSITION = m.POSITION, |
||
85 | EMAIL_ADDRESS = m.EMAIL_ADDRESS |
||
86 | }).ToArray(); |
||
87 | } |
||
88 | c517099d | taeseongkim | } |
89 | cf1cc862 | taeseongkim | } |
90 | catch (Exception ex) |
||
91 | { |
||
92 | } |
||
93 | finally |
||
94 | { |
||
95 | c517099d | taeseongkim | |
96 | cf1cc862 | taeseongkim | } |
97 | c517099d | taeseongkim | |
98 | cf1cc862 | taeseongkim | return results; |
99 | } |
||
100 | c517099d | taeseongkim | } |
101 | } |