コード例 #1
0
        public async Task <ActionResult <DiseaseModel> > PostDiseaseModel(DiseaseModel diseaseModel)
        {
            _context.DiseaseModels.Add(diseaseModel);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetDiseaseModel", new { id = diseaseModel.Id }, diseaseModel));
        }
コード例 #2
0
        public ActionResult GetAllDisease()
        {
            DiseaseModel D  = new DiseaseModel();
            DataTable    dt = D.SelectAll();

            return(View(dt));
        }
コード例 #3
0
        public async Task <IActionResult> PutDiseaseModel(int id, DiseaseModel diseaseModel)
        {
            if (id != diseaseModel.Id)
            {
                return(BadRequest());
            }

            _context.Entry(diseaseModel).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DiseaseModelExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #4
0
        public ActionResult CreateDisease(FormCollection collection)
        {
            DiseaseModel D = new DiseaseModel();

            D.DiseaseName = collection["DiseaseName"];
            D.IsActive    = (collection["IsActive"] == "true");
            D.InsertDisease();
            return(RedirectToAction("GetAllDisease"));
        }
コード例 #5
0
 public ActionResult addDiseaseDetails(DiseaseModel diseaseModel)
 {
     try
     {
         ModelManager modelManager = new ModelManager();
         modelManager.addDiseaseDetails(diseaseModel);
         return(RedirectToAction("Index"));
     }
     catch (MedicalException e)
     {
         TempData["result"] = e.Message;
         return(View());
     }
 }
コード例 #6
0
        public static async Task <DiseaseModel> RetrieveDiseaseById(int id)
        {
            DiseaseModel result = new DiseaseModel();

            using (var httpClientHandler = new HttpClientHandler())
            {
                httpClientHandler.ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => { return(true); };
                using (var httpClient = new HttpClient(httpClientHandler))
                {
                    using (var response = await httpClient.GetAsync(basUrl + "Disease/" + id))
                    {
                        string apiResponse = await response.Content.ReadAsStringAsync();

                        result = JsonConvert.DeserializeObject <DiseaseModel>(apiResponse);
                    }
                }
            }
            return(result);
        }
コード例 #7
0
        public IActionResult Post([FromBody] DiseaseModel obj)
        {
            var context = new ValidationContext(obj, null, null);

            var result = new List <ValidationResult>();

            var isValid = Validator.TryValidateObject(obj, context, result, true);

            if (result.Count == 0)
            {
                PatientDAL dal = new PatientDAL(ConStr);
                dal.Database.EnsureCreated();   // ensure table is created or not
                dal.Add(obj);                   //inmemory
                dal.SaveChanges();              // pysical commit save to database
                List <DiseaseModel> recs = dal.Diseas.ToList();
                return(StatusCode(200, recs));
            }
            else
            {
                return(StatusCode(500, result));
            }
        }
コード例 #8
0
        public async Task <IActionResult> UpdateDisease(DiseaseModel Disease)
        {
            DiseaseModel anim = new DiseaseModel();

            using (var httpClientHandler = new HttpClientHandler())
            {
                httpClientHandler.ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => { return(true); };

                using (var httpClient = new HttpClient(httpClientHandler))
                {
                    StringContent content = new StringContent(JsonConvert.SerializeObject(Disease), Encoding.UTF8, "application/json");
                    string        url     = basUrl + "Disease/" + Disease.Id;
                    using (var response = await httpClient.PutAsync(url, content))
                    {
                        string apiResponse = await response.Content.ReadAsStringAsync();

                        ViewBag.Result = "Success";
                        anim           = JsonConvert.DeserializeObject <DiseaseModel>(apiResponse);
                    }
                }
            }
            return(RedirectToAction("Index"));
        }
コード例 #9
0
        public async Task <IActionResult> AddDisease(DiseaseModel diseaseModel)
        {
            //diseaseModel.DateDiagnosed = DateTime.Now;
            DiseaseModel Disease = new DiseaseModel();

            using (var httpClientHandler = new HttpClientHandler())
            {
                httpClientHandler.ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => { return(true); };
                using (var httpClient = new HttpClient(httpClientHandler))
                {
                    StringContent content = new StringContent(JsonConvert.SerializeObject(diseaseModel), Encoding.UTF8, "application/json");

                    using (var response = await httpClient.PostAsync(basUrl + "Disease", content))
                    {
                        string apiResponse = await response.Content.ReadAsStringAsync();

                        //HttpResponseMessage mssg = new HttpResponseMessage();
                        //mssg.StatusCode = System.Net.HttpStatusCode.OK;
                        Disease = JsonConvert.DeserializeObject <DiseaseModel>(apiResponse);
                    }
                }
            }
            return(RedirectToAction("Index"));
        }
コード例 #10
0
        public IActionResult AddDisease()
        {
            DiseaseModel Disease = new DiseaseModel();

            return(View(Disease));
        }