예제 #1
0
        /// <summary>
        /// Handler=Save
        /// </summary>
        /// <returns></returns>
        public async Task <IActionResult> OnPostSaveAsync([FromBody] MessagesExtendDto messagesExtendDto)
        {
            SenparcTrace.Log($"messagesExtendDto----{messagesExtendDto.ToJson()}");
            if (messagesExtendDto == null)
            {
                return(Ok(false));
            }
            MessagesDto messagesDto = new MessagesDto
            {
                Id      = messagesExtendDto.Id,
                Title   = messagesExtendDto.Title,
                Content = messagesExtendDto.Content,
                Method  = messagesExtendDto.Method,
                Type    = messagesExtendDto.Type,
                Status  = messagesExtendDto.Status
            };
            var strategy = _messagesService.BaseData.BaseDB.BaseDataContext.Database.CreateExecutionStrategy();
            await strategy.ExecuteAsync(async() => {
                await _messagesService.BeginTransactionAsync(async() =>
                {
                    var messages = await _messagesService.CreateOrUpdateAsync(messagesDto);
                    await messageDetailService.InsertMessageUserAsync(messages.Id, messagesExtendDto.RelationUser);
                });
            });

            return(Ok(true));
        }