Ejemplo n.º 1
0
 public async Task <List <GpsLog> > GetDeviceLog(GetLogParameter data)
 {
     // TODO: Convert to sp
     return(await context.GpsLogs.Where(a =>
                                        a.Device.UserDevices.Any(b => b.UserId == data.UserId) &&
                                        a.DeviceId == data.DeviceId &&
                                        a.SubmitDate >= data.From &&
                                        a.SubmitDate <= data.To)
            .ToListAsync());
 }
        public async Task <IActionResult> GetDeviceLog(GetLogParameter data)
        {
            var userId = HttpContext.User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier)?.Value;

            if (string.IsNullOrEmpty(userId))
            {
                return(BadRequest());
            }
            data.UserId = Convert.ToInt32(userId);
            return(Ok(await repo.GetDeviceLog(data)));
        }