public async Task <TopicHomepageViewModel> GetTopicById(int topicId, string lang = "vi") { TopicHomepageViewModel result = null; string cmd = $@"SELECT * FROM `topic` t LEFT JOIN `topic_language` tl ON t.id = tl.topic_id WHERE t.is_deleted = 0 and t.id = {topicId}"; if (DbConnection != null) { var rd = await DbConnection.QueryMultipleAsync(cmd, transaction : DbTransaction); rd.Read <Topic, TopicLanguage, TopicHomepageViewModel>( (fRs, flRs) => { if (result == null) { result = CommonHelper.Mapper <Topic, TopicHomepageViewModel>(fRs); } if (flRs != null) { result.TopicLanguages.Add(flRs); } return(result); } ); return(result); } else { using (var conn = DALHelper.GetConnection()) { var rd = await conn.QueryMultipleAsync(cmd); rd.Read <Topic, TopicLanguage, TopicHomepageViewModel>( (fRs, flRs) => { if (result == null) { result = CommonHelper.Mapper <Topic, TopicHomepageViewModel>(fRs); } if (flRs != null) { result.TopicLanguages.Add(flRs); } return(result); } ); return(result); } } }
public UpdateCommand(TopicHomepageViewModel topic) { this.Topic = topic; }
public AddCommand(TopicHomepageViewModel topic) { this.Topic = topic; }