}//end of GetAllSubBrandbyBrandId public SubBrand getOneSubBrandByRecordId(string inRecordId) { DbConnection dbConn = new DbConnection(); SubBrand subBrand = new SubBrand(); dbConn.Cmd.CommandText = "SELECT SubBrandID, SubBrandName, Description, CreatedAt, UpdatedAt, BrandID, SubBrandVideoID " + " FROM SubBrand where SubBrandID = @inSubBrandID and DeletedAt is null"; dbConn.Cmd.Parameters.Add("@inSubBrandId", SqlDbType.Int).Value = inRecordId; try { dbConn.Fill(); DataRow dr = dbConn.Dt.Rows[0]; subBrand.SubBrandID = Int32.Parse(dr["SubBrandID"].ToString()); subBrand.SubBrandName = dr["SubBrandName"].ToString(); subBrand.Description = dr["Description"].ToString(); subBrand.CreatedAt = DateTime.Parse(dr["CreatedAt"].ToString()); subBrand.UpdatedAt = DateTime.Parse(dr["UpdatedAt"].ToString()); subBrand.BrandID = Int32.Parse(dr["BrandID"].ToString()); subBrand.SubBrandVideoID = Int32.Parse(dr["SubBrandVideoID"].ToString()); }//end of try block catch (SqlException ex) { } return(subBrand); }//end of getOneSubBrandByRecordId
public List <SubBrand> GetAllSubBrandbyBrandId(string BrandId) { DbConnection dbConn = new DbConnection(); List <SubBrand> subBrandList = new List <SubBrand>(); dbConn.Cmd.CommandText = " SELECT SubBrandID, SubBrandName, Description, SubBrandVideoID, CreatedAt, UpdatedAt, BrandID FROM SubBrand where BrandID = @inBrandId AND DeletedAt IS NULL"; dbConn.Cmd.Parameters.Add("@inBrandId", SqlDbType.Int).Value = BrandId; dbConn.Fill(); try { foreach (DataRow dr in dbConn.Dt.Rows) { SubBrand subbrand = new SubBrand { SubBrandID = Int32.Parse(dr["SubBrandID"].ToString()), SubBrandName = dr["SubBrandName"].ToString(), Description = dr["Description"].ToString(), SubBrandVideoID = Int32.Parse(dr["SubBrandVideoID"].ToString()), //Int32.TryParse(dr["SubBrandVideoID"].ToString() CreatedAt = DateTime.Parse(dr["CreatedAt"].ToString()), UpdatedAt = DateTime.Parse(dr["UpdatedAt"].ToString()), BrandID = Int32.Parse(dr["BrandID"].ToString()) }; subBrandList.Add(subbrand); } } catch (SqlException ex) { } return(subBrandList); }//end of GetAllSubBrandbyBrandId
}//end of getOneSubBrandByRecordId public object addOneSubBrand(string inSubBrandName, string inDescription, string inVideoLink, string inBrandID) { DbConnection dbConn = new DbConnection(); SubBrand subBrand = new SubBrand(); int subBrandID = 0; object subBrandIDAndValidationMsg = new object(); dbConn.Cmd.CommandText = " INSERT into subbrand" + " (subbrandname,Description,BrandID) " + " OUTPUT inserted.SubBrandID " + " values " + " (@inSubBrandName,@inDescription,@inBrandID) "; dbConn.Cmd.Parameters.Add("@inSubBrandName", SqlDbType.VarChar, 50).Value = inSubBrandName; dbConn.Cmd.Parameters.Add("@inDescription", SqlDbType.VarChar, 3000).Value = inDescription; dbConn.Cmd.Parameters.Add("@inBrandID", SqlDbType.Int).Value = inBrandID; try { dbConn.Conn.Open(); subBrandID = Int32.Parse(dbConn.Cmd.ExecuteScalar().ToString()); dbConn.Cmd.CommandText = "INSERT into subbrandvideo (SubBrandVideoLink,subBrandID) " + " values " + " (@inSubBrandVideoLink,@insubBrandID) "; dbConn.Cmd.Parameters.Add("@inSubBrandVideoLink", SqlDbType.VarChar, 50).Value = inVideoLink; dbConn.Cmd.Parameters.Add("@insubBrandID", SqlDbType.VarChar, 3000).Value = subBrandID; dbConn.Conn.Close(); subBrandIDAndValidationMsg = new { collectedSubBrandID = subBrandID, uniqueConstraint = false }; } catch (SqlException ex) { if (ex.Message.Contains("SubBrandNameUniqueConstraint") == true) { subBrandIDAndValidationMsg = new { collectedSubBrandID = subBrandID, uniqueConstraint = true }; } } return(subBrandIDAndValidationMsg); }
}//end of GetOneSubBrandWVideoLinkByRecordId public List <SubBrand> GetAllSubBrandByBrandRecordIDAndSearchTxt(string inSearchTxt, string brandId) { DbConnection dbConn = new DbConnection(); List <SubBrand> subBrandList = new List <SubBrand>(); dbConn.Cmd.CommandText = " SELECT SubBrandID, SubBrandName, Description, CreatedAt, UpdatedAt, BrandID, SubBrandVideoID " + " FROM SubBrand where brandID = @inBrandId AND DeletedAt IS NULL " + " AND (subbrandname like @inSearchTxt or Description like @inSearchTxt) "; dbConn.Cmd.Parameters.Add("@inSearchTxt", SqlDbType.VarChar, 100).Value = "%" + inSearchTxt + "%"; dbConn.Cmd.Parameters.Add("@inBrandId", SqlDbType.Int).Value = brandId; dbConn.Fill(); try { foreach (DataRow dr in dbConn.Dt.Rows) { SubBrand subbrand = new SubBrand { SubBrandID = Int32.Parse(dr["SubBrandID"].ToString()), SubBrandName = dr["SubBrandName"].ToString(), Description = dr["Description"].ToString(), SubBrandVideoID = Int32.Parse(dr["SubBrandVideoID"].ToString()), //Int32.TryParse(dr["SubBrandVideoID"].ToString() CreatedAt = DateTime.Parse(dr["CreatedAt"].ToString()), UpdatedAt = DateTime.Parse(dr["UpdatedAt"].ToString()), BrandID = Int32.Parse(dr["BrandID"].ToString()) }; subBrandList.Add(subbrand); } } catch (SqlException ex) { } return(subBrandList); }//end of GetAllSubBrandWithVideoLinkBySearchTxt