//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/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()));; } }