public IActionResult List(string userId) { if (string.IsNullOrEmpty(userId)) { return(BadRequest("bad request, id should be an integer")); } var items = _briefkastenRepository.Get(x => x.UserId == userId); items.Where(x => !string.IsNullOrEmpty(x.Bezug)).ToList().ForEach(x => { var vertraege = _vertragRepository.Get(v => v.PartnerId == x.PartnerId).ToList(); var vertrag = vertraege[(int)Math.Floor(new Random().NextDouble() * vertraege.Count())]; x.BezugId = vertrag.Vsnr; x.BezugURI = $"{serverUrl}/vertrag/{vertrag.Vsnr}"; }); return(Ok(items)); }
public IActionResult Get([FromQuery] int partnerId, [FromQuery] string mode = "list") { var angebote = _vertragRepository.Get(x => x.PartnerId == partnerId).Select(p => new { Sparte = p.Sparte, BeitragZent = p.BeitragZent, VertragURI = p.VertragURI, Vsnr = p.Vsnr, PartnerId = p.PartnerId }); if (mode == "list") { return(Ok(angebote)); } else { return(Ok(angebote.Count())); } }