コード例 #1
0
        public async Task <ActionResult> InsertIPBan([FromBody] IPBanDto toInsert)
        {
            if (!this.HttpContext.Session.HasSystemActionRights() || !this.HttpContext.Session.HasSystemActionRight(ActionRights.UserManagement))
            {
                return(RedirectToAction("Index", "Home"));
            }

            toInsert.IPBanSetByUserID = this.HttpContext.Session.GetUserID();
            toInsert.IPBanSetOn       = DateTime.Now;
            var ipBanId = await SecurityManager.AddNewIPBanAsync(toInsert);

            if (ipBanId > 0)
            {
                _cache.Remove(CacheKeys.AllIPBans);
                toInsert.IPBanID = ipBanId;
            }

            // jsGrid requires the inserted object as return value.
            return(Json(toInsert));
        }