Esempio n. 1
0
        public async Task <IEnumerable <ShortDeviceDto> > GetAll()
        {
            var userIdClaim = ((ClaimsIdentity)User.Identity).FindFirst(ClaimTypes.NameIdentifier);
            var userId      = int.Parse(userIdClaim.Value);

            return(await _devicesRepository.GetAll(userId));
        }
        public async Task <IActionResult> GetAll(string partitionKey)
        {
            var response = await devicesRepository.GetAll(partitionKey);

            return(Ok(new
            {
                correct = true,
                title = "Mensaje del sistema",
                message = "Dispositivos obtenidos correctamente",
                deviceData = response,
                fullStackTrace = "",
            }));
        }
        public async Task <IActionResult> Index(string message, int?page)
        {
            var devices = _devicesRepository.GetAll();

            if (!User.IsInRole(Helper.Admin))
            {
                var userId     = Helper.GetUserId(this.User);
                var userGroups = _groupsRepository.GetUserGroups(userId);

                devices = devices.Where(d => userGroups.Any(g => g.Id == d.GroupId));
            }

            ViewBag.Message = message;
            ViewBag.Current = "Devices";

            int pageSize = 15;

            return(View(await devices.ToPagedListAsync(page ?? 1, pageSize)));
        }
Esempio n. 4
0
 public Device GetBySku(string sku)
 {
     return(_deviceRepository.GetAll().FirstOrDefault(s => string.Compare(sku, s.Sku) == 0));
 }
Esempio n. 5
0
        public IList <DeviceDto> GetAll()
        {
            var devices = _devicesRepository.GetAll().ToList();

            return(MapperDevices.GetDeviceDto(devices));
        }