コード例 #1
0
        public async Task <IActionResult> UpdateConsumerHealthIndicatorSuggestion([FromBody]
                                                                                  UpdateHealthIndicatorSuggestion request)
        {
            var userBiz = new UserBiz();
            var model   = await userBiz.GetModelAsync(request.UserGuid, true);

            if (model is null || !model.Enable)
            {
                return(Failed(ErrorCode.Empty, "指定会员不存在"));
            }

            var suggestionModel = new ConsumerIndicatorSuggestionModel()
            {
                IndicatorSuggestionGHuid = Guid.NewGuid().ToString("N"),
                Suggestion    = request.Suggestion,
                UserGuid      = request.UserGuid,
                CreatedBy     = UserID,
                LastUpdatedBy = UserID
            };

            var result = await new HealthIndicatorBiz().UpdateConsumerHealthIndicatorSuggestion(suggestionModel);

            if (result)
            {
                new HealthRabbitMQNotificationBiz().HealthRabbitMQNotification(new HealthMessageDto()
                {
                    HealthType = HealthMessageDto.HealthTypeEnum.HealthIndicator,
                    Content    = suggestionModel.Suggestion,
                    Title      = "您的日常健康指标医生建议有更新",
                }, request.UserGuid);
            }

            return(result ? Success() : Failed(ErrorCode.DataBaseError, "更新医生建议失败"));
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <bool> UpdateConsumerHealthIndicatorSuggestion(ConsumerIndicatorSuggestionModel model)
        {
            using (var conn = MySqlHelper.GetConnection())
            {
                var result = await conn.InsertAsync <string, ConsumerIndicatorSuggestionModel>(model);

                return(!string.IsNullOrEmpty(result));
            }
        }