public HttpResponseMessage UploadLotNumber(UploadLotNumber[] uploadLotNumberRequest) { // Trace Log File.AppendAllText(SuiteWrapper.traceLogPath, Environment.NewLine + Environment.NewLine); SuiteWrapper.WriteTraceLog("Called 'UploadLotNumber' with request :" + JsonConvert.SerializeObject(uploadLotNumberRequest)); var sessionId = "0"; string outputMessage = string.Empty; foreach (var data in uploadLotNumberRequest) { 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())); } PushResponseforMultipleEntries <UploadLotNumber> pushResponse = new PushResponseforMultipleEntries <UploadLotNumber>(); var pushResponseResult = pushResponse.BuildResponse(sessionId, uploadLotNumberRequest, "Itm1_Item"); SuiteWrapper.WriteTraceLog("Successfully called with response:" + JsonConvert.SerializeObject(pushResponseResult)); return(Request.CreateResponse(HttpStatusCode.OK, pushResponseResult)); }
//Path: /api/User/UpdateUser public HttpResponseMessage UpdateUser(UpdateUserModel updateUserModelRequest) { File.AppendAllText(SuiteWrapper.traceLogPath, Environment.NewLine + Environment.NewLine); SuiteWrapper.WriteTraceLog("Called 'UpdateUser' with request :" + JsonConvert.SerializeObject(updateUserModelRequest)); string outputMessage = string.Empty; if (!SuiteWrapper.ValidateRequest(updateUserModelRequest, out outputMessage)) { //Trace Log SuiteWrapper.WriteTraceLog("Exception while validating request for " + JsonConvert.SerializeObject(updateUserModelRequest) + " is : " + outputMessage); return(Request.CreateResponse(HttpStatusCode.NotAcceptable, outputMessage));; } try { using (PundolesEntities context = new PundolesEntities()) { var UpdEntity = context.users.AsNoTracking().FirstOrDefault(m => m.id == updateUserModelRequest.id); if (UpdEntity == null) { SuiteWrapper.WriteTraceLog("User doesn't exist."); return(Request.CreateResponse(HttpStatusCode.NotAcceptable, "User doesn't exist."));; } UpdEntity.user_name = updateUserModelRequest.user_name; if (!string.IsNullOrEmpty(updateUserModelRequest.user_hash)) { UpdEntity.user_hash = SuiteWrapper.CreateMD5(updateUserModelRequest.user_hash); } UpdEntity.first_name = updateUserModelRequest.first_name; UpdEntity.last_name = updateUserModelRequest.last_name; UpdEntity.phone_home = updateUserModelRequest.phone_home; UpdEntity.phone_mobile = updateUserModelRequest.phone_mobile; UpdEntity.department = updateUserModelRequest.department; UpdEntity.report_to_id = updateUserModelRequest.report_to_id; UpdEntity.primary_email = updateUserModelRequest.primary_email; UpdEntity.alternate_email = updateUserModelRequest.alternate_email; UpdEntity.user_type = updateUserModelRequest.user_type; UpdEntity.user_status = updateUserModelRequest.user_status; UpdEntity.modified_date = DateTime.Now; UpdEntity.modifiedby_id = updateUserModelRequest.modifiedby_id; context.Entry(UpdEntity).State = EntityState.Modified; context.SaveChanges(); SuiteWrapper.WriteTraceLog("User is Successfully updated."); return(Request.CreateResponse(HttpStatusCode.OK, "Success")); } } catch (Exception ex) { SuiteWrapper.WriteTraceLog("Exception while updating the contact is : " + ex.Message.ToString()); return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message.ToString()));; } }
//Path: /api/User/CreateUser public HttpResponseMessage CreateUser(CreateUserModel CreateUserModelRequest) { // Trace Log File.AppendAllText(SuiteWrapper.traceLogPath, Environment.NewLine + Environment.NewLine); SuiteWrapper.WriteTraceLog("Called 'CreateUser' with request :" + JsonConvert.SerializeObject(CreateUserModelRequest)); PushUserResponse pushUserResponse = new PushUserResponse(); string outputMessage = string.Empty; if (!SuiteWrapper.ValidateRequest(CreateUserModelRequest, out outputMessage)) { //Trace Log SuiteWrapper.WriteTraceLog("Exception while validating request for " + JsonConvert.SerializeObject(CreateUserModelRequest) + " is : " + outputMessage); return(Request.CreateResponse(HttpStatusCode.NotAcceptable, outputMessage));; } try { using (PundolesEntities context = new PundolesEntities()) { user userObject = new user(); userObject.user_name = CreateUserModelRequest.user_name; userObject.user_hash = SuiteWrapper.CreateMD5(CreateUserModelRequest.user_hash); userObject.first_name = CreateUserModelRequest.first_name; userObject.last_name = CreateUserModelRequest.last_name; userObject.phone_home = CreateUserModelRequest.phone_home; userObject.phone_mobile = CreateUserModelRequest.phone_mobile; userObject.department = CreateUserModelRequest.department; userObject.report_to_id = CreateUserModelRequest.report_to_id; userObject.primary_email = CreateUserModelRequest.primary_email; userObject.alternate_email = CreateUserModelRequest.alternate_email; userObject.user_type = CreateUserModelRequest.user_type; userObject.user_status = CreateUserModelRequest.user_status; userObject.created_date = DateTime.Now; userObject.modified_date = DateTime.Now; userObject.createdby_id = CreateUserModelRequest.createdby_id; userObject.modifiedby_id = CreateUserModelRequest.createdby_id; context.users.Add(userObject); context.SaveChanges(); pushUserResponse.id = userObject.id; pushUserResponse.status = "Success"; SuiteWrapper.WriteTraceLog("user is successfully created with response :" + JsonConvert.SerializeObject(pushUserResponse)); return(Request.CreateResponse(HttpStatusCode.OK, pushUserResponse)); } } catch (Exception ex) { pushUserResponse.id = null; pushUserResponse.status = ex.Message.ToString(); SuiteWrapper.WriteTraceLog("Exception while creating user is : " + ex.Message.ToString()); return(Request.CreateResponse(HttpStatusCode.InternalServerError, JsonConvert.SerializeObject(pushUserResponse))); } }
//Path: /api/Artist/CreateArtist public HttpResponseMessage CreateArtist(CreateArtist createArtistRequest) { // Trace Log File.AppendAllText(SuiteWrapper.traceLogPath, Environment.NewLine + Environment.NewLine); SuiteWrapper.WriteTraceLog("Called 'CreateArtist' with request :" + JsonConvert.SerializeObject(createArtistRequest)); CreateArtistResponse createArtistResponse = new CreateArtistResponse(); string outputMessage = string.Empty; if (!SuiteWrapper.ValidateRequest(createArtistRequest, out outputMessage)) { //Trace Log SuiteWrapper.WriteTraceLog("Exception while validating request for " + JsonConvert.SerializeObject(createArtistRequest) + " is : " + outputMessage); return(Request.CreateResponse(HttpStatusCode.NotAcceptable, outputMessage));; } try { using (PundolesEntities context = new PundolesEntities()) { artist artistObject = new artist(); artistObject.name = createArtistRequest.name; artistObject.description = createArtistRequest.description; artistObject.year_of_birth_c = createArtistRequest.year_of_birth_c; artistObject.year_of_death_c = createArtistRequest.year_of_death_c; artistObject.status = createArtistRequest.status; artistObject.created_date = DateTime.Now; artistObject.modified_date = DateTime.Now; artistObject.createdby_id = createArtistRequest.createdby_id; artistObject.modifiedby_id = createArtistRequest.createdby_id; context.artists.Add(artistObject); context.SaveChanges(); createArtistResponse.id = artistObject.id; createArtistResponse.status = "Success"; SuiteWrapper.WriteTraceLog("user is successfully created with response :" + JsonConvert.SerializeObject(createArtistResponse)); return(Request.CreateResponse(HttpStatusCode.OK, createArtistResponse)); } } catch (Exception ex) { createArtistResponse.id = null; createArtistResponse.status = ex.Message.ToString(); SuiteWrapper.WriteTraceLog("Exception while creating artist is : " + ex.Message.ToString()); return(Request.CreateResponse(HttpStatusCode.InternalServerError, JsonConvert.SerializeObject(createArtistResponse))); } }
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())); } }
//Path: /api/Artist/UpdateArtist public HttpResponseMessage UpdateArtist(UpdateArtist updateArtistRequest) { File.AppendAllText(SuiteWrapper.traceLogPath, Environment.NewLine + Environment.NewLine); SuiteWrapper.WriteTraceLog("Called 'UpdateArtist' with request :" + JsonConvert.SerializeObject(updateArtistRequest)); string outputMessage = string.Empty; if (!SuiteWrapper.ValidateRequest(updateArtistRequest, out outputMessage)) { //Trace Log SuiteWrapper.WriteTraceLog("Exception while validating request for " + JsonConvert.SerializeObject(updateArtistRequest) + " is : " + outputMessage); return(Request.CreateResponse(HttpStatusCode.NotAcceptable, outputMessage));; } try { using (PundolesEntities context = new PundolesEntities()) { var UpdEntity = context.artists.AsNoTracking().FirstOrDefault(m => m.id == updateArtistRequest.id); if (UpdEntity == null) { SuiteWrapper.WriteTraceLog("Artist doesn't exist."); return(Request.CreateResponse(HttpStatusCode.NotAcceptable, "Artist doesn't exist."));; } UpdEntity.name = updateArtistRequest.name; UpdEntity.description = updateArtistRequest.description; UpdEntity.year_of_birth_c = updateArtistRequest.year_of_birth_c; UpdEntity.year_of_death_c = updateArtistRequest.year_of_death_c; UpdEntity.status = updateArtistRequest.status; UpdEntity.modified_date = DateTime.Now; UpdEntity.modifiedby_id = updateArtistRequest.modifiedby_id; context.Entry(UpdEntity).State = EntityState.Modified; context.SaveChanges(); SuiteWrapper.WriteTraceLog("Artist is Successfully updated."); return(Request.CreateResponse(HttpStatusCode.OK, "Success")); } } catch (Exception ex) { SuiteWrapper.WriteTraceLog("Exception while updating the artist is : " + ex.Message.ToString()); return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message.ToString()));; } }
public HttpResponseMessage MoveItem(MoveItem moveItemRequest) { // Trace Log File.AppendAllText(SuiteWrapper.traceLogPath, Environment.NewLine + Environment.NewLine); SuiteWrapper.WriteTraceLog("Called 'MoveItem' with request :" + JsonConvert.SerializeObject(moveItemRequest)); var sessionId = "0"; string outputMessage = string.Empty; if (!SuiteWrapper.ValidateRequest(moveItemRequest, out outputMessage)) { //Trace Log SuiteWrapper.WriteTraceLog("Exception while validating request for " + JsonConvert.SerializeObject(moveItemRequest) + " 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())); } PushResponseforSingleEntry pushResponseforSingleEntry = new PushResponseforSingleEntry(); try { var req = new AddUpdateSingleEntryRequest(); req.SessionId = sessionId; req.ModuleName = "Itm1_Item"; req.Entity = moveItemRequest; var response = SuiteWrapper.AddUpdateSingleEntry(req).GetAwaiter().GetResult(); pushResponseforSingleEntry.Id = response.Id; pushResponseforSingleEntry.Status = "Success"; SuiteWrapper.WriteTraceLog("Successfully called with response:" + JsonConvert.SerializeObject(pushResponseforSingleEntry)); return(Request.CreateResponse(HttpStatusCode.OK, pushResponseforSingleEntry)); } catch (Exception ex) { pushResponseforSingleEntry.Id = null; pushResponseforSingleEntry.Status = ex.Message.ToString(); SuiteWrapper.WriteTraceLog("Exception while pushing data is : " + ex.Message.ToString()); return(Request.CreateResponse(HttpStatusCode.InternalServerError, pushResponseforSingleEntry)); } }
//Path: /api/Contact/UpdateContact public HttpResponseMessage UpdateContact(ContactModel contactRequest) { File.AppendAllText(SuiteWrapper.traceLogPath, Environment.NewLine + Environment.NewLine); SuiteWrapper.WriteTraceLog("Called 'UpdateContact' with request :" + JsonConvert.SerializeObject(contactRequest)); string outputMessage = string.Empty; if (!SuiteWrapper.ValidateRequest(contactRequest, out outputMessage)) { //Trace Log SuiteWrapper.WriteTraceLog("Exception while validating request for " + JsonConvert.SerializeObject(contactRequest) + " is : " + outputMessage); return(Request.CreateResponse(HttpStatusCode.NotAcceptable, outputMessage));; } try { using (PundolesEntities context = new PundolesEntities()) { var UpdEntity = context.contacts.AsNoTracking().FirstOrDefault(m => m.contact_id == contactRequest.contact_id); if (UpdEntity == null) { SuiteWrapper.WriteTraceLog("Contact doesn't exist."); return(Request.CreateResponse(HttpStatusCode.NotAcceptable, "Contact doesn't exist."));; } UpdEntity.salutation = contactRequest.salutation; UpdEntity.first_name = contactRequest.first_name; UpdEntity.last_name = contactRequest.last_name; UpdEntity.company_name = contactRequest.company_name; UpdEntity.contact_type = contactRequest.contact_type; UpdEntity.client_number = contactRequest.client_number; UpdEntity.interest_id = contactRequest.interest_id; UpdEntity.category_id = contactRequest.category_id; UpdEntity.customer_category_id = contactRequest.customer_category_id; UpdEntity.level_id = contactRequest.level_id; UpdEntity.catalogue_id = contactRequest.catalogue_id; UpdEntity.marital_status_id = contactRequest.marital_status_id; UpdEntity.marriage_anniversary_date = contactRequest.marriage_anniversary_date; UpdEntity.am_customer_id = contactRequest.am_customer_id; UpdEntity.approval_status_id = contactRequest.approval_status_id; UpdEntity.authorized_to_bid_id = contactRequest.authorized_to_bid_id; UpdEntity.email = contactRequest.email; UpdEntity.phone = contactRequest.phone; UpdEntity.fax = contactRequest.fax; UpdEntity.mobile = contactRequest.mobile; UpdEntity.other_phone = contactRequest.other_phone; UpdEntity.clients_vat_tin_no = contactRequest.clients_vat_tin_no; UpdEntity.aadhar_number = contactRequest.aadhar_number; UpdEntity.pan_no = contactRequest.pan_no; UpdEntity.date_modified = DateTime.Now; UpdEntity.modifiedby_id = contactRequest.modifiedby_id; context.Entry(UpdEntity).State = EntityState.Modified; context.SaveChanges(); SuiteWrapper.WriteTraceLog("Successfully called"); return(Request.CreateResponse(HttpStatusCode.OK, "Success")); } } catch (Exception ex) { SuiteWrapper.WriteTraceLog("Exception while updating the contact is : " + ex.Message.ToString()); return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message.ToString()));; } }