Exemplo n.º 1
0
        public async Task <IActionResult> TechNoteView(int id)
        {
            if (id == 0)
            {
                return(View());
            }
            else
            {
                var techNote = await _techNoteService.GetTechNoteById(id);

                if (techNote == null)
                {
                    string referer = Request.Headers["Referer"].ToString();
                    TempData["ErrorMsg"] = "자료가 존재하지 않습니다.";
                    return(Redirect(referer));
                }
                techNote.m_read++;
                await _techNoteService.UpdateTechNote(techNote, true);


                var nextPrev = _dbRecordService.GetPrevNext("TechNotes", id);
                ViewBag.NextPrev = nextPrev;

                return(View(techNote));
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> TechNoteEdit(TechNote techNote)
        {
            if (techNote == null)
            {
                return(View(techNote));
            }

            techNote.m_name = User.Identity.Name;

            var file = await UploadFile(HttpContext);

            if (file != null)
            {
                techNote.m_filesize  = file.FileSizeInKB;
                techNote.m_file_guid = file.GuidName;
                techNote.m_file_name = file.OriginalFileName;
            }

            if (techNote.Id == 0)
            {
                techNote.m_name = User.Identity.Name;
                techNote.m_date = DateTime.Now;
                techNote.m_read = 0;
                await _techNoteService.AddTechNote(techNote);

                TempData["SuccessMsg"] = "저장되었습니다.";
                return(RedirectToAction("TechNote"));
            }
            else
            {
                try
                {
                    techNote.m_date          = DateTime.Now;
                    techNote.m_date_modified = DateTime.Now;
                    await _techNoteService.UpdateTechNote(techNote);

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