public bool Insert(PrescriptionItem newPrescriptionItem) { using (MySqlHealthContext ctx = new MySqlHealthContext()) { ctx.PrescriptionItems.Add(newPrescriptionItem); return(ctx.SaveChanges() > -1); } }
public bool Delete(int id) { using (MySqlHealthContext ctx = new MySqlHealthContext()) { PrescriptionItem prescriptionItem = ctx.PrescriptionItems.FirstOrDefault(d => d.Id == id); if (prescriptionItem == null) { return(false); } ctx.PrescriptionItems.Remove(prescriptionItem); return(ctx.SaveChanges() > -1); } }
public Result AddPrescriptionItem(int prescriptionId, PrescriptionItem item) { return(Try(() => { var entity = _context.Prescriptions.Find(prescriptionId); if (entity == null) { throw new PrescriptionNotFoundException(prescriptionId); } _context.AddPrescriptionItem(item.MedicineId, item.PrescriptionId, item.QuantityToBuy); _context.SaveChanges(); }, typeof(PrescriptionEfRepo))); }
public bool Update(PrescriptionItem newInfoPresciptionItem) { using (MySqlHealthContext ctx = new MySqlHealthContext()) { PrescriptionItem prescriptionItem = ctx.PrescriptionItems.FirstOrDefault(d => d.Id == newInfoPresciptionItem.Id); if (prescriptionItem == null) { return(false); } prescriptionItem.PrescriptionId = newInfoPresciptionItem.PrescriptionId; prescriptionItem.MedicamentId = newInfoPresciptionItem.MedicamentId; prescriptionItem.UsePerDay = newInfoPresciptionItem.UsePerDay; prescriptionItem.DoctorNote = newInfoPresciptionItem.DoctorNote; prescriptionItem.IsActive = newInfoPresciptionItem.IsActive; return(ctx.SaveChanges() > -1); } }
public bool Update(PrescriptionItem newInfoPresciptionItem) { return(_prescriptionItemDal.Update(newInfoPresciptionItem)); }
public bool Insert(PrescriptionItem newPrescriptionItem) { return(_prescriptionItemDal.Insert(newPrescriptionItem)); }