46 lines
1.3 KiB
C#
46 lines
1.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.ServiceModel;
|
|
|
|
namespace EHEC_Server
|
|
{
|
|
public partial class Result
|
|
{
|
|
public Result CreateResult(Result result)
|
|
{
|
|
try
|
|
{
|
|
using (EHEC_DBEntities ctx = new EHEC_DBEntities())
|
|
{
|
|
result.ResultUid = Guid.NewGuid().ToString();
|
|
ctx.Results.Add(result);
|
|
ctx.SaveChanges();
|
|
}
|
|
return result;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return new Result();
|
|
}
|
|
}
|
|
public List<Result> GetAllResults()
|
|
{
|
|
using (EHEC_DBEntities ctx = new EHEC_DBEntities())
|
|
{
|
|
ctx.Configuration.ProxyCreationEnabled = false;
|
|
List<Result> list = new List<Result>();
|
|
return ctx.Results.ToList();
|
|
}
|
|
}
|
|
public Result GetResultsById(int id)
|
|
{
|
|
using (EHEC_DBEntities ctx = new EHEC_DBEntities())
|
|
{
|
|
Result result = ctx.Results.Where(e => e.ResultId == id).SingleOrDefault();
|
|
return result;
|
|
}
|
|
}
|
|
}
|
|
} |