//Path: /api/Contact/CreateContact public HttpResponseMessage CreateContact(ContactModel ContactModelRequest) { // Trace Log File.AppendAllText(SuiteWrapper.traceLogPath, Environment.NewLine + Environment.NewLine); SuiteWrapper.WriteTraceLog("Called 'MoveItem' with request :" + JsonConvert.SerializeObject(ContactModelRequest)); PushContactResponse pushContactResponse = new PushContactResponse(); try { using (PundolesEntities context = new PundolesEntities()) { contact contactObject = new contact(); contactObject.salutation = ContactModelRequest.salutation; contactObject.first_name = ContactModelRequest.first_name; contactObject.last_name = ContactModelRequest.last_name; contactObject.company_name = ContactModelRequest.company_name; contactObject.contact_type = ContactModelRequest.contact_type; contactObject.client_number = ContactModelRequest.client_number; contactObject.interest_id = ContactModelRequest.interest_id; contactObject.category_id = ContactModelRequest.category_id; contactObject.customer_category_id = ContactModelRequest.customer_category_id; contactObject.level_id = ContactModelRequest.level_id; contactObject.catalogue_id = ContactModelRequest.catalogue_id; contactObject.marital_status_id = ContactModelRequest.marital_status_id; contactObject.marriage_anniversary_date = ContactModelRequest.marriage_anniversary_date; contactObject.am_customer_id = ContactModelRequest.am_customer_id; contactObject.approval_status_id = ContactModelRequest.approval_status_id; contactObject.authorized_to_bid_id = ContactModelRequest.authorized_to_bid_id; contactObject.email = ContactModelRequest.email; contactObject.phone = ContactModelRequest.phone; contactObject.fax = ContactModelRequest.fax; contactObject.mobile = ContactModelRequest.mobile; contactObject.other_phone = ContactModelRequest.other_phone; contactObject.clients_vat_tin_no = ContactModelRequest.clients_vat_tin_no; contactObject.aadhar_number = ContactModelRequest.aadhar_number; contactObject.pan_no = ContactModelRequest.pan_no; contactObject.date_created = DateTime.Now; contactObject.date_modified = DateTime.Now; contactObject.createdby_id = ContactModelRequest.createdby_id; contactObject.modifiedby_id = ContactModelRequest.createdby_id; context.contacts.Add(contactObject); context.SaveChanges(); pushContactResponse.contactid = contactObject.contact_id; pushContactResponse.status = "Success"; SuiteWrapper.WriteTraceLog("Successfully called with response:" + JsonConvert.SerializeObject(pushContactResponse)); return(Request.CreateResponse(HttpStatusCode.OK, pushContactResponse)); } } catch (Exception ex) { pushContactResponse.contactid = null; pushContactResponse.status = ex.Message.ToString(); SuiteWrapper.WriteTraceLog("Exception while pushing data is : " + ex.Message.ToString()); return(Request.CreateResponse(HttpStatusCode.InternalServerError, JsonConvert.SerializeObject(pushContactResponse))); } }
//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))); } }
//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()));; } }
//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()));; } }