75 lines
1.7 KiB
C#
75 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;
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
}
|