Beispiel #1
0
        /// <summary>
        /// 연락처 삭제
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <IActionResult> Delete(long?id)
        {
            CreaetUserAuth();

            // 사용자 삭제 권한 체크
            if (_userAuth.Delete.Equals("4-3"))
            {
                return(RedirectToAction("Error", "Home", new { errormessage = "UserauthError" }));
            }

            if (id == null)
            {
                return(NotFound());
            }

            Contact contact = await _context.Contact.Where(x => x.Contactid == id).SingleOrDefaultAsync();

            if (contact != null)
            {
                _context.Remove(contact);
                int deleteResult = await _context.SaveChangesAsync();

                // 삭제가 정상적으로 이루어지지 않았을 때
                if (deleteResult <= 0)
                {
                    return(RedirectToAction("Error", "Home", new { errormessage = "UserauthError" }));
                }
            }
            else
            {
                return(RedirectToAction("Error", "Home", new { errormessage = "UserauthError" }));
            }

            return(View("Index"));
        }
Beispiel #2
0
        /// <summary>
        /// 거래처 삭제
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <IActionResult> Delete(long?id)
        {
            // 권한 검사
            CreaetUserAuth();
            if (_userAuth.Delete.Equals("4-3"))
            {
                return(RedirectToAction("Error", "Home", new { errormessage = "UserauthError" }));
            }

            if (id == null)
            {
                return(NotFound());
            }

            Account account = await _context.Account.Where(x => x.Accountid == id).SingleOrDefaultAsync();

            if (account != null)
            {
                _context.Remove(account);
                int deleteResult = await _context.SaveChangesAsync();

                // 삭제가 정상적으로 이루어지지 않았을 때
                if (deleteResult <= 0)
                {
                    return(RedirectToAction("Error", "Home", new { errormessage = "UserauthError" }));
                }
            }
            else
            {
                return(RedirectToAction("Error", "Home", new { errormessage = "UserauthError" }));
            }

            ViewBag.isPop = false;
            // 권한
            ViewData["Read"]   = _userAuth.Read;
            ViewData["Write"]  = _userAuth.Write;
            ViewData["Modify"] = _userAuth.Modify;
            ViewData["Delete"] = _userAuth.Delete;

            return(RedirectToAction("Index", "Accounts"));
        }