oop_II-6/EHEC_Server/EHEC_Server/DatabaseAccess/DoctorAccess.cs

36 lines
826 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ServiceModel;
namespace EHEC_Server.DatabaseAccess
{
public class DoctorAccess
{
public Doctor CreateDoctor(Doctor doctor)
{
try
{
using (EHEC_DBEntities ctx = new EHEC_DBEntities())
{
ctx.Doctor.Add(doctor);
ctx.SaveChanges();
}
return doctor;
}
catch (Exception)
{
return new Doctor();
}
}
public List<Doctor> GetAllDoctors()
{
using (EHEC_DBEntities ctx = new EHEC_DBEntities())
{
return ctx.Doctor.ToList();
}
}
}
}