public static Advert GetByid(int id)
    {
        // Read a row from Tab based on key value
        Advert        returnObject = new Advert();
        SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["TriadAdvertsConnectionString"].ToString());
        string        SPName       = "SearchResults_GetByid";
        SqlCommand    myCommand    = new SqlCommand(SPName, myConnection);

        myCommand.CommandType = CommandType.StoredProcedure;
        myCommand.Parameters.Add(DAL.getParameter("@id", id, SqlDbType.Int));

        try
        {
            myConnection.Open();
            SqlDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
            for (
                ; myReader.Read();
                )
            {
                returnObject = AdvertDB.toObject(myReader);
            }
            myReader.Close();
        }
        catch (Exception)
        {
            throw;
        }
        return(returnObject);
    }
    public static SearchResults GetLatest(int SearchType)
    {
        // Get the length of the Advert Spec to be displayed on results view
        int TrimLength = DAL.To_Integer(ConfigurationManager.AppSettings["Trimlength"]);


        // Read a row from Tab based on key value
        SearchResults returnObject = new SearchResults();
        SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["TriadAdvertsConnectionString"].ToString());
        string        SPName       = "SearchResults_GetLatest";
        SqlCommand    myCommand    = new SqlCommand(SPName, myConnection);

        myCommand.CommandType = CommandType.StoredProcedure;
        myCommand.Parameters.Add(DAL.getParameter("@JobType", SearchType, SqlDbType.Int));
        myCommand.Parameters.Add(DAL.getParameter("@TrimLength", TrimLength, SqlDbType.Int));
        try
        {
            myConnection.Open();
            SqlDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
            for (
                ; myReader.Read();
                )
            {
                returnObject.Add(AdvertDB.toObject(myReader));
            }
            myReader.Close();
        }
        catch (Exception)
        {
            throw;
        }
        return(returnObject);
    }
Beispiel #3
0
 public bool Update(Advert NewItem)
 {
     return(AdvertDB.Update(NewItem));
 }
Beispiel #4
0
 public bool Create(Advert NewItem)
 {
     return(AdvertDB.Create(NewItem));
 }
Beispiel #5
0
 public static bool Delete(int id)
 {
     return(AdvertDB.Delete(id));
 }
Beispiel #6
0
 public static Advert GetByid(int id)
 {
     return(AdvertDB.GetByid(id));
 }