private static SourcingLink PopulateFromDBDetailsObject(SourcingLinkDetails obj) { SourcingLink objNew = new SourcingLink(); objNew.SourcingLinkId = obj.SourcingLinkId; objNew.SourcingLinkName = obj.SourcingLinkName; objNew.URL = obj.URL; objNew.ClientNo = obj.ClientNo; objNew.UpdatedBy = obj.UpdatedBy; objNew.DLUP = obj.DLUP; return(objNew); }
/// <summary> /// Get /// Calls [usp_select_SourcingLink] /// </summary> public override SourcingLinkDetails Get(System.Int32?sourcingLinkId) { SqlConnection cn = null; SqlCommand cmd = null; try { cn = new SqlConnection(this.ConnectionString); cmd = new SqlCommand("usp_select_SourcingLink", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandTimeout = 30; cmd.Parameters.Add("@SourcingLinkId", SqlDbType.Int).Value = sourcingLinkId; cn.Open(); DbDataReader reader = ExecuteReader(cmd, CommandBehavior.SingleRow); if (reader.Read()) { //return GetSourcingLinkFromReader(reader); SourcingLinkDetails obj = new SourcingLinkDetails(); obj.SourcingLinkId = GetReaderValue_Int32(reader, "SourcingLinkId", 0); obj.SourcingLinkName = GetReaderValue_String(reader, "SourcingLinkName", ""); obj.URL = GetReaderValue_String(reader, "URL", ""); obj.ClientNo = GetReaderValue_Int32(reader, "ClientNo", 0); obj.UpdatedBy = GetReaderValue_NullableInt32(reader, "UpdatedBy", null); obj.DLUP = GetReaderValue_DateTime(reader, "DLUP", DateTime.MinValue); return(obj); } else { return(null); } } catch (SqlException sqlex) { //LogException(sqlex); throw new Exception("Failed to get SourcingLink", sqlex); } finally { cmd.Dispose(); cn.Close(); cn.Dispose(); } }
/// <summary> /// GetListForClient /// Calls [usp_selectAll_SourcingLink_for_Client] /// </summary> public override List <SourcingLinkDetails> GetListForClient(System.Int32?clientId) { SqlConnection cn = null; SqlCommand cmd = null; try { cn = new SqlConnection(this.ConnectionString); cmd = new SqlCommand("usp_selectAll_SourcingLink_for_Client", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandTimeout = 30; cmd.Parameters.Add("@ClientId", SqlDbType.Int).Value = clientId; cn.Open(); DbDataReader reader = ExecuteReader(cmd); List <SourcingLinkDetails> lst = new List <SourcingLinkDetails>(); while (reader.Read()) { SourcingLinkDetails obj = new SourcingLinkDetails(); obj.SourcingLinkId = GetReaderValue_Int32(reader, "SourcingLinkId", 0); obj.SourcingLinkName = GetReaderValue_String(reader, "SourcingLinkName", ""); obj.URL = GetReaderValue_String(reader, "URL", ""); obj.ClientNo = GetReaderValue_Int32(reader, "ClientNo", 0); obj.UpdatedBy = GetReaderValue_NullableInt32(reader, "UpdatedBy", null); obj.DLUP = GetReaderValue_DateTime(reader, "DLUP", DateTime.MinValue); lst.Add(obj); obj = null; } return(lst); } catch (SqlException sqlex) { //LogException(sqlex); throw new Exception("Failed to get SourcingLinks", sqlex); } finally { cmd.Dispose(); cn.Close(); cn.Dispose(); } }