Esempio n. 1
0
        public ActionResult EditFaqItem(carrot_FaqItem model)
        {
            if (ModelState.IsValid)
            {
                using (FaqHelper fh = new FaqHelper(this.SiteID)) {
                    var fc = fh.FaqItemGetByID(model.FaqItemID);

                    if (fc == null || model.FaqCategoryID == Guid.Empty)
                    {
                        model.FaqItemID = Guid.NewGuid();
                        fc = new carrot_FaqItem();
                        fc.FaqCategoryID = model.FaqCategoryID;
                        fc.FaqItemID     = model.FaqItemID;
                    }

                    fc.Caption   = model.Caption;
                    fc.Question  = model.Question;
                    fc.Answer    = model.Answer;
                    fc.ItemOrder = model.ItemOrder;
                    fc.IsActive  = model.IsActive;

                    fh.Save(fc);
                }

                return(RedirectToAction("ListFaqItems", new { @id = model.FaqCategoryID }));
            }
            else
            {
                return(View("EditFaqItem", model));
            }
        }
Esempio n. 2
0
        public ActionResult ShowRandomFaq()
        {
            carrot_FaqItem model   = new carrot_FaqItem();
            FaqPublic      payload = new FaqPublic();

            if (this.WidgetPayload is FaqPublic)
            {
                payload = (FaqPublic)this.WidgetPayload;
                payload.LoadData();
            }

            ModelState.Clear();

            if (payload.FaqCategoryID != Guid.Empty)
            {
                model = payload.GetRandomItem();
            }

            if (String.IsNullOrEmpty(payload.AlternateViewFile))
            {
                return(PartialView("FaqItem", model));
            }
            else
            {
                return(PartialView(payload.AlternateViewFile, model));
            }
        }
Esempio n. 3
0
        public ActionResult DeleteFaqItem(carrot_FaqItem model)
        {
            using (FaqHelper fh = new FaqHelper(this.SiteID)) {
                fh.DeleteItem(model.FaqItemID);
            }

            return(RedirectToAction("ListFaqItems", new { @id = model.FaqCategoryID }));
        }
Esempio n. 4
0
        public ActionResult CreateFaqItem(Guid parent)
        {
            carrot_FaqItem model = new carrot_FaqItem();

            model.FaqCategoryID = parent;

            return(View("EditFaqItem", model));
        }
        public ActionResult ShowRandomFaq()
        {
            carrot_FaqItem model = new carrot_FaqItem();
            FaqPublic payload = new FaqPublic();

            if (this.WidgetPayload is FaqPublic) {
                payload = (FaqPublic)this.WidgetPayload;
                payload.LoadData();
            }

            ModelState.Clear();

            if (payload.FaqCategoryID != Guid.Empty) {
                model = payload.GetRandomItem();
            }

            if (String.IsNullOrEmpty(payload.AlternateViewFile)) {
                return PartialView("FaqItem", model);
            } else {
                return PartialView(payload.AlternateViewFile, model);
            }
        }
Esempio n. 6
0
        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;
        }
Esempio n. 7
0
 public ActionResult CreateFaqItem(carrot_FaqItem model)
 {
     return(EditFaqItem(model));
 }