public IHttpActionResult GetClient([FromBody] GetClientReq req) { if (req == null || req.snils == null) { return(BadRequest("Parameters is empty")); } var client = (from c in dc.GetTable <Client>() where c.Snils == req.snils join ci in dc.GetTable <d_City>() on c.Cityid equals ci.Id select new { c.Id, c.Surname, c.Name, c.PatronymicName, BirthDate = c.BirthDate.Date.ToString(), City = ci.Name, c.Addres, c.Gender, c.PassSerial, c.PassNumber, PassDate = c.PassDate.Date.ToString(), c.PassPlace, c.Insurance, c.Snils }).FirstOrDefault(); if (client == null) { return(Json(client)); } var chronicMass = (from c in dc.GetTable <Chronic>() where c.ClientId == client.Id join t in dc.GetTable <d_DiseaseType>() on c.ChronicDiseaseTypeId equals t.Id select t.DiseaseName).ToArray(); var allergyMass = (from a in dc.GetTable <Allergy>() where a.ClientId == client.Id select a.AlergyName).ToArray(); var diseaseMass = (from d in dc.GetTable <Disease>() where d.ClientId == client.Id join t in dc.GetTable <d_DiseaseType>() on d.DiseaseTypeId equals t.Id orderby d.EndDate descending select new { Name = t.DiseaseName, EndDate = d.EndDate.Date.ToString(), d.Description }).ToArray(); var vaccineMass = (from v in dc.GetTable <Vaccine>() where v.ClientId == client.Id select new { v.VaccineName, VaccineDate = v.VaccineDate.Date.ToString() }).ToArray(); return(Json(new { client = client, allergy = allergyMass, disease = diseaseMass, chronic = chronicMass, vaccine = vaccineMass })); }
public async Task <ActionResult <IEnumerable <ClientRes> > > Get([FromQuery] GetClientReq req) { return(Ok(await _clientService.GetPaging(req))); }