public UpdateCommand(CaptionViewModel caption) { Caption = caption; }
public async Task <CaptionViewModel> GetCaption(int captionId) { CaptionViewModel result = null; string cmd = $@"SELECT * FROM `caption` c LEFT JOIN `caption_language` cl ON c.id = cl.caption_id WHERE c.id = {captionId}"; if (DbConnection != null) { var rd = await DbConnection.QueryMultipleAsync(cmd, transaction : DbTransaction); var rs = rd.Read <Caption, CaptionLanguage, CaptionViewModel>( (cRs, clRs) => { if (result == null) { result = CommonHelper.Mapper <Caption, CaptionViewModel>(cRs); } if (clRs != null) { var language = result.Languages.FirstOrDefault(l => l.Id == clRs.Id); if (language == null) { result.Languages.Add(clRs); } } return(result); }); return(result); } else { using (var conn = DALHelper.GetConnection()) { var rd = await conn.QueryMultipleAsync(cmd); var rs = rd.Read <Caption, CaptionLanguage, CaptionViewModel>( (cRs, clRs) => { if (result == null) { result = CommonHelper.Mapper <Caption, CaptionViewModel>(cRs); } if (clRs != null) { var language = result.Languages.FirstOrDefault(l => l.Id == clRs.Id); if (language == null) { result.Languages.Add(clRs); } } return(result); }); return(result); } } }