Ejemplo n.º 1
0
        public IActionResult UpdataById(int id, [FromBody] UserInfo NewUser)
        {
            var u = _context.UserInfo.Update(NewUser);

            var user = this.GetAuthUser();

            if (user.Power != 2)
            {
                return(StatusCode(403));
            }

            if (u == null)
            {
                return(Json(new { sucess = false }));
            }


            try
            {
                var providedApiKey = long.Parse(Request.Headers["Authorization"].ToString());
                //获取日志信息
                ModifyInfo NewModify = modify.UpdataInfo(DateTime.Now, "User", 1, providedApiKey);
                //保存日志信息
                _context.Add(NewModify);
                _context.SaveChanges();
            }
            catch (Exception e)
            {
                return(Json(new { sucess = false }));
            }

            return(Json(new { sucess = true }));
        }
Ejemplo n.º 2
0
        public IActionResult UpdataById(int id, [FromBody] EngineerInfo Newengineer)
        {
            var user = this.GetAuthUser();

            if (user.Power != 1)
            {
                return(StatusCode(403));
            }

            var u = _context.EngineerInfo.Update(Newengineer);

            if (u == null)
            {
                return(Json(new { success = false }));
            }

            //成功时执行以下操作
            //获取header中的token
            var providedApiKey = long.Parse(Request.Headers["Authorization"].ToString());
            //获取日志信息
            ModifyInfo NewModify = modify.UpdataInfo(DateTime.Now, "Engineer", 1, providedApiKey);

            //保存日志信息
            _context.Add(NewModify);

            return(Json(new { success = _context.SaveChanges() > 0 }));
        }