public TryAddPatient(string name, string address, long contactNumber, int age, string gender, string blood, string majorDisease, int pid) { try { var context = new HospitalContext(); var patient = new AddPatient { Name = name, FullAddress = address, Contact = contactNumber, Age = age, Gender = gender, BloodGroup = blood, MajorDisease = majorDisease, pid = pid }; context.AddPatients.Add(patient); context.SaveChanges(); MessageBox.Show("Patient has been successfully Added!"); } catch (System.Data.Entity.Infrastructure.DbUpdateException) { MessageBox.Show("User already Exists or Incorrect data Added"); } }
private List <AddPatient> GetPeople(AddPatient query) { var list = new List <AddPatient>(); list.Add(new AddPatient() { pid = query.pid, Name = query.Name, FullAddress = query.FullAddress, Contact = query.Contact, Age = query.Age, Gender = query.Gender, BloodGroup = query.BloodGroup, MajorDisease = query.MajorDisease }); return(list); }