Added write and read function
This commit is contained in:
parent
aa6695c0aa
commit
4223202c81
|
@ -0,0 +1,56 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated from a template.
|
||||
//
|
||||
// Manual changes to this file may cause unexpected behavior in your application.
|
||||
// Manual changes to this file will be overwritten if the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace EHEC_Server
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
public partial class Doctor
|
||||
{
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
|
||||
public Doctor()
|
||||
{
|
||||
this.Exam = new HashSet<Exam>();
|
||||
}
|
||||
public int DoctorId { get; set; }
|
||||
public string FirstName { get; set; }
|
||||
public string LastName { get; set; }
|
||||
public string DoctorOrigin { get; set; }
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
|
||||
public virtual ICollection<Exam> Exam { get; set; }
|
||||
|
||||
|
||||
public bool CreateDoctor(Doctor doctor)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (EHEC_DBEntities ctx = new EHEC_DBEntities())
|
||||
{
|
||||
ctx.Doctor.Add(doctor);
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public List<Doctor> GetAllDoctors()
|
||||
{
|
||||
using (EHEC_DBEntities ctx = new EHEC_DBEntities())
|
||||
{
|
||||
return ctx.Doctor.ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue