Ejemplo n.º 1
0
        public IActionResult DeleteById(int id)
        {
            var state = false;
            var user  = this.GetAuthUser();

            if (user.Power != 2)
            {
                return(StatusCode(403));
            }
            var u = _context.UserInfo.SingleOrDefault(s => s.ID == id);

            if (u != null)
            {
                _context.UserInfo.Remove(u);
                state = _context.SaveChanges() > 0;
            }

            if (state == true)
            {
                var providedApiKey = long.Parse(Request.Headers["Authorization"].ToString());
                //获取日志信息
                ModifyInfo NewModify = modify.DeleteInfo(DateTime.Now, "User", 1, providedApiKey);
                //保存日志信息
                _context.Add(NewModify);
            }

            return(Json(new { sucess = state }));
        }