public HttpResponseMessage trackingProductWithTime(string deviceId, int timeSearch)
        {
            IDeviceService deviceService = this.Service <IDeviceService>();
            Device         device        = deviceService.GetById(deviceId);
            DateTime       startDate     = DateTime.Now;
            DateTime       endDate       = startDate.AddMinutes(timeSearch * (-1));

            if (device != null)
            {
                IProduct_positionService productPositionService = this.Service <IProduct_positionService>();
                Product_position         positionAlt            = productPositionService.trackingProduct(deviceId);
                double altitude = 0.0;
                if (positionAlt != null)
                {
                    altitude = positionAlt.Altitude.Value;
                }
                List <Product_position> positions = productPositionService.getListByTime(deviceId, endDate, startDate, altitude);
                if (positions != null)
                {
                    positions = positions.Select(q => new Product_position()
                    {
                        Id          = q.Id,
                        DeviceId    = q.DeviceId,
                        Altitude    = q.Altitude,
                        Latitude    = q.Latitude,
                        Longitude   = q.Longitude,
                        CreatedDate = q.CreatedDate,
                        Active      = q.Active,
                    }).ToList();
                    return(new HttpResponseMessage()
                    {
                        StatusCode = System.Net.HttpStatusCode.OK,
                        Content = new JsonContent(positions)
                    });
                }
                else
                {
                    return(new HttpResponseMessage()
                    {
                        StatusCode = System.Net.HttpStatusCode.NotFound,
                        Content = new JsonContent("Can not find device")
                    });
                }
            }
            else
            {
                return(new HttpResponseMessage()
                {
                    StatusCode = System.Net.HttpStatusCode.NotFound,
                    Content = new JsonContent("Device is not exist")
                });
            }
        }
        public HttpResponseMessage trackingProduct(string deviceId)
        {
            IDeviceService deviceService = this.Service <IDeviceService>();
            Device         device        = deviceService.GetById(deviceId);

            if (device != null)
            {
                IProduct_positionService productPositionService = this.Service <IProduct_positionService>();
                Product_position         model = productPositionService.trackingProduct(deviceId);
                if (model != null)
                {
                    Product_position positionModel = new Product_position()
                    {
                        Id          = model.Id,
                        DeviceId    = model.DeviceId,
                        Altitude    = model.Altitude,
                        Latitude    = model.Latitude,
                        Longitude   = model.Longitude,
                        CreatedDate = model.CreatedDate,
                        Active      = model.Active,
                    };
                    return(new HttpResponseMessage()
                    {
                        StatusCode = System.Net.HttpStatusCode.OK,
                        Content = new JsonContent(positionModel)
                    });
                }
                else
                {
                    return(new HttpResponseMessage()
                    {
                        StatusCode = System.Net.HttpStatusCode.NotFound,
                        Content = new JsonContent("Can not find device")
                    });
                }
            }
            else
            {
                return(new HttpResponseMessage()
                {
                    StatusCode = System.Net.HttpStatusCode.NotFound,
                    Content = new JsonContent("Device is not exist")
                });
            }
        }