Esempio n. 1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }


            try
            {
                await _faqService.UpdateFaq(Faq);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FaqExists(Faq.FaqId))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Esempio n. 2
0
        public IHttpActionResult DeleteFaq(Faq faqModel)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                if (faqModel.Id != 0)
                {
                    faqModel.isDelete = true;
                    faqService.UpdateFaq(faqModel);
                }

                return(Ok());
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }
Esempio n. 3
0
        public async Task <IActionResult> FAQEdit(Faq faq)
        {
            if (faq.Id == 0)
            {
                faq.m_name = User.Identity.Name;
                faq.m_date = DateTime.Now;
                faq.m_read = 0;
                faq.m_ip   = _accessor.HttpContext.Connection.RemoteIpAddress.ToString();
                await _faqService.AddFaq(faq);

                TempData["SuccessMsg"] = "저장되었습니다.";
                return(RedirectToAction("FAQ"));
            }
            else
            {
                try
                {
                    faq.m_date = DateTime.Now;
                    await _faqService.UpdateFaq(faq);

                    TempData["SuccessMsg"] = "저장되었습니다.";
                    return(RedirectToAction("FAQ"));
                }
                catch (Exception ex)
                {
                    if (ex.Message == "PASSWORD-NOT-MATCHED")
                    {
                        TempData["ErrorMsg"] = "비밀번호가 일치하지 않습니다.";
                    }
                    else
                    {
                        TempData["ErrorMsg"] = ex.Message;
                    }
                }
            }
            return(View(faq));
        }