public Result <int> AddPrescription(Prescription entity) { return(Try(() => { var result = _context.AddPrescription(entity.DoctorId, entity.ApothecaryId, entity.PrescriptionDate, entity.Email); _context.SaveChanges(); return result.FirstOrDefault().Value; }, typeof(PrescriptionEfRepo))); }
public Result Add(Doctor doctor) { var result = Try(() => { _context.Doctors.Add(doctor); _context.SaveChanges(); }, typeof(DoctorEfRepo)); return(result); }
public Result Add(Apothecary apothecary) { var result = Try(() => { _context.InsertApothecary(apothecary.FirstName, apothecary.LastName, apothecary.MonthlySalary); _context.SaveChanges(); }, typeof(ApothecaryEfRepo)); return(result); }
public Result Add(Medicine medicine) { var result = Try(() => { _context.Medicines.Add(medicine); _context.SaveChanges(); }, typeof(MedicineEfRepo)); return(result); }
public Result Add(MedicineWarehouse entity) { var result = Try(() => { var item = _context.MedicineWarehouses.FirstOrDefault(x => x.MedicineId == entity.MedicineId); if (item == null) { _context.MedicineWarehouses.Add(entity); } else { item.Quantity = entity.Quantity; } _context.SaveChanges(); }, typeof(WarehouseEfRepo)); return(result); }
public Result <int> Create(int apothecaryId) { var result = Try(() => { var res = _context.CreateOrder(apothecaryId).FirstOrDefault(); if (!res.HasValue) { throw new Exception("Nie znaleziono nowo dodanego zamówienia."); } _context.SaveChanges(); return(res.Value); }, typeof(OrderEfRepo)); return(result); }