public ServerResponse.ResponseCodes EditJob(out Guid gJobGuid, Guid guid, Job oJob) { ServerResponse.ResponseCodes eResponse = ServerResponse.ResponseCodes.Internal_Error; gJobGuid = Guid.Empty; try { using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DemoVideoBurstConnection"].ConnectionString)) { using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = conn; cmd.CommandType = CommandType.Text; cmd.CommandText = @"Update [tblJobs] set [title]= @Title,[callback]=@CallBack,[clickurl]=@ClickUrl,[templateguid]=@templateguid where guid=@jobguid IF(@@ROWCOUNT>0) BEGIN SELECT [guid] FROM [tblJobs] WHERE guid=@jobguid END "; cmd.Parameters.AddWithValue("@Title", oJob.title); cmd.Parameters.AddWithValue("@CallBack", oJob.callback.ToString()); cmd.Parameters.AddWithValue("@ClickUrl", oJob.clickurl); cmd.Parameters.AddWithValue("@templateguid", oJob.templateguid); cmd.Parameters.AddWithValue("@jobguid", guid); conn.Open(); object oReturnValue = cmd.ExecuteScalar(); JobElementsBL oJobElementsBL = new JobElementsBL(); // Newly Added Code if (oReturnValue != null && !String.IsNullOrEmpty(Convert.ToString(oReturnValue)) && oJobElementsBL.EditJobElements(oJob.elements, guid)) { gJobGuid = new Guid(Convert.ToString(oReturnValue)); eResponse = ServerResponse.ResponseCodes.Success; } else { eResponse = ServerResponse.ResponseCodes.DatabaseInsertionError; } } } } catch (Exception ex) { eResponse = ServerResponse.ResponseCodes.Internal_Error; } return(eResponse); }
public ServerResponse.ResponseCodes AddJob(out Guid gJobGuid, Job oJob) { ServerResponse.ResponseCodes eResponse = ServerResponse.ResponseCodes.Internal_Error; gJobGuid = Guid.Empty; try { using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DemoVideoBurstConnection"].ConnectionString)) { using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = conn; cmd.CommandType = CommandType.Text; cmd.CommandText = @"INSERT INTO [tblJobs] ( [title],[callback],[clickurl],[callbackformat],[templateguid],[companyid],[createdby]) VALUES (@Title, @CallBack, @ClickUrl, 'JSON', @templateguid, 817, 10721) IF(@@ROWCOUNT>0) BEGIN SELECT [guid] FROM [tblJobs] WHERE id=SCOPE_IDENTITY() END "; cmd.Parameters.AddWithValue("@Title", oJob.title); cmd.Parameters.AddWithValue("@CallBack", oJob.callback.ToString()); cmd.Parameters.AddWithValue("@ClickUrl", oJob.clickurl); cmd.Parameters.AddWithValue("@templateguid", oJob.templateguid); conn.Open(); object oReturnValue = cmd.ExecuteScalar(); JobElementsBL oJobElementsBL = new JobElementsBL(); // Newly Added Code if (oReturnValue != null && !String.IsNullOrEmpty(Convert.ToString(oReturnValue)) && oJobElementsBL.AddJobElements(oJob.elements, oJob.templateguid, new Guid(oReturnValue.ToString()))) { //oJobElementsBL.AddJobElements(oJob.elements, oJob.templateguid, new Guid(oReturnValue.ToString())); gJobGuid = new Guid(Convert.ToString(oReturnValue)); eResponse = ServerResponse.ResponseCodes.Success; } else { eResponse = ServerResponse.ResponseCodes.DatabaseInsertionError; } //Previous Code //if (oReturnValue != null // && !String.IsNullOrEmpty(Convert.ToString(oReturnValue)) // && oJobElementsBL.EditJobElements(oJob.elements, new Guid(oReturnValue.ToString()))) //{ // gJobGuid = new Guid(Convert.ToString(oReturnValue)); // eResponse = ServerResponse.ResponseCodes.Success; // ServerResponse.ResponseCodes eResponseCode = GetJobByJobGuid(out oJob, null, lUserId, gJobGuid); // //Add Stats // if (oStats != null && oStats.contentid == null) // { // if (eResponseCode == ServerResponse.ResponseCodes.Success && oJob != null) // oStats.contentid = oJob.id; // } //} //else //{ // eResponse = ServerResponse.ResponseCodes.DatabaseInsertionError; // if (oStats != null && oStats.details != null) // { // oStats.details.message = "Failed to add the job."; // } //} } } } catch (Exception ex) { } return(eResponse); }