blob: ce92bb26993ca64eee5ed7664dd43cc38992dd30 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Tango.TCC.BL.Entities;
using Tango.TCC.Service.DB;
using Tango.TCC.Service.DTO;
using Tango.TCC.Service.Security;
using Tango.Web.Controllers;
using System.Data.Entity;
using Tango.TCC.BL.Web;
namespace Tango.TCC.Service.Controllers
{
public class ResultsController : TangoController<TokenObject>
{
[HttpGet]
public List<ResultDTO> GetResults([FromUri] ResultsByDateRequest request)//int count)
{
List<ResultDTO> results = new List<ResultDTO>();
using (var db = TccDbContext.CreateTCC())
{
DateTime start, end;
if (!DateTime.TryParse(request.From, out start) || !DateTime.TryParse(request.To, out end))
{
return results;
}
var dbResults = (from RESULTS in db.Results
where RESULTS.Date >= start && RESULTS.Date <= end
join CARDS in db.Cards on RESULTS.CardGuid equals CARDS.Guid
join DEVICES in db.Devices on RESULTS.DeviceGuid equals DEVICES.Guid into prodGroup
from DEVICES2 in prodGroup
where (request.Email == null || DEVICES2.Email == request.Email) && (request.DeviceModel == null || DEVICES2.DeviceModel == request.DeviceModel)
select new
{
Result = RESULTS,
DeviceModel = DEVICES2.DeviceModel,
Email = DEVICES2.Email,
CardCode = CARDS.Code,
DeviceID = DEVICES2.DeviceID
}).ToList(); ;//.Where(x => (request.Email == null || x.Email == request.Email) && (request.DeviceModel == null || x.DeviceModel.Contains(request.DeviceModel))).ToList();
foreach (var item in dbResults)
{
ResultDTO dto = new ResultDTO();
dto.Date = item.Result.Date;
dto.RawColor = item.Result.RawColor;
dto.ProcessedColor = item.Result.ProcessedColor;
dto.SampleImageBlobName = item.Result.SampleImageBlobName;
dto.SourceImageBlobName = item.Result.SourceImageBlobName;
dto.ProcessTime = item.Result.ProcessTime;
dto.CardGuid = item.Result.CardGuid;
dto.CardCode = item.CardCode;
dto.DeviceModel = item.DeviceModel;
dto.Email = item.Email;
dto.DeviceGuid = item.DeviceID;
results.Add(dto);
}
}
return results;
}
}
}
|