public async Task <Localize> Handle(Query request, CancellationToken cancellationToken) { JObject messageJson = JObject.Parse("{}"); JObject menuJson = JObject.Parse("{}"); if (request.Module == "ALL") { var messages = await _context.QuerySingleAsync <string>(@"select COALESCE(json_object_agg(message_code, message_desc),'{ }') as message from su_message where lang_code = @lang::lang", new { lang = request.Lang }, token : cancellationToken); messageJson = JObject.Parse(messages); var menus = await _context.QuerySingleAsync <string>(@"select COALESCE(json_object_agg(menu_code, menu_name),'{}') from su_menu_label where system_code = 'bbo' AND lang_code = @lang::lang", new { lang = request.Lang }, token : cancellationToken); menuJson = JObject.Parse(menus); } var labels = await _context.QuerySingleAsync <string>(@"select COALESCE(json_object_agg(concat(program_code,'.',field_name), label_name),'{}') from su_program_label where lang_code = @lang::lang AND module_code = @module ", new { lang = request.Lang, module = request.Module }, token : cancellationToken); var labelJson = JObject.Parse(labels); return(new Localize() { Message = messageJson, Menu = menuJson, Label = labelJson }); }
public async Task<JObject> Handle(Query request, CancellationToken cancellationToken) { var parameter = await _context.QuerySingleAsync<string>(@"select COALESCE(json_object_agg(sp.parameter_code, sp.parameter_value),'{ }') as parameter from su_parameter sp where sp.parameter_group_code = @Group and sp.parameter_code = COALESCE(@Code,sp.parameter_code) ", new { Group = request.Group,Code = request.Code }, token: cancellationToken); return JObject.Parse(parameter); }