Exemplo n.º 1
0
 public int DeleteHospitalFromDB(int userid, int hospitalid)
 {
     using (var context = new assignmentEntities())
     {
         var deletedHospital = context.hospitals.FirstOrDefault(x => x.userid == userid && x.hospitalid == hospitalid);
         if (deletedHospital != null)
         {
             context.hospitals.Remove(deletedHospital);
             return(context.SaveChanges());
         }
         else
         {
             return(-1);
         }
     }
 }
Exemplo n.º 2
0
 public int AddHospitalToDB(Hospital hospital)
 {
     using (var context = new assignmentEntities())
     {
         context.hospitals.Add(new hospitals()
         {
             userid       = hospital.UserId,
             address      = hospital.Address,
             email        = hospital.Email,
             hospitalname = hospital.HospitalName,
             phone1       = hospital.Phone1,
             phone2       = hospital.Phone2,
             isprimary    = hospital.IsPrimary
         });
         return(context.SaveChanges());
     }
 }
Exemplo n.º 3
0
 public int UpdateHospitalToDB(Hospital hospital)
 {
     using (var context = new assignmentEntities())
     {
         var updatedHospital = context.hospitals.FirstOrDefault(x => x.userid == hospital.UserId && x.hospitalid == hospital.HospitalId);
         if (updatedHospital != null)
         {
             updatedHospital.address      = hospital.Address;
             updatedHospital.email        = hospital.Email;
             updatedHospital.hospitalname = hospital.HospitalName;
             updatedHospital.phone1       = hospital.Phone1;
             updatedHospital.phone2       = hospital.Phone2;
             updatedHospital.isprimary    = hospital.IsPrimary;
             return(context.SaveChanges());
         }
         else
         {
             return(-1);
         }
     }
 }