public async Task <ActionResult <msec_detail> > Postmsec_detail(msec_detail msec_detail) { _context.msec_details.Add(msec_detail); await _context.SaveChangesAsync(); return(CreatedAtAction("Getmsec_detail", new { id = msec_detail.id }, msec_detail)); }
public async Task <IActionResult> Putmsec_detail(int id, msec_detail msec_detail) { if (id != msec_detail.id) { return(BadRequest()); } _context.Entry(msec_detail).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!msec_detailExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <msec_detail[]> > GetMsecByPin(string pin) { using (var client = new HttpClient()) { var json = JsonConvert.SerializeObject( new { clientId = "ebb7570a-5357-4afa-8430-19843b34dfd7", orgName = "ПОРТАЛ", request = new { MSECDetails = new { request = new { PIN = pin } } } }); var data = new StringContent(json, Encoding.UTF8, "application/json"); var url = "http://" + _appSettings.Value.SODHost + "/ServiceConstructor/SoapClient/SendRequest2"; if (!_appSettings.Value.hasInternet) { var obj = new msec_detail { created_at = DateTime.Now, updated_at = DateTime.Now, organizationName = "test", disabilityGroup = "test", examinationDate = (DateTime)DateTime.Now, examinationType = "test", from = DateTime.Now, to = DateTime.Now, reExamination = "test" }; return(Ok(new[] { obj })); } var response = await client.PostAsync(url, data); string result = response.Content.ReadAsStringAsync().Result; var j = JObject.Parse(result); if (j["response"]["MSECDetailsResponse"]["response"] != null) { var s = j["response"]["MSECDetailsResponse"]["response"]; if (s["StatusCode"].ToString() == "SUCCESS") { var obj = new msec_detail { created_at = DateTime.Now, updated_at = DateTime.Now, organizationName = s["OrganizationName"].ToString(), disabilityGroup = s["DisabilityGroup"].ToString(), examinationDate = (DateTime)s["ExaminationDate"], examinationType = s["ExaminationType"].ToString(), from = (DateTime?)s["From"], to = (DateTime?)s["To"], reExamination = s["ReExamination"] != null ? s["ReExamination"].ToString() : "" }; return(Ok(new[] { obj })); } else { return(Ok(new msec_detail[] { })); } } return(Ok(new msec_detail[] { })); } }