71 lines
1.8 KiB
C#
71 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using Web_Server_EHEC.Model;
|
|
|
|
namespace Web_Server_EHEC.ISL
|
|
{
|
|
public class PatientISL
|
|
{
|
|
public List<Patient> GetAllPatients()
|
|
{
|
|
using (EHEC_DB_ModelContainer ctx = new EHEC_DB_ModelContainer())
|
|
{
|
|
return ctx.PatientSet.ToList();
|
|
}
|
|
}
|
|
public bool CreatePatient(Patient patient)
|
|
{
|
|
try
|
|
{
|
|
using (EHEC_DB_ModelContainer ctx = new EHEC_DB_ModelContainer())
|
|
{
|
|
ctx.PatientSet.Add(patient);
|
|
ctx.SaveChanges();
|
|
}
|
|
return true;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public bool UpdatePatient(Patient patient)
|
|
{
|
|
try
|
|
{
|
|
using (EHEC_DB_ModelContainer ctx = new EHEC_DB_ModelContainer())
|
|
{
|
|
ctx.PatientSet.Attach(patient);
|
|
ctx.Entry(patient).State = System.Data.Entity.EntityState.Modified;
|
|
ctx.SaveChanges();
|
|
}
|
|
return true;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
}
|
|
public bool DeletePatient(Patient patient)
|
|
{
|
|
try
|
|
{
|
|
using (EHEC_DB_ModelContainer ctx = new EHEC_DB_ModelContainer())
|
|
{
|
|
ctx.PatientSet.Attach(patient);
|
|
ctx.PatientSet.Remove(patient);
|
|
ctx.SaveChanges();
|
|
}
|
|
return true;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
} |