コード例 #1
0
        public ActionResult Post([FromBody] Medication med)
        {
            List <Medication> meds = MedicationRepo.GetMedications().ToList();

            med.ID = meds.Count < 1 ? 1 : meds.OrderByDescending(e => e.ID).FirstOrDefault().ID + 1;
            meds.Add(med);
            MedicationRepo.SavePatients(meds);
            return(Ok());
        }
コード例 #2
0
        public ActionResult Delete(long id)
        {
            var meds     = MedicationRepo.GetMedications().ToList();
            var selected = meds.FirstOrDefault(e => e.ID.Equals(id));

            if (selected.Equals(null))
            {
                return(NotFound());
            }
            else
            {
                meds.Remove(selected);
                MedicationRepo.SavePatients(meds);
                return(Ok());
            }
        }
コード例 #3
0
        public ActionResult Put([FromBody] Medication med)
        {
            var meds     = MedicationRepo.GetMedications().ToList();
            var selected = meds.FirstOrDefault(e => e.ID.Equals(med.ID));

            if (selected.Equals(null))
            {
                return(NotFound());
            }
            else
            {
                selected.ID               = med.ID;
                selected.MedicationName   = med.MedicationName;
                selected.ActiveIngredient = med.ActiveIngredient;
                selected.MinimumAge       = med.MinimumAge;
                selected.MaximumAge       = med.MaximumAge;
                selected.Dosage           = med.Dosage;
                selected.Packaging        = med.Packaging;
                selected.Description      = med.Description;
                MedicationRepo.SavePatients(meds);
                return(Ok());
            }
        }
コード例 #4
0
 public MedicationController(MedicationRepo repository, IMapper mapper)
 {
     _repository = repository;
     _mapper     = mapper;
 }
コード例 #5
0
 public ActionResult <IEnumerable <Medication> > Get()
 {
     return(Ok(MedicationRepo.GetMedications()));
 }