Exemple #1
0
        public static void Update(Gallery obj)
        {
            GalleryDataMapper objCaller = new GalleryDataMapper();

            objCaller.Update(obj);
        }
Exemple #2
0
 public void PopulateGallery(SqlDataReader _dtr, Gallery obj)
 {
     int columnIndex = 0;
     columnIndex = _dtr.GetOrdinal(GalleryDataMapper.CN_ID);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.ID = _dtr.GetInt32((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(GalleryDataMapper.CN_NAME);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.Name = _dtr.GetString((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(GalleryDataMapper.CN_DESCRIPTION);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.Description = _dtr.GetString((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(GalleryDataMapper.CN_TAGS);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.Tags = _dtr.GetString((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(GalleryDataMapper.CN_DATE);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.Date = _dtr.GetString((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(GalleryDataMapper.CN_URL);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.Url = _dtr.GetString((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(GalleryDataMapper.CN_TYPE);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.Type = (RootEnums.GalleryType)_dtr.GetInt32((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(GalleryDataMapper.CN_PATH);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.Path = _dtr.GetString((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(GalleryDataMapper.CN_CREATEDBY);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.CreatedBy = _dtr.GetInt32((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(GalleryDataMapper.CN_ISDELETED);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.IsDeleted = _dtr.GetBoolean((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(GalleryDataMapper.CN_ISARCHIEVED);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.IsArchieved = _dtr.GetBoolean((columnIndex));
     }
     columnIndex = _dtr.GetOrdinal(GalleryDataMapper.CN_CATEGORYID);
     if (!_dtr.IsDBNull(columnIndex))
     {
         obj.CategoryID = _dtr.GetInt32((columnIndex));
     }
 }
        public int Add(Gallery obj)
        {
            _connection.ConnectionString = _ConnectionString;
            _command.Connection = _connection;
            _command.CommandType = CommandType.StoredProcedure;
            _command.CommandText = INSERTGallery;

            #region [Parameters]
            SqlParameter parameterID = new SqlParameter(PN_ID, SqlDbType.Int);
            parameterID.Value = obj.ID;
            parameterID.Direction = ParameterDirection.Output;
            _command.Parameters.Add(parameterID);
            SqlParameter parameterName = new SqlParameter(PN_NAME, SqlDbType.NVarChar);
            parameterName.Value = obj.Name;
            parameterName.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterName);
            SqlParameter parameterDescription = new SqlParameter(PN_DESCRIPTION, SqlDbType.NVarChar);
            parameterDescription.Value = obj.Description;
            parameterDescription.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterDescription);
            SqlParameter parameterTags = new SqlParameter(PN_TAGS, SqlDbType.NVarChar);
            parameterTags.Value = obj.Tags;
            parameterTags.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterTags);
            SqlParameter parameterDate = new SqlParameter(PN_DATE, SqlDbType.NVarChar);
            parameterDate.Value = obj.Date;
            parameterDate.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterDate);
            SqlParameter parameterUrl = new SqlParameter(PN_URL, SqlDbType.NVarChar);
            parameterUrl.Value = obj.Url;
            parameterUrl.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterUrl);
            SqlParameter parameterType = new SqlParameter(PN_TYPE, SqlDbType.Int);
            parameterType.Value = obj.Type;
            parameterType.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterType);
            SqlParameter parameterPath = new SqlParameter(PN_PATH, SqlDbType.NVarChar);
            parameterPath.Value = obj.Path;
            parameterPath.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterPath);
            SqlParameter parameterCreatedBy = new SqlParameter(PN_CREATEDBY, SqlDbType.Int);
            parameterCreatedBy.Value = obj.CreatedBy;
            parameterCreatedBy.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterCreatedBy);
            SqlParameter parameterIsDeleted = new SqlParameter(PN_ISDELETED, SqlDbType.Int);
            parameterIsDeleted.Value = obj.IsDeleted;
            parameterIsDeleted.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterIsDeleted);
            SqlParameter parameterIsArchieved = new SqlParameter(PN_ISARCHIEVED, SqlDbType.Int);
            parameterIsArchieved.Value = obj.IsArchieved;
            parameterIsArchieved.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterIsArchieved);
            SqlParameter parameterCategoryID = new SqlParameter(PN_CATEGORYID, SqlDbType.Int);
            parameterCategoryID.Value = obj.CategoryID;
            parameterCategoryID.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterCategoryID);
            #endregion;

            _connection.Open();
            _command.ExecuteNonQuery();
            _connection.Close();
            obj.ID = Convert.ToInt32(parameterID.Value);
            return obj.ID;
        }
Exemple #4
0
        public static int Add(Gallery obj)
        {
            GalleryDataMapper objCaller = new GalleryDataMapper();

            return objCaller.Add(obj);
        }
        public IList<Gallery> GetAllGalleryByCategoryPages(int categoryID, int from, int to, ref int totalRows)
        {

            Gallery obj = null;

            IList<Gallery> colobj = new List<Gallery>();
            _connection.ConnectionString = _ConnectionString;
            _command.Connection = _connection;
            _command.CommandType = CommandType.StoredProcedure;
            _command.CommandText = "[usp_SelectGalleriesPaged]";

            #region [Parameters]
            SqlParameter parameterID = new SqlParameter(PN_CATEGORYID, SqlDbType.Int);
            parameterID.Value = categoryID;
            parameterID.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterID);

            SqlParameter pFrom = new SqlParameter("@From", SqlDbType.Int);
            pFrom.Value = from;
            pFrom.Direction = ParameterDirection.Input;
            _command.Parameters.Add(pFrom);

            SqlParameter pTo = new SqlParameter("@To", SqlDbType.Int);
            pTo.Value = to;
            pTo.Direction = ParameterDirection.Input;
            _command.Parameters.Add(pTo);

            SqlParameter ptotal = new SqlParameter("@TotalRows", SqlDbType.Int);
            ptotal.Value = totalRows;
            ptotal.Direction = ParameterDirection.Output;
            _command.Parameters.Add(ptotal);
            #endregion;

            _connection.Open();
            try
            {
                using (_dtreader = _command.ExecuteReader())
                {
                    if (_dtreader != null && _dtreader.HasRows)
                    {
                        obj = new Gallery();
                        colobj = new List<Gallery>();
                        while (_dtreader.Read())
                        {
                            obj = GetGallery(_dtreader, colobj);
                            GetEntityFromReader(_dtreader, obj);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                totalRows = Convert.ToInt32(ptotal.Value);
                _dtreader.Close();
                _connection.Close();
            }

            return colobj;
        }
 public Gallery GetGallery(SqlDataReader _dtr, IList<Gallery> colobj)
 {
     Gallery obj = colobj.Where(t => t.ID == Convert.ToInt32(_dtr[CN_ID].ToString())).SingleOrDefault();
     if (null == obj)
     {
         obj = new Gallery();
         colobj.Add(obj);
     }
     return obj;
 }
        public IList<Gallery> GetbyCategory(int categoryID)
        {

            Gallery obj = null;

            IList<Gallery> colobj = new List<Gallery>();
            _connection.ConnectionString = _ConnectionString;
            _command.Connection = _connection;
            _command.CommandType = CommandType.StoredProcedure;
            _command.CommandText = "usp_SelectGalleriesByCategoryID";

            #region [Parameters]
            SqlParameter parameterID = new SqlParameter(PN_CATEGORYID, SqlDbType.Int);
            parameterID.Value = categoryID;
            parameterID.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterID);
            #endregion;

            _connection.Open();
            try
            {
                using (_dtreader = _command.ExecuteReader())
                {
                    if (_dtreader != null && _dtreader.HasRows)
                    {
                        obj = new Gallery();
                        colobj = new List<Gallery>();
                        while (_dtreader.Read())
                        {
                            obj = GetGallery(_dtreader, colobj);
                            GetEntityFromReader(_dtreader, obj);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {

                _dtreader.Close();
                _connection.Close();
            }

            return colobj;
        }
        public IList<Gallery> SearchPaging(int from, int to, ref int totalRows, string keyword)
        {

            Gallery obj = null;

            IList<Gallery> colobj = new List<Gallery>();
            _connection.ConnectionString = _ConnectionString;
            _command.Connection = _connection;
            _command.CommandType = CommandType.StoredProcedure;
            _command.CommandText = "SearchGalleryPaging";

            #region "Paramters"
            SqlParameter pTotalRows = new SqlParameter("TotalRows", SqlDbType.Int);
            pTotalRows.Value = totalRows;
            pTotalRows.Direction = ParameterDirection.Output;
            _command.Parameters.Add(pTotalRows);

            SqlParameter pFrom = new SqlParameter("From", SqlDbType.Int);
            pFrom.Value = from;
            pFrom.Direction = ParameterDirection.Input;
            _command.Parameters.Add(pFrom);

            SqlParameter pTo = new SqlParameter("To", SqlDbType.Int);
            pTo.Value = to;
            pTo.Direction = ParameterDirection.Input;
            _command.Parameters.Add(pTo);

            SqlParameter pKeyword = new SqlParameter("Keyword", SqlDbType.NVarChar);
            pKeyword.Value = keyword;
            pKeyword.Direction = ParameterDirection.Input;
            _command.Parameters.Add(pKeyword);
            #endregion

            _connection.Open();
            try
            {
                using (_dtreader = _command.ExecuteReader())
                {
                    if (_dtreader != null && _dtreader.HasRows)
                    {
                        obj = new Gallery();
                        colobj = new List<Gallery>();
                        while (_dtreader.Read())
                        {
                            obj = GetGallery(_dtreader, colobj);
                            GetEntityFromReader(_dtreader, obj);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {

                _dtreader.Close();
                _connection.Close();
            }

            return colobj;
        }
        public IList<Gallery> GetAll()
        {

            Gallery obj = null;

            IList<Gallery> colobj = new List<Gallery>();
            _connection.ConnectionString = _ConnectionString;
            _command.Connection = _connection;
            _command.CommandType = CommandType.StoredProcedure;
            _command.CommandText = SELECTALLGallery;

            _connection.Open();
            try
            {
                using (_dtreader = _command.ExecuteReader())
                {
                    if (_dtreader != null && _dtreader.HasRows)
                    {
                        obj = new Gallery();
                        colobj = new List<Gallery>();
                        while (_dtreader.Read())
                        {
                            obj = GetGallery(_dtreader, colobj);
                            GetEntityFromReader(_dtreader, obj);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {

                _dtreader.Close();
                _connection.Close();
            }

            return colobj;
        }
Exemple #10
0
 private void GetEntityFromReader(SqlDataReader _dtr, Gallery obj)
 {
     PopulateGallery(_dtr, obj);
 }
Exemple #11
0
        public Gallery GetByID(int ID)
        {

            Gallery obj = null;
            _connection.ConnectionString = _ConnectionString;
            _command.Connection = _connection;
            _command.CommandType = CommandType.StoredProcedure;
            _command.CommandText = SELECTGallery;

            #region [Parameters]
            SqlParameter parameterID = new SqlParameter(PN_ID, SqlDbType.Int);
            parameterID.Value = ID;
            parameterID.Direction = ParameterDirection.Input;
            _command.Parameters.Add(parameterID);
            #endregion;

            _connection.Open();
            try
            {
                using (_dtreader = _command.ExecuteReader())
                {
                    if (_dtreader != null && _dtreader.HasRows)
                    {
                        obj = new Gallery();
                        if (_dtreader.Read())
                            GetEntityFromReader(_dtreader, obj);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {

                _dtreader.Close();
                _connection.Close();
            }

            return obj;
        }