public void DeleteRecipe() { try { if (PrescriptionsGiven.Count() == 0) { throw new ArgumentException("אין מרשם למחיקה"); } Recipe recipe = PrescriptionsGiven.First(); AddDoctorVisitM.DeleteRecipe(recipe); (App.Current as App).navigation.MainWindows.comments.Text = "תרופה הוסרה בהצלחה"; PrescriptionsGiven.Remove(recipe); MedicationsAdded.Remove(recipe.MedicineName); } catch (Exception e) { (App.Current as App).navigation.MainWindows.comments.Text = e.Message.ToString(); } }
public void AddRecipe() { try { if (Description == null || QuantityPerDay == 0 || PeriodOfUse == 0) { throw new ArgumentException("אתה צריך למלא את כל השדות"); } MedicineId = AddDoctorVisitM.GetMedicineId(MedicineSelected); RecipeId = AddDoctorVisitM.AddRecipeId(); Recipe recipe = new Recipe(RecipeId, MedicineSelected, Patient.PatientId, User.Id, MedicineId, PeriodOfUse, QuantityPerDay, Description, DateTime.Now); AddDoctorVisitM.AddRecipe(recipe); (App.Current as App).navigation.MainWindows.comments.Text = "תרופה נוספה בהצלחה"; PrescriptionsGiven.Add(recipe); MedicationsAdded.Add(recipe.MedicineName); } catch (Exception e) { (App.Current as App).navigation.MainWindows.comments.Text = e.Message.ToString(); } }