예제 #1
0
 public HttpResponseMessage InsertPO([FromBody]MobilePO MobilePO)
 {
     Logger.Debug("Inside JM Controller- InsertPO");
     Logger.Debug("Request: " + new JavaScriptSerializer().Serialize(MobilePO));
     MobilePO lResponse = new MobilePO();
     ErrorResponse error = new ErrorResponse();
     var response = new Dictionary<string, object>();
     try
     {
         string SessionID = Guid.Empty.ToString();
         if (Request.Headers != null)
         {
             SessionID = Request.Headers.LastOrDefault().Value.First();
             Logger.Debug("SessionID: " + SessionID.ToString());
             if (_IJMServer.ValidateUser(SessionID))
             {
                 int result = _IJMServer.InsertPO(MobilePO);
                 if (result > 0)
                 {
                     Logger.Debug("Response: No response In Body,Process is Success");
                     return Request.CreateResponse(HttpStatusCode.OK);
                 }
                 else
                 {
                     error.ErrorCode = HttpStatusCode.BadRequest;
                     error.ErrorMessage = "Failure";
                     response.Add("ErrorResponse", error);
                     return Request.CreateResponse(HttpStatusCode.BadRequest, response);
                 }
             }
             else
             {
                 error.ErrorCode = HttpStatusCode.Forbidden;
                 error.ErrorMessage = "Session has expired, please login again";
                 response.Add("ErrorResponse", error);
                 return Request.CreateResponse(HttpStatusCode.Forbidden, response);
             }
         }
         else
         {
             error.ErrorCode = HttpStatusCode.BadRequest;
             error.ErrorMessage = "Failure";
             response.Add("ErrorResponse", error);
             return Request.CreateResponse(HttpStatusCode.BadRequest, response);
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex.Message);
         error.ErrorCode = HttpStatusCode.InternalServerError;
         error.ErrorMessage = "Failure";
         response.Add("ErrorResponse", error);
         return Request.CreateResponse(HttpStatusCode.InternalServerError, response);
     }
 }
예제 #2
0
 public HttpResponseMessage GetPO([FromBody]MobilePO MobilePO)
 {
     Logger.Debug("Inside JM Controller- GetPO");
     Logger.Debug("Request: " + new JavaScriptSerializer().Serialize(MobilePO));
     MobilePO lResponse = new MobilePO();
     ErrorResponse error = new ErrorResponse();
     var response = new Dictionary<string, object>();
     try
     {
         string SessionID = Guid.Empty.ToString();
         if (Request.Headers != null)
         {
             SessionID = Request.Headers.LastOrDefault().Value.First();
             Logger.Debug("SessionID: " + SessionID.ToString());
             if (_IJMServer.ValidateUser(SessionID))
             {
                 lResponse = _IJMServer.GetPOs(MobilePO);
                 if (lResponse != null)
                 {
                     if (lResponse.POGUID != Guid.Empty)
                     {
                         Logger.Debug("Response: " + new JavaScriptSerializer().Serialize(lResponse));
                         response.Add("PO", lResponse);
                         return Request.CreateResponse(HttpStatusCode.OK, response);
                     }
                     else
                     {
                         Logger.Debug("Response: No PO Found");
                         error.ErrorCode = HttpStatusCode.BadRequest;
                         error.ErrorMessage = "No PO Found";
                         response.Add("ErrorResponse", error);
                         return Request.CreateResponse(HttpStatusCode.BadRequest, response);
                     }
                 }
                 else
                 {
                     error.ErrorCode = HttpStatusCode.BadRequest;
                     error.ErrorMessage = "Unable to get PO Detail";
                     response.Add("ErrorResponse", error);
                     return Request.CreateResponse(HttpStatusCode.BadRequest, response);
                 }
             }
             else
             {
                 error.ErrorCode = HttpStatusCode.Forbidden;
                 error.ErrorMessage = "Session has expired, please login again";
                 response.Add("ErrorResponse", error);
                 return Request.CreateResponse(HttpStatusCode.Forbidden, response);
             }
         }
         else
         {
             error.ErrorCode = HttpStatusCode.BadRequest;
             error.ErrorMessage = "Unable to get SessionID in Header";
             response.Add("ErrorResponse", error);
             return Request.CreateResponse(HttpStatusCode.BadRequest, response);
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex.Message);
         error.ErrorCode = HttpStatusCode.InternalServerError;
         error.ErrorMessage = "Failure";
         response.Add("ErrorResponse", error);
         return Request.CreateResponse(HttpStatusCode.InternalServerError, response);
     }
 }