74 lines
1.7 KiB
C#
74 lines
1.7 KiB
C#
using Service_Server.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
namespace Service_Server.DB
|
|
{
|
|
class Doctor_DB
|
|
{
|
|
public List<Doctor> GetAllDoctors()
|
|
{
|
|
using (DATABASE ctx = new DATABASE())
|
|
{
|
|
return ctx.Doctors.ToList();
|
|
}
|
|
}
|
|
public bool CreateDoctor(Doctor doctor)
|
|
{
|
|
try
|
|
{
|
|
using (DATABASE ctx = new DATABASE())
|
|
{
|
|
ctx.Doctors.Add(doctor);
|
|
ctx.SaveChanges();
|
|
}
|
|
return true;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public bool UpdateDoctor(Doctor doctor)
|
|
{
|
|
try
|
|
{
|
|
using (DATABASE ctx = new DATABASE())
|
|
{
|
|
ctx.Doctors.Attach(doctor);
|
|
ctx.Entry(doctor).State = System.Data.Entity.EntityState.Modified;
|
|
ctx.SaveChanges();
|
|
}
|
|
return true;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
}
|
|
public bool DeleteDoctor(Doctor doctor)
|
|
{
|
|
try
|
|
{
|
|
using (DATABASE ctx = new DATABASE())
|
|
{
|
|
ctx.Doctors.Attach(doctor);
|
|
ctx.Doctors.Remove(doctor);
|
|
ctx.SaveChanges();
|
|
}
|
|
return true;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|