Ejemplo n.º 1
0
        public async Task <ResponseMessage> GiftAddOrUpdate(Models.UserInfo user, [FromBody] GiftAddRequest request)
        {
            Logger.Trace($"用户{user?.UserName ?? ""}({user?.Id ?? ""})赛季奖品管理-新增/修改赛季奖品,请求参数为:\r\n" + (request != null ? JsonHelper.ToJson(request) : ""));
            var response = new ResponseMessage();

            if (!ModelState.IsValid)
            {
                response.Code    = ResponseCodeDefines.ModelStateInvalid;
                response.Message = "模型验证失败:" + ModelState.GetAllErrors();
                Logger.Warn("赛季奖品管理-新增/修改赛季奖品,模型验证失败:\r\n{0}", response.Message ?? "");
                return(response);
            }
            try
            {
                response = await _giftManager.GiftAddOrUpdateAsync(user, request, HttpContext.RequestAborted);
            }
            catch (Exception e)
            {
                response.Code    = ResponseCodeDefines.ServiceError;
                response.Message = e.Message;
                Logger.Error($"用户{user?.UserName ?? ""}({user?.Id ?? ""})赛季奖品管理-新增/修改赛季奖品,报错:{e.Message}\r\n{e.StackTrace}");
            }
            return(response);
        }