Ejemplo n.º 1
0
        /// <summary>
        /// update an existing faq item
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public async Task<RServiceResult<bool>> UpdateItemAsync(FAQItem item)
        {
            try
            {
                var dbModel = await _context.FAQItems.Where(i => i.Id == item.Id).SingleAsync();
                dbModel.Question = item.Question;
                dbModel.AnswerExcerpt = item.AnswerExcerpt;
                dbModel.FullAnswer = item.FullAnswer;
                dbModel.Pinned = item.Pinned;
                dbModel.PinnedItemOrder = item.PinnedItemOrder;
                dbModel.CategoryId = item.CategoryId;
                dbModel.ItemOrderInCategory = item.ItemOrderInCategory;
                dbModel.ContentForSearch = item.ContentForSearch;
                dbModel.HashTag1 = item.HashTag1;
                dbModel.HashTag2 = item.HashTag2;
                dbModel.HashTag3 = item.HashTag3;
                dbModel.HashTag4 = item.HashTag4;
                dbModel.Published = item.Published;
                _context.Update(dbModel);
                await _context.SaveChangesAsync();

                return new RServiceResult<bool>(true);
            }
            catch (Exception exp)
            {
                return new RServiceResult<bool>(false, exp.ToString());
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> UpdateItemAsync([FromBody] FAQItem item)
        {
            var res = await _faqService.UpdateItemAsync(item);

            if (!string.IsNullOrEmpty(res.ExceptionString))
            {
                return(BadRequest(res.ExceptionString));
            }
            return(Ok(res.Result));
        }
Ejemplo n.º 3
0
    protected void gvFAQ_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        if (e == null)
        {
            throw new ArgumentNullException("e");
        }
        FAQItem.FlushFAQCache();
        Controls_mfbHtmlEdit t = (Controls_mfbHtmlEdit)gvFAQ.Rows[e.RowIndex].FindControl("txtAnswer");

        sqlFAQ.UpdateParameters["Answer"] = new Parameter("Answer", System.Data.DbType.String, t.FixedHtml);
    }
Ejemplo n.º 4
0
        public ViewResult Submit(FAQPage currentPage, string question)
        {
            var     contentRepository = ServiceLocator.Current.GetInstance <IContentRepository>();
            FAQItem fi = contentRepository.GetDefault <FAQItem>(currentPage.ContentLink);

            fi.Name     = string.Format("Question: {0}", question);
            fi.Question = question;

            contentRepository.Save(fi, EPiServer.DataAccess.SaveAction.Save, EPiServer.Security.AccessLevel.Read);
            DefaultPageViewModel <FAQPage> model = new DefaultPageViewModel <FAQPage>(currentPage);

            return(View("Index", model));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// add a new faq item
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public async Task<RServiceResult<FAQItem>> AddItemAsync(FAQItem item)
        {
            try
            {
                _context.FAQItems.Add(item);
                await _context.SaveChangesAsync();

                return new RServiceResult<FAQItem>(item);
            }
            catch (Exception exp)
            {
                return new RServiceResult<FAQItem>(null, exp.ToString());
            }
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> OnGetAsync()
        {
            if (string.IsNullOrEmpty(Request.Cookies["Token"]))
            {
                return(Redirect("/"));
            }

            LastMessage = "";
            await GanjoorSessionChecker.ApplyPermissionsToViewData(Request, Response, ViewData);

            if (!ViewData.ContainsKey($"{RMuseumSecurableItem.FAQEntityShortName}-{RMuseumSecurableItem.ModerateOperationShortName}"))
            {
                LastMessage = "شما به این بخش دسترسی ندارید.";
                return(Page());
            }

            if (!string.IsNullOrWhiteSpace(Request.Query["id"]))
            {
                using (HttpClient secureClient = new HttpClient())
                {
                    if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response))
                    {
                        HttpResponseMessage response = await secureClient.GetAsync($"{APIRoot.Url}/api/faq/secure/{Request.Query["id"]}");

                        if (!response.IsSuccessStatusCode)
                        {
                            LastMessage = JsonConvert.DeserializeObject <string>(await response.Content.ReadAsStringAsync());
                            return(Page());
                        }

                        Question = JsonConvert.DeserializeObject <FAQItem>(await response.Content.ReadAsStringAsync());
                    }
                    else
                    {
                        LastMessage = "لطفا از گنجور خارج و مجددا به آن وارد شوید.";
                    }
                }
            }
            else
            {
                Question = new FAQItem()
                {
                    CategoryId = int.Parse(Request.Query["catId"])
                };
            }

            return(Page());
        }
Ejemplo n.º 7
0
    protected void btnInsert_Click(object sender, EventArgs e)
    {
        DBHelper dbh = new DBHelper("INSERT INTO FAQ SET Category=?Category, Question=?Question, Answer=?Answer");

        if (dbh.DoNonQuery((comm) =>
        {
            comm.Parameters.AddWithValue("Category", txtCategory.Text);
            comm.Parameters.AddWithValue("Question", txtQuestion.Text);
            comm.Parameters.AddWithValue("Answer", txtAnswer.Text);
        }))
        {
            FAQItem.FlushFAQCache();
            txtCategory.Text = txtQuestion.Text = txtAnswer.Text = string.Empty;
            gvFAQ.DataBind();
        }
    }
Ejemplo n.º 8
0
        public async Task <IActionResult> OnGetAsync()
        {
            ViewData["Title"] = $"گنجور » پرسش‌های متداول";
            LoggedIn          = !string.IsNullOrEmpty(Request.Cookies["Token"]);


            ViewData["GoogleAnalyticsCode"] = Configuration["GoogleAnalyticsCode"];

            //todo: use html master layout or make it partial
            if (false == (await preparePoets()))
            {
                return(Page());
            }

            if (!string.IsNullOrEmpty(Request.Query["id"]))
            {
                var response = await _httpClient.GetAsync($"{APIRoot.Url}/api/faq/{Request.Query["id"]}");

                if (!response.IsSuccessStatusCode)
                {
                    LastError = JsonConvert.DeserializeObject <string>(await response.Content.ReadAsStringAsync());
                    if (string.IsNullOrEmpty(LastError))
                    {
                        LastError = $"خطا در دریافت اطلاعات پرسش مد نظر - کد خطا = {response.StatusCode}";
                    }
                    return(Page());
                }
                Question = JsonConvert.DeserializeObject <FAQItem>(await response.Content.ReadAsStringAsync());
            }
            else
            {
                var response = await _httpClient.GetAsync($"{APIRoot.Url}/api/faq/pinned");

                if (!response.IsSuccessStatusCode)
                {
                    LastError = JsonConvert.DeserializeObject <string>(await response.Content.ReadAsStringAsync());
                    return(Page());
                }
                PinnedItemsCategories = JArray.Parse(await response.Content.ReadAsStringAsync()).ToObject <List <FAQCategory> >();
            }

            return(Page());
        }
Ejemplo n.º 9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Master.SelectedTab = tabID.lbtImport;

        wzImportFlights.PreRender += new EventHandler(wzImportFlights_PreRender);

        Title   = (string)GetLocalResourceObject("PageResource1.Title");
        UseHHMM = MyFlightbook.Profile.GetUser(User.Identity.Name).UsesHHMM;

        if (!IsPostBack)
        {
            List <FAQItem> lst = new List <FAQItem>(FAQItem.CachedFAQItems);
            FAQItem        fi  = lst.Find(f => f.idFAQ == 44);
            if (fi != null)
            {
                lblTipsHeader.Text = fi.Question;
                litTipsFAQ.Text    = fi.Answer;
            }
        }
    }