public void RemovePrescriptionItem(string pharmaceuticalName) { PrescriptionItems.Remove ( PrescriptionItems.Where(p => p.PharmaceuticalName == pharmaceuticalName).FirstOrDefault() ); }
public void AddPrescriptionItem(string pharmaceuticalName, int prescribedDailyDose, int duration, int containerSize, bool?availableOverTheCounter, string comments) { var oldItem = PrescriptionItems .Where(p => p.PharmaceuticalName == pharmaceuticalName) .FirstOrDefault(); //if item not already in list add it if (oldItem == null) { PrescriptionItems.Add(new PrescriptionItem(pharmaceuticalName, prescribedDailyDose, duration, containerSize, availableOverTheCounter, comments)); return; } //update the item oldItem.UpdateDuration(duration); oldItem.PrescribedDailyDose = oldItem.PrescribedDailyDose > prescribedDailyDose ? oldItem.PrescribedDailyDose : prescribedDailyDose; }