Esempio n. 1
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));
        }