/// <summary> /// 获取每个选项的比例 /// </summary> /// <param name="model"></param> /// <returns></returns> public async Task <List <OptionShowViewModel> > GetOptionRate(GetOptionRateViewModel model) { List <OptionShowViewModel> list = new List <OptionShowViewModel>() { }; int total = 0; if (model.DeptId == Guid.Empty) { total = await _userRepository.GetAll().CountAsync(); } else { total = await _userRepository.GetAll().Where(m => m.DepartmentId == model.DeptId).CountAsync(); } IQueryable <LaborDetail> laborDetails = _laborDetailRepository.GetAll().Where(m => m.LaborId == model.LaborId); model.Options.ForEach(option => { int optionCount = laborDetails.Where(m => m.Option == option).Count(); list.Add(new OptionShowViewModel() { Option = option, OptionCount = optionCount, Total = total }); }); return(list); }
public async Task <IActionResult> GetOptionRate([FromQuery] GetOptionRateViewModel model) { return(Ok(await _laborHeadService.GetOptionRate(model))); }