Exemplo n.º 1
0
        public ActionResult Put([FromBody] Patient patient)
        {
            var patients   = PatientRepo.GetPatients().ToList();
            var ChoosenOne = patients.FirstOrDefault(e => e.ID.Equals(patient.ID));

            if (ChoosenOne.Equals(null))
            {
                return(NotFound());
            }
            else
            {
                ChoosenOne.FirstName   = patient.FirstName;
                ChoosenOne.LastName    = patient.LastName;
                ChoosenOne.HomeAddress = patient.HomeAddress;
                ChoosenOne.HIS         = patient.HIS;
                ChoosenOne.Intake      = patient.Intake;
                ChoosenOne.Complaint   = patient.Complaint;
                ChoosenOne.Diagnose    = patient.Diagnose;
                ChoosenOne.DateOfBirth = patient.DateOfBirth;
                ChoosenOne.Age         = Patient.CalculateAge(patient.DateOfBirth);
                ChoosenOne.Allergy     = patient.Allergy;
                ChoosenOne.Medications = patient.Medications;
                PatientRepo.SavePatients(patients);
                return(Ok());
            }
        }
Exemplo n.º 2
0
        public ActionResult Index()
        {
            var Patients = _patientRepo.GetPatients();

            ViewData["Patients"] = Patients; // When we use view data then we don't need to cast its type on the view side. While when we don't need type casting in case of viewbag
            ViewBag.Patients     = Patients; // its a container that takes the value from controller and passes it to view, it can contain any string or object
            return(View(Patients));
        }
Exemplo n.º 3
0
        public ActionResult Post([FromBody] Patient patient)
        {
            List <Patient> patients = PatientRepo.GetPatients().ToList();

            patient.ID = patients.Count < 1 ? 1 : patients.OrderByDescending(e => e.ID).FirstOrDefault().ID + 1;
            patients.Add(patient);
            PatientRepo.SavePatients(patients);
            return(Ok());
        }
Exemplo n.º 4
0
        public ActionResult Delete(long id)
        {
            var patients   = PatientRepo.GetPatients().ToList();
            var ChoosenOne = patients.FirstOrDefault(e => e.ID.Equals(id));

            if (ChoosenOne.Equals(null))
            {
                return(NotFound());
            }
            else
            {
                patients.Remove(ChoosenOne);
                PatientRepo.SavePatients(patients);
                return(Ok());
            }
        }
Exemplo n.º 5
0
 public ActionResult <IEnumerable <Patient> > Get()
 {
     return(Ok(PatientRepo.GetPatients()));
 }