public HttpResponseMessage PushSymbols(PushSymbols[] symbolsRequest) { // Trace Log File.AppendAllText(SuiteWrapper.traceLogPath, Environment.NewLine + Environment.NewLine); SuiteWrapper.WriteTraceLog("Called 'PushSymbols' with request :" + JsonConvert.SerializeObject(symbolsRequest)); var sessionId = "0"; // Validating string outputMessage = string.Empty; foreach (var data in symbolsRequest) { if (!SuiteWrapper.ValidateRequest(data, out outputMessage)) { //Trace Log SuiteWrapper.WriteTraceLog("Exception while validating request for " + JsonConvert.SerializeObject(data) + " is : " + outputMessage); return(Request.CreateResponse(HttpStatusCode.NotAcceptable, outputMessage));; } } try { sessionId = SuiteWrapper.Login().GetAwaiter().GetResult(); } catch (Exception ex) { SuiteWrapper.WriteTraceLog("Exception while generating session id is " + ex.ToString()); return(Request.CreateErrorResponse(HttpStatusCode.Unauthorized, ex.Message.ToString())); } try { var request = new AddUpdateMultipleEntriesRequest(); request.SessionId = sessionId; request.ModuleName = "Sym1_Symbols"; request.Entity = symbolsRequest; var response = SuiteWrapper.AddUpdateMultipleEntries(request).GetAwaiter().GetResult(); PushResponseforMultipleEntries <PushSymbols> pushResponse = new PushResponseforMultipleEntries <PushSymbols>(); var pushResponseResult = pushResponse.BuildResponse(sessionId, symbolsRequest, "Sym1_Symbols"); SuiteWrapper.WriteTraceLog("Successfully called with response:" + JsonConvert.SerializeObject(pushResponseResult)); return(Request.CreateResponse(HttpStatusCode.OK, pushResponseResult)); } catch (Exception ex) { SuiteWrapper.WriteTraceLog("Exception while Adding/updating the data is " + ex.ToString()); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message.ToString())); } }
public HttpResponseMessage PushArtists(PushArtist[] artistRequest) { // Trace Log File.AppendAllText(SuiteWrapper.traceLogPath, Environment.NewLine + Environment.NewLine); SuiteWrapper.WriteTraceLog("Called 'PushArtists' with request :" + JsonConvert.SerializeObject(artistRequest)); // Validating string outputMessage = string.Empty; foreach (var data in artistRequest) { if (!SuiteWrapper.ValidateRequest(data, out outputMessage)) { //Trace Log SuiteWrapper.WriteTraceLog("Exception while validating request for " + JsonConvert.SerializeObject(data) + " is : " + outputMessage); return(Request.CreateResponse(HttpStatusCode.NotAcceptable, outputMessage));; } } var sessionId = "0"; try { sessionId = SuiteWrapper.Login().GetAwaiter().GetResult(); } catch (Exception ex) { SuiteWrapper.WriteTraceLog("Exception while generating session id is " + ex.ToString()); return(Request.CreateErrorResponse(HttpStatusCode.Unauthorized, ex.Message.ToString())); } PushResponseforMultipleEntries <PushArtist> pushResponse = new PushResponseforMultipleEntries <PushArtist>(); var pushResponseResult = pushResponse.BuildResponse(sessionId, artistRequest, "A1_Artists"); SuiteWrapper.WriteTraceLog("Successfully called with response:" + JsonConvert.SerializeObject(pushResponseResult)); return(Request.CreateResponse(HttpStatusCode.OK, pushResponseResult)); }