Exemplo n.º 1
0
        public bool DeleteGroup(HomePageBlock item)
        {
            bool result = false;
            using (StoredProcedure sp = new StoredProcedure("HomePageBlocks_DeleteGroup"))
            {
                sp.Params.Add("@GroupID", System.Data.SqlDbType.Int).Value = item.GroupID;

                result = sp.ExecuteNonQuery() > 0;
            }
            return result;
        }
Exemplo n.º 2
0
        public virtual int Add(HomePageBlock item)
        {
            int newID = 0;
            using (StoredProcedure sp = new StoredProcedure("HomePageBlocks_AddItem"))
            {
                sp.Params.Add("@GroupID", System.Data.SqlDbType.Int).Value = item.GroupID;
                sp.Params.Add("@LangCode", System.Data.SqlDbType.NChar).Value = item.LangCode;
                sp.Params.Add("@ImageFile", System.Data.SqlDbType.VarBinary).Value = item.ImageFile;
                sp.Params.Add("@LinkUrl", System.Data.SqlDbType.NVarChar, 255).Value = Tools.FixUrl(item.LinkUrl);
                sp.Params.Add("@LinkText", System.Data.SqlDbType.NVarChar, 255).Value = item.LinkText;
                sp.Params.Add("@IsActive", System.Data.SqlDbType.Bit).Value = item.IsActive;
                sp.Params.Add("@OrderNumber", System.Data.SqlDbType.Int).Value = item.OrderNumber;

                newID = Convert.ToInt32(sp.ExecuteScalar());
            }
            return newID;
        }
Exemplo n.º 3
0
        public virtual List<HomePageBlock> GetAll(string langCode)
        {
            List<HomePageBlock> all = new List<HomePageBlock>();
            using (StoredProcedure sp = new StoredProcedure("HomePageBlocks_GetAll"))
            {
                sp.Params.Add("@LangCode", System.Data.SqlDbType.NChar).Value = langCode;
                using (SqlDataReader r = (SqlDataReader)sp.ExecuteReader())
                {
                    if (r != null)
                    {
                        while (r.Read())
                        {
                            HomePageBlock item = new HomePageBlock();

                            item.ID = Convert.ToInt32(r["ID"]);
                            item.GroupID = Convert.ToInt32(r["GroupID"]);
                            item.LangCode = Convert.ToString(r["LangCode"]);
                            item.LinkUrl = Convert.ToString(r["LinkUrl"]);
                            item.LinkText = Convert.ToString(r["LinkText"]);
                            item.OrderNumber = Convert.ToInt32(r["OrderNumber"]);
                            item.IsActive = Convert.ToBoolean(r["IsActive"]);
                            item.DateCreated = Convert.ToDateTime(r["DateCreated"]);

                            all.Add(item);
                        }
                    }
                }
            }
            return all;
        }
Exemplo n.º 4
0
        public virtual bool Update(HomePageBlock item)
        {
            bool result = false;
            using (StoredProcedure sp = new StoredProcedure("HomePageBlocks_UpdateItem"))
            {
                sp.Params.Add("@GroupID", System.Data.SqlDbType.Int).Value = item.GroupID;
                sp.Params.Add("@LangCode", System.Data.SqlDbType.NChar).Value = item.LangCode;
                sp.Params.Add("@LinkUrl", System.Data.SqlDbType.NVarChar, 255).Value = Tools.FixUrl(item.LinkUrl);
                sp.Params.Add("@LinkText", System.Data.SqlDbType.NVarChar, 255).Value = item.LinkText;
                sp.Params.Add("@IsActive", System.Data.SqlDbType.Bit).Value = item.IsActive;

                result = sp.ExecuteNonQuery() > 0;
            }
            return result;
        }
Exemplo n.º 5
0
        public virtual HomePageBlock GetByLangGroup(string language, int groupId)
        {
            HomePageBlock item = null;
            using (StoredProcedure sp = new StoredProcedure("HomePageBlocks_GetByLangGroup"))
            {
                sp.Params.Add("@GroupID", System.Data.SqlDbType.Int).Value = groupId;
                sp.Params.Add("@LangCode", System.Data.SqlDbType.NChar).Value = language;
                using (SqlDataReader r = (SqlDataReader)sp.ExecuteReader())
                {
                    if (r != null && r.Read())
                    {
                        item = new HomePageBlock();

                        item.ID = Convert.ToInt32(r["ID"]);
                        item.GroupID = Convert.ToInt32(r["GroupID"]);
                        item.LangCode = Convert.ToString(r["LangCode"]);
                        item.LinkUrl = Convert.ToString(r["LinkUrl"]);
                        item.LinkText = Convert.ToString(r["LinkText"]);
                        item.OrderNumber = Convert.ToInt32(r["OrderNumber"]);
                        item.IsActive = Convert.ToBoolean(r["IsActive"]);
                        item.HasImage = Convert.ToBoolean(r["HasImage"]);
                        item.DateCreated = Convert.ToDateTime(r["DateCreated"]);
                    }
                }
            }
            return item;
        }