-
Notifications
You must be signed in to change notification settings - Fork 8
/
MaterialsAPIController.cs
106 lines (97 loc) · 3.71 KB
/
MaterialsAPIController.cs
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
using InventoryManagement.BAL;
using InventoryManagement.BAL.Common;
using System;
using System.Data;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.Http.Cors;
namespace InventoryManagement.API.Controllers
{
[EnableCors(origins: "*", headers: "*", methods: "*")]
public class MaterialsAPIController : ApiController
{
[System.Web.Http.HttpGet]
public HttpResponseMessage GetMaterials(long materialId = 0)
{
try
{
MaterialsBA objMaterialBA = new MaterialsBA();
DataSet ds = objMaterialBA.GetMaterials(materialId.CheckNull());
return Request.CreateResponse(HttpStatusCode.OK, ds.Tables[0]);
}
catch (Exception ex)
{
return Request.CreateResponse(HttpStatusCode.InternalServerError, new ErrorLogDetails() { Message = CommonMessages.DEFAULT_ERRORMESSAGE, StackTrace = ex.ToString() });
}
}
/// <summary>
/// Insert OR Update City Details
/// </summary>
/// <param name="objMaterialsBA"></param>
/// <returns></returns>
//[System.Web.Http.HttpPost]
[System.Web.Http.HttpPost]
public HttpResponseMessage InsertUpdateMaterial(MaterialsBA objMaterialsBA)//[FromBody] string test
{
try
{
int value = objMaterialsBA.InsertUpdateMaterial(objMaterialsBA);
return Request.CreateResponse(HttpStatusCode.OK, value);
}
catch (Exception ex)
{
return Request.CreateResponse(HttpStatusCode.InternalServerError, new ErrorLogDetails() { Message = CommonMessages.DEFAULT_ERRORMESSAGE, StackTrace = ex.ToString() });
}
}
/// <summary>
/// Delete City Details
/// </summary>
/// <param name="CityId"></param>
/// <returns></returns>
[System.Web.Http.HttpGet]
public HttpResponseMessage DeleteEmployee(long EmpId)
{
try
{
if (EmpId.CheckNull() > 0)
{
EmployeeBA objEmployeeBA = new EmployeeBA();
Int32 retValue = objEmployeeBA.DeleteEmployee(EmpId);
if (retValue == -3)
{
return Request.CreateResponse(HttpStatusCode.OK, 3);
}
else
{
return Request.CreateResponse(HttpStatusCode.OK, 1);
}
}
return Request.CreateResponse(HttpStatusCode.BadRequest, CommonMessages.InvalidInputMessage);
}
catch (Exception ex)
{
return Request.CreateResponse(HttpStatusCode.InternalServerError, new ErrorLogDetails() { Message = CommonMessages.DEFAULT_ERRORMESSAGE, StackTrace = ex.ToString() });
}
}
/// <summary>
/// check exist duplication of city
/// </summary>
/// <param name="objEmployeeBA"></param>
/// <returns></returns>
[HttpPost]
public HttpResponseMessage CheckExistEmployee(EmployeeBA objEmployeeBA)
{
try
{
objEmployeeBA.ReturnCode = 999;
int value = objEmployeeBA.InsertUpdateEmployee(objEmployeeBA);
return Request.CreateResponse(HttpStatusCode.OK, value);
}
catch (Exception ex)
{
return Request.CreateResponse(HttpStatusCode.InternalServerError, new ErrorLogDetails() { Message = CommonMessages.DEFAULT_ERRORMESSAGE, StackTrace = ex.ToString() });
}
}
}
}