Ejemplo n.º 1
0
        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);
        }