public Donation GetOne(long id) { var db = new BloodBankingContext(); var donation = db.Donations.Find(id); if (donation == null) { throw new Exception("Could not find Donations"); } return(donation); }
public Region GetOne(long id) { var db = new BloodBankingContext(); var region = db.Regions.Find(id); if (region == null) { throw new Exception("Could not find region"); } return(region); }
public bool Update(Donor donor) { var db = new BloodBankingContext(); var donors = db.Donors.FirstOrDefault(x => x.ID == donor.ID); if (donor == null) { db.SaveChanges(); } return(true); }
public Donor GetOne() { var db = new BloodBankingContext(); var donor = db.Donors.Find(); if (donor == null) { throw new Exception("Couldn't find Donor"); } return(donor); }
public List <Donor> GetAll() { var db = new BloodBankingContext(); var donor = db.Donors.ToList(); if (donor == null) { throw new Exception("Couldn't find Donor"); } return(donor); }
public Bank GetOne(long id) { var db = new BloodBankingContext(); var bank = db.Banks.Find(id); if (bank == null) { throw new Exception("Could not find Bank"); } return(bank); }
public List <Donation> GetAll() { var db = new BloodBankingContext(); var donation = db.Donations.ToList(); if (donation == null) { throw new Exception("Couldnt find any donations"); } return(donation); }
public List <Region> GetAll() { var db = new BloodBankingContext(); var region = db.Regions.ToList(); if (region == null) { throw new Exception("Could not find any region"); } return(region); }
public List <Bank> GetAll() { var db = new BloodBankingContext(); var Bank = db.Banks.ToList(); if (Bank == null) { throw new Exception("Could not find Bank"); } return(Bank); }
public bool Update(Bank bank) { var db = new BloodBankingContext(); var banks = db.Banks.FirstOrDefault(x => x.Id == bank.Id); if (bank == null) { return(false); } bank.Name = bank.Name; return(true); }
public bool Update(Donation donation) { var db = new BloodBankingContext(); var donations = db.Donations.FirstOrDefault(x => x.ID == donation.ID); if (donation == null) { return(false); } db.SaveChanges(); return(true); }
public bool Delete(long id) { var db = new BloodBankingContext(); var donors = db.Donors.FirstOrDefault(x => x.ID == id); if (donors == null) { db.Donors.Remove(donors); } db.SaveChanges(); return(true); }
public bool AddRegion(Region reg) { var database = new BloodBankingContext(); if (string.IsNullOrEmpty(reg.Name)) { return(false); } database.Regions.Add(reg); database.SaveChanges(); return(true); }
public bool AddDonor(Donor donor) { var database = new BloodBankingContext(); if (string.IsNullOrEmpty(donor.Name)) { return(false); } database.Donors.Add(donor); database.SaveChanges(); return(true); }
public bool Delete(long id) { var db = new BloodBankingContext(); var region = db.Regions.FirstOrDefault(x => x.Id == id); if (region == null) { return(false); } db.Regions.Remove(region); db.SaveChanges(); return(true); }
public bool AddBanks(Bank bank) { var database = new BloodBankingContext(); if (string.IsNullOrEmpty(bank.Name)) { return(false); } database.Banks.Add(bank); database.SaveChanges(); return(true); }
public bool Update(Region reg) { var db = new BloodBankingContext(); var region = db.Regions.FirstOrDefault(x => x.Id == reg.Id); if (region == null) { return(false); } region.Name = reg.Name; db.SaveChanges(); return(true); }
public bool Delete(Bank bank) { var db = new BloodBankingContext(); var banks = db.Banks.FirstOrDefault(x => x.Id == bank.Id); if (bank == null) { return(false); } db.Banks.Remove(bank); db.SaveChanges(); return(true); }
public bool AddDonations(Donation donation) { var database = new BloodBankingContext(); if (string.IsNullOrEmpty(donation.DonorId)) { return(false); } database.Donations.Add(donation); database.SaveChanges(); return(true); }