public async Task <APIResult> GetFaqById(int topicId) { var rs = await topicHomepageQueries.GetTopicById(topicId); return(new APIResult() { Result = 0, Data = rs }); }
public override async Task <int> HandleCommand(UpdateCommand request, CancellationToken cancellationToken) { if (request.Topic == null || request.Topic.Id == 0) { throw new BusinessException("Topic.NotExisted"); } var topic = (await topicQueries.GetTopicById(request.Topic.Id)); if (topic == null) { throw new BusinessException("Topic.NotExisted"); } var rs = -1; using (var conn = DALHelper.GetConnection()) { conn.Open(); using (var trans = conn.BeginTransaction()) { try { //request.Topic.CreatedDate = topic.CreatedDate; //request.Topic.CreatedBy = topic.CreatedBy; request.Topic = UpdateBuild(request.Topic, request.LoginSession); rs = await topicRepository.UpdateAsync(request.Topic); if (rs != 0) { return(-1); } //for language // languages foreach (var item in request.Topic.TopicLanguages) { item.TopicId = request.Topic.Id; await topicRepository.AddOrUpdateLanguage(item); } rs = 0; } catch (Exception ex) { throw ex; } finally { if (rs == 0) { trans.Commit(); } else { try { trans.Rollback(); } catch { } } } } } return(rs); }