public IActionResult GetClaims() { var claims = _claimService.GetAll(); var temp = claims.GroupBy(d => d.Type).Select(c => new { type = c.Key, value = c.Select(v => v.Value) }); return(Ok(temp)); }
public async Task <IActionResult> CreateClaim([FromBody] CreateClaimDto dto) { if (!ModelState.IsValid) { return(BadRequest(ModelStateErrors)); } var temp = _claimService.GetAll().FirstOrDefault(c => c.Type == dto.Type && c.Value == dto.Value); if (temp != null) { return(ResultResponse(false, "已存在,请勿重复添加")); } var claims = _mapper.Map <Claims>(dto); var result = await _claimService.AddAsync(claims); return(ResultResponse(result, "插入成功")); }