public ActionResult chooseTreat(TreatmentVM treat) { int oo = idp = Convert.ToInt32(HttpContext.Request.Params.Get("name")); string str1; string str = Request.Form["test"]; str1 = str.Substring(0, 21); str = str.Replace(str1, ""); str = str.Remove(str.Length - 2); JavaScriptSerializer j = new JavaScriptSerializer(); object a = j.Deserialize(str, typeof(object)); // return new JsonResult { Data = oo, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; /* if (Session["authtoken"] == null) * return RedirectToAction("Login", "Auth");*/ HttpClient Client = new HttpClient(); /* Client.DefaultRequestHeaders.Authorization = * new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", Session["authtoken"] + "");*/ Client.BaseAddress = new Uri("http://localhost:18080"); Client.PostAsJsonAsync <object>("epione-jee-web/api/treatments/copyListTreatment?idPath=" + oo, a).ContinueWith((PostTask) => PostTask.Result.EnsureSuccessStatusCode()); return(RedirectToAction("Index")); }
public ActionResult AddTreatment(TreatmentVM treat, int iddd) { pathIdForChooseTreat = iddd; try { //idp = Convert.ToInt32(HttpContext.Request.Params.Get("idSelected")); // evm.patient = new PatientVM(); // evm.patient.id = getUserId(idp); // treat.path = new PathVM(); // treat.path.id = idp; ViewBag.testest = iddd; if (Session["authtoken"] == null) { return(RedirectToAction("Login", "Auth")); } HttpClient Client = new HttpClient(); Client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", Session["authtoken"] + ""); Client.BaseAddress = new Uri("http://localhost:18080"); Client.PostAsJsonAsync <TreatmentVM>("epione-jee-web/api/paths/addTreatment?idPath=" + iddd, treat).ContinueWith((PostTask) => PostTask.Result.EnsureSuccessStatusCode()); return(RedirectToAction("Index")); } catch { return(View()); } //return new JsonResult { Data = treat,JsonRequestBehavior=JsonRequestBehavior.AllowGet}; }
public ActionResult Create(TreatmentVM treat) { try { if (Session["authtoken"] == null) { return(RedirectToAction("Login", "Auth")); } HttpClient Client = new HttpClient(); Client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", Session["authtoken"] + ""); Client.BaseAddress = new Uri("http://localhost:18080"); Client.PostAsJsonAsync <TreatmentVM>("epione-jee-web/api/paths", treat).ContinueWith((PostTask) => PostTask.Result.EnsureSuccessStatusCode()); return(RedirectToAction("Index")); } catch { return(View()); } }
public IEnumerable <PatientVM> Get() { var patients = patientRepository.GetPatients(); List <PatientVM> patientVMs = new List <PatientVM>(); foreach (var patient in patients) { var patientVM = new PatientVM() { PatientId = patient.PatientId, Name = patient.Name, DateAdmitted = patient.DateAdmitted, DateReleased = patient.DateReleased, Description = patient.Description, Diagnosis = patient.Diagnosis }; var treatmentsToBeReturned = new List <TreatmentVM>(); foreach (var treatment in patient.Treatments) { var treatmentVM = new TreatmentVM() { TreatmentAndDose = treatment.TreatmentAndDose, PatientId = treatment.PatientId, Date = treatment.Date, TreatmentId = treatment.TreatmentId }; treatmentsToBeReturned.Add(treatmentVM); } var vaccinesToBeReturned = new List <VaccineVM>(); foreach (var vaccine in patient.Vaccines) { var vaccineVM = new VaccineVM() { VaccineId = vaccine.VaccineId, PatientId = vaccine.PatientId, Type = vaccine.Type.ToString(), Dose1Delivered = vaccine.Dose1Delivered, Dose1DeliveredDate = vaccine.Dose1DeliveredDate, Dose1Required = vaccine.Dose1Required, Dose1TargetDate = vaccine.Dose1TargetDate, Dose2Delivered = vaccine.Dose2Delivered, Dose2DeliveredDate = vaccine.Dose2DeliveredDate, Dose2Required = vaccine.Dose2Required, Dose2TargetDate = vaccine.Dose2TargetDate, Dose3Delivered = vaccine.Dose3Delivered, Dose3DeliveredDate = vaccine.Dose3DeliveredDate, Dose3Required = vaccine.Dose3Required, Dose3TargetDate = vaccine.Dose3TargetDate }; vaccinesToBeReturned.Add(vaccineVM); } patientVM.Treatments = treatmentsToBeReturned; patientVM.Vaccines = vaccinesToBeReturned; patientVMs.Add(patientVM); } return(patientVMs); }