added db files for the migration

This commit is contained in:
ismail 2018-06-01 15:36:25 +02:00
parent d977fc0433
commit c794b29d30
5 changed files with 82 additions and 4 deletions

View File

@ -4,11 +4,12 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web;
namespace Service_Server.DB namespace Service_Server.DB
{ {
class Doctor_DB public class Doctor_DB
{ {
public List<Doctor> GetAllDoctors() public List<Doctor> GetAllDoctors()
{ {

View File

@ -4,10 +4,11 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web;
namespace Service_Server.DB namespace Service_Server.DB
{ {
class Origin_DB public class Origin_DB
{ {
public List<Origin> GetAllOrigins() public List<Origin> GetAllOrigins()
{ {

View File

@ -4,10 +4,11 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web;
namespace Service_Server.DB namespace Service_Server.DB
{ {
class PStatus_DB public class PStatus_DB
{ {
public List<PStatus> GetAllPstatuses() public List<PStatus> GetAllPstatuses()
{ {

View File

@ -4,10 +4,11 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web;
namespace Service_Server.DB namespace Service_Server.DB
{ {
class Person_DB public class Person_DB
{ {
public List<Person> GetAllPersons() public List<Person> GetAllPersons()
{ {

View File

@ -0,0 +1,74 @@
using Service_Server.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
namespace Service_Server.DB
{
public class Result_DB
{
public List<Result> GetAllResults()
{
using (DATABASE ctx = new DATABASE())
{
return ctx.Results.ToList();
}
}
public bool CreateResult(Result result)
{
try
{
using (DATABASE ctx = new DATABASE())
{
ctx.Results.Add(result);
ctx.SaveChanges();
}
return true;
}
catch (Exception)
{
return false;
}
}
public bool UpdateResult(Result result)
{
try
{
using (DATABASE ctx = new DATABASE())
{
ctx.Results.Attach(result);
ctx.Entry(result).State = System.Data.Entity.EntityState.Modified;
ctx.SaveChanges();
}
return true;
}
catch (Exception)
{
return false;
}
}
public bool DeleteResult(Result result)
{
try
{
using (DATABASE ctx = new DATABASE())
{
ctx.Results.Attach(result);
ctx.Results.Remove(result);
ctx.SaveChanges();
}
return true;
}
catch (Exception)
{
return false;
}
}
}
}