public List <Medicine> GetList() { using (MedicineDATA ctx = new MedicineDATA()) { return(ctx.Medicine.ToList()); } }
public void Add(Medicine Medicine) { using (var ctx = new MedicineDATA()) { ctx.Medicine.Add(Medicine); ctx.SaveChanges(); } }
public Medicine GetMedicineById(int id) { using (MedicineDATA ctx = new MedicineDATA()) { var medicine = ctx.Medicine.Where(s => s.ID == id).FirstOrDefault(); return(medicine); } }
public void Delete(int id) { using (MedicineDATA ctx = new MedicineDATA()) { var medicine = ctx.Medicine.Where(s => s.ID == id).FirstOrDefault(); ctx.Medicine.Remove(medicine); ctx.SaveChanges(); } }
public void EditImage(Medicine medicine, string path) { path = path.Remove(0, 39); path = path.Replace('\\', '/'); using (var ctx = new MedicineDATA()) { var m = ctx.Medicine.FirstOrDefault(x => x.ID == medicine.ID); ctx.Medicine.Remove(m); medicine.ImageURL = path; ctx.Medicine.Add(medicine); ctx.SaveChanges(); } }
public List <string> GetNames() { List <string> MedicinesNames = new List <string>(); using (var ctx = new MedicineDATA()) { foreach (var item in ctx.Medicine) { MedicinesNames.Add(item.ProprietaryName); } } return(MedicinesNames); }