Esempio n. 1
0
 public Hospital GetHospitalDetailsFromDB(int userid, int hospitalid)
 {
     using (var context = new assignmentEntities())
     {
         hospitals h = context.hospitals.FirstOrDefault(x => x.userid == userid && x.hospitalid == hospitalid);
         if (h != null)
         {
             return(new Hospital()
             {
                 status = 1,
                 HospitalId = h.hospitalid,
                 UserId = h.userid,
                 Address = h.address,
                 Email = h.email,
                 HospitalName = h.hospitalname,
                 Phone1 = h.phone1,
                 Phone2 = h.phone2,
                 IsPrimary = h.isprimary
             });
         }
         else
         {
             return(new Hospital()
             {
                 status = -1
             });
         }
     }
 }
Esempio n. 2
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);
         }
     }
 }
Esempio n. 3
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());
     }
 }
Esempio n. 4
0
 public List <Hospital> GetHospitalsFromDB(int userid)
 {
     using (var context = new assignmentEntities())
     {
         return(context.hospitals.Where(x => x.userid == userid).Select(x => new Hospital()
         {
             HospitalId = x.hospitalid,
             UserId = x.userid,
             Address = x.address,
             Email = x.email,
             HospitalName = x.hospitalname,
             Phone1 = x.phone1,
             Phone2 = x.phone2,
             IsPrimary = x.isprimary
         }).ToList());
     }
 }
Esempio n. 5
0
 public List <Hospital> GetAllHospitalsFromDB()
 {
     using (var context = new assignmentEntities())
     {
         return(context.hospitals.Select(x => new Hospital()
         {
             hospitalid = x.hospitalid,
             userid = x.userid,
             address = x.address,
             email = x.email,
             hospitalname = x.hospitalname,
             phone1 = x.phone1,
             phone2 = x.phone2,
             isprimary = x.isprimary
         }).ToList());
     }
 }
Esempio n. 6
0
 public Hospital GetHospitalDetailsFromDB(int userid, int hospitalid)
 {
     using (var context = new assignmentEntities())
     {
         hospitals h = context.hospitals.FirstOrDefault(x => x.userid == userid && x.hospitalid == hospitalid);
         return(new Hospital()
         {
             hospitalid = h.hospitalid,
             userid = h.userid,
             address = h.address,
             email = h.email,
             hospitalname = h.hospitalname,
             phone1 = h.phone1,
             phone2 = h.phone2,
             isprimary = h.isprimary
         });
     }
 }
Esempio n. 7
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);
         }
     }
 }