aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/TCC/Tango.TCC.Service/Controllers/ResultsController.cs
blob: 19ad591514e9ff5416874e4f0a97e7c26182af71 (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
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;

namespace Tango.TCC.Service.Controllers
{
    public class ResultsController : TangoController<TokenObject>
    {
        [HttpGet]
        public List<ResultDTO> GetResults(int count)
        {
            List<ResultDTO> results = new List<ResultDTO>();

            using (var db = TccDbContext.CreateTCC())
            {
                
                var dbResults = db.Results.Take(count).Include(x => x.Device).Include(x => x.Card).ToList();

                foreach (var item in dbResults)
                {
                    ResultDTO dto = new ResultDTO();
                    dto.Date = item.Date;
                    dto.RawColor = item.RawColor;
                    dto.ProcessedColor = item.ProcessedColor;
                    dto.SampleImageBlobName = item.SampleImageBlobName;
                    dto.SourceImageBlobName = item.SourceImageBlobName;
                    dto.ProcessTime = item.ProcessTime;
                    dto.CardGuid = item.CardGuid;
                    CardDTO card = new CardDTO();
                    card.CardGuid = item.Card.Guid;
                    card.Columns = item.Card.Columns;
                    card.TargetIndex = item.Card.TargetIndex;
                    card.Version = item.Card.Version;
                    card.Batch = item.Card.Batch;
                    card.IsHomePrinted = item.Card.IsHomePrinted;
                    dto.Card = card;
                    DeviceDTO device = new DeviceDTO();
                    device.DeviceID = item.Device.DeviceID;
                    device.DeviceModel = item.Device.DeviceModel;
                    device.OSVersion = item.Device.OSVersion;
                    device.Email = item.Device.Email;
                    device.LastLogin = item.Device.LastLogin;
                    device.MachineRegistered = item.Device.MachineRegistered;
                    device.OrganizationGuid = item.Device.OrganizationGuid;
                    device.MachineRegistered = item.Device.MachineRegistered;
                    dto.Device = device;
                    dto.DeviceGuid = item.DeviceGuid;
                    results.Add(dto);
                }
            }

            return results;
        }


    }
}