protected void Save()
        {
            using (FaqHelper fh = new FaqHelper(SiteID)) {
                var itm = fh.FaqItemGetByID(ItemGuid);

                if (itm == null || ItemGuid == Guid.Empty)
                {
                    ItemGuid          = Guid.NewGuid();
                    itm               = new carrot_FaqItem();
                    itm.FaqItemID     = ItemGuid;
                    itm.FaqCategoryID = CatGuid;
                }

                if (itm != null)
                {
                    itm.Caption  = txtCaption.Text;
                    itm.Answer   = reAnswer.Text;
                    itm.Question = reQuestion.Text;

                    itm.IsActive  = chkActive.Checked;
                    itm.ItemOrder = int.Parse(txtSort.Text);

                    fh.Save(itm);

                    ItemGuid = itm.FaqItemID;
                }
            }

            string filePath = CreateLink(ModuleName, string.Format("id={0}", ItemGuid));

            Response.Redirect(filePath);
        }
        public carrot_FaqItem FaqItemGetByID(Guid faqItemID)
        {
            carrot_FaqItem ff = (from f in db.carrot_FaqItems
                                 where f.FaqItemID == faqItemID
                                 select f).FirstOrDefault();

            return(ff);
        }
        public carrot_FaqItem Save(carrot_FaqItem item)
        {
            if (item.FaqItemID == Guid.Empty)
            {
                item.FaqItemID = Guid.NewGuid();
            }

            if (!db.carrot_FaqItems.Where(x => x.FaqItemID == item.FaqItemID).Any())
            {
                db.carrot_FaqItems.InsertOnSubmit(item);
            }

            db.SubmitChanges();

            return(item);
        }
Exemple #4
0
        public carrot_FaqItem FaqItemListPublicRandGetByFaqCategoryID(Guid faqCategoryID, Guid siteID)
        {
            Random rand = new Random();

            int toSkip = rand.Next(0, (from f in db.carrot_FaqItems
                                       join fc in db.carrot_FaqCategories on f.FaqCategoryID equals fc.FaqCategoryID
                                       where f.FaqCategoryID == faqCategoryID &&
                                       f.IsActive == true && fc.SiteID == siteID
                                       orderby f.ItemOrder
                                       select f).Count());

            carrot_FaqItem ff = (from f in db.carrot_FaqItems
                                 join fc in db.carrot_FaqCategories on f.FaqCategoryID equals fc.FaqCategoryID
                                 where f.FaqCategoryID == faqCategoryID &&
                                 f.IsActive == true && fc.SiteID == siteID
                                 orderby f.ItemOrder
                                 select f).Skip(toSkip).FirstOrDefault();

            return(ff);
        }
		public carrot_FaqItem Save(carrot_FaqItem item) {

			if (item.FaqItemID == Guid.Empty) {
				item.FaqItemID = Guid.NewGuid();
			}

			if (!db.carrot_FaqItems.Where(x => x.FaqItemID == item.FaqItemID).Any()) {
				db.carrot_FaqItems.InsertOnSubmit(item);
			}

			db.SubmitChanges();

			return item;
		}
Exemple #6
0
 partial void Deletecarrot_FaqItem(carrot_FaqItem instance);
Exemple #7
0
 partial void Updatecarrot_FaqItem(carrot_FaqItem instance);
Exemple #8
0
 partial void Insertcarrot_FaqItem(carrot_FaqItem instance);
Exemple #9
0
 private void detach_carrot_FaqItems(carrot_FaqItem entity)
 {
     this.SendPropertyChanging();
     entity.carrot_FaqCategory = null;
 }
 partial void Deletecarrot_FaqItem(carrot_FaqItem instance);
 partial void Updatecarrot_FaqItem(carrot_FaqItem instance);
 partial void Insertcarrot_FaqItem(carrot_FaqItem instance);
		private void detach_carrot_FaqItems(carrot_FaqItem entity)
		{
			this.SendPropertyChanging();
			entity.carrot_FaqCategory = null;
		}
        protected void Save()
        {
            using (FaqHelper fh = new FaqHelper(SiteID)) {

                var itm = fh.FaqItemGetByID(ItemGuid);

                if (itm == null || ItemGuid == Guid.Empty) {
                    ItemGuid = Guid.NewGuid();
                    itm = new carrot_FaqItem();
                    itm.FaqItemID = ItemGuid;
                    itm.FaqCategoryID = CatGuid;
                }

                if (itm != null) {
                    itm.Caption = txtCaption.Text;
                    itm.Answer = reAnswer.Text;
                    itm.Question = reQuestion.Text;

                    itm.IsActive = chkActive.Checked;
                    itm.ItemOrder = int.Parse(txtSort.Text);

                    fh.Save(itm);

                    ItemGuid = itm.FaqItemID;
                }

            }

            string filePath = CreateLink(ModuleName, string.Format("id={0}", ItemGuid));

            Response.Redirect(filePath);
        }