CarrotCake.CMS.Plugins.FAQ2.Models.FaqPublic.GetRandomItem C# (CSharp) Method

GetRandomItem() public method

public GetRandomItem ( ) : carrot_FaqItem
return carrot_FaqItem
        public carrot_FaqItem GetRandomItem()
        {
            using (FaqHelper fh = new FaqHelper(this.SiteID)) {
                return fh.FaqItemListPublicRandGetByFaqCategoryID(this.FaqCategoryID, this.SiteID);
            }
        }

Usage Example

        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);
            }
        }