Exemplo n.º 1
0
        public void UpdateImagesOrder(Tag tag, int startid, int endid)
        {
            bool isMovedDown = startid < endid ? true : false;
            int temp_start = startid < endid ? startid : endid;
            int temp_end = startid < endid ? endid : startid;

            var imageTagList = (from imgTag in DatabaseContext.ImageTags
                            where imgTag.Tag.TagId == tag.TagId
                            orderby imgTag.OrderNumber
                            select imgTag);

            foreach (Westgate.Data.ImageTag imgTag in imageTagList)
            {
                if (imgTag.OrderNumber == startid)
                {
                    imgTag.OrderNumber = endid;
                    continue;
                }
                if (isMovedDown)
                {
                    if (imgTag.OrderNumber > temp_start && imgTag.OrderNumber <= temp_end)
                        imgTag.OrderNumber--;
                }
                else
                {
                    if (imgTag.OrderNumber >= temp_start && imgTag.OrderNumber < temp_end)
                        imgTag.OrderNumber++;
                }
            }
            DatabaseContext.SaveChanges();
        }
Exemplo n.º 2
0
        private void SetImagesOrderNumber(Tag tag)
        {
            var imageTagList = (from imgTag in DatabaseContext.ImageTags
                                where imgTag.Tag.TagId == tag.TagId
                                orderby imgTag.OrderNumber
                                select imgTag);

            int orderNumber = 1;
            foreach (Westgate.Data.ImageTag imgTag in imageTagList)
            {
                imgTag.OrderNumber = orderNumber++;
            }
            DatabaseContext.SaveChanges();
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Tag allTag = new Tag
                {
                    TagId = 0,
                    Name = "All"
                };

                List<Tag> taglist = (from row in DatabaseContext.Tags where row.ShowInTabs orderby row.OrderNumber select row).ToList();
                taglist.Insert(0, allTag);

                Repeater2.DataSource = taglist;
                Repeater2.DataBind();
            }

            if (Request["tagId"] != null)
            {
                int tagId = int.Parse(Request["tagId"]);
                Tag tag = (from t in DatabaseContext.Tags
                           where t.TagId == tagId
                           select t).FirstOrDefault();

                SetGallery(tagId);

                if (Request["deleteID"] != null)
                {
                    int imageId = Int32.Parse(Request["deleteID"]);
                    Westgate.Data.Image img = (from image in DatabaseContext.Images
                                               where image.ImageId == imageId
                                               select image).FirstOrDefault();

                    var imageTag = (from imgTag in DatabaseContext.ImageTags
                                    where imgTag.ImageId == img.ImageId
                                    && imgTag.TagId == tagId
                                    select imgTag).FirstOrDefault();
                    DatabaseContext.ImageTags.DeleteObject(imageTag);
                    DatabaseContext.SaveChanges();
                    SetImagesOrderNumber(tag);
            //                    Response.Redirect("~/Admin/Gallery.aspx?tagId=" + tag.TagId);
                }

            }
            else
            {
                SetGallery();
            }
        }
Exemplo n.º 4
0
        protected void AddButton_Click(object sender, EventArgs e)
        {
            int orderNumber = 1;
            var preRecords = (from tag in DatabaseContext.Tags
                              select tag.OrderNumber).Max();
            if (preRecords.Value != null && preRecords.Value > 0)
            {
                orderNumber = preRecords.Value + 1;
            }

            Tag TagItem = new Tag
            {
                Name = NameText.Text,
                Description = DescriptionText.Text,
                ShowInTabs = RadioButtonYes.Checked,
                OrderNumber = orderNumber
            };

            DatabaseContext.AddToTags(TagItem);
            DatabaseContext.SaveChanges();
            Response.Redirect("~/Admin/AddTag.aspx?Save=true", false);
        }
Exemplo n.º 5
0
 private void SetTag(Tag tag)
 {
     if (!tag.IsEditable)
     {
         this.NameText.Enabled = false;
         this.RadioButtonYes.Enabled = false;
         this.RadioButtonNo.Enabled = false;
     }
 }
 /// <summary>
 /// Create a new Tag object.
 /// </summary>
 /// <param name="tagId">Initial value of the TagId property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="showInTabs">Initial value of the ShowInTabs property.</param>
 /// <param name="isEditable">Initial value of the IsEditable property.</param>
 public static Tag CreateTag(global::System.Int32 tagId, global::System.String name, global::System.Boolean showInTabs, global::System.Boolean isEditable)
 {
     Tag tag = new Tag();
     tag.TagId = tagId;
     tag.Name = name;
     tag.ShowInTabs = showInTabs;
     tag.IsEditable = isEditable;
     return tag;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Tags EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToTags(Tag tag)
 {
     base.AddObject("Tags", tag);
 }
Exemplo n.º 8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Tag allTag = new Tag
            {
                TagId = 0,
                Name = "All"
            };

            Tag galleryTag = new Tag
            {
                TagId = 3,
                Name = "Gallery"
            };

            WestgateEntities DatabaseContext = new WestgateEntities();
            List<Tag> taglistMain = (from row in DatabaseContext.Tags where row.ShowInTabs orderby row.OrderNumber select row).ToList();
            taglistMain.Insert(2, galleryTag);

            Repeater1.DataSource = taglistMain;
            Repeater1.DataBind();

            /*List<Tag> taglistMore = (from row in DatabaseContext.Tags where row.ShowInTabs orderby row.OrderNumber select row).ToList();
            if (taglistMore.Count>6)
            {
                div_repeatermore.Visible = true;
                for (int i = 0; i < 6; i++)
                {
                    taglistMore.RemoveAt(0);
                }

                RepeaterMore.DataSource = taglistMore;
                RepeaterMore.DataBind();
            }
            else
            {
                div_repeatermore.Visible = false;

            }
            */
            div_repeatermore.Visible = false;

            //            Repeater1.DataSource = (from row in DatabaseContext.Tags where row.ShowInTabs orderby row.OrderNumber select row).Take(7);
            //           Repeater1.DataBind();

            //List<Tag> taglist = (from row in DatabaseContext.Tags where row.ShowInTabs orderby row.OrderNumber select row).ToList();
            //taglist.Insert(0, allTag);

            //Repeater2.DataSource = taglist;
            //Repeater2.DataBind();

            if (!IsPostBack)
            {

                //TreeNode categoriesNode = new TreeNode("All");
                //categoriesNode.NavigateUrl = "javascript:onGalleryClick()";
                //categoriesNode.Expand();
                //List<Tag> listTags = (from t in DatabaseContext.Tags orderby t.Name select t).ToList();
                //foreach (Tag tag in listTags)
                //{
                //    TreeNode catNode = new TreeNode(tag.Name, tag.TagId.ToString());
                //    catNode.NavigateUrl = "javascript:onGalleryClick("+tag.TagId+")";
                //    catNode.CollapseAll();
                //    categoriesNode.ChildNodes.Add(catNode);
                //}
                //tvStructure.Nodes.Add(categoriesNode);
            }
        }