Esempio n. 1
0
        public async Task <bool> UpdateDevice(DTODevice device)
        {
            Device mapDevice = _mapper.Map <Device>(device);

            _deviceRepository.Update(mapDevice);

            bool success = true;

            try
            {
                await _deviceRepository.SaveChanges();
            }
            catch
            {
                if (!_deviceRepository.DeviceExists(device.ID))
                {
                    success = false;
                }
                else
                {
                    throw;
                }
            }

            return(success);
        }
Esempio n. 2
0
        public async Task <ActionResult <DTODevice> > GetDevice(int id)
        {
            DTODevice device = await _service.GetDevice(id);

            if (device == null)
            {
                return(NotFound());
            }

            return(device);
        }
Esempio n. 3
0
        public async Task <IActionResult> AddDevice(DTODevice device)
        {
            bool success = await _service.AddDevice(device);

            if (success)
            {
                return(Ok());
            }
            else
            {
                return(BadRequest());
            }
        }
Esempio n. 4
0
        public async Task <IActionResult> UpdateDevice(DTODevice device)
        {
            bool success = await _service.UpdateDevice(device);

            if (success)
            {
                return(Ok());
            }
            else
            {
                return(NotFound());
            }
        }
Esempio n. 5
0
        public async Task <bool> AddDevice(DTODevice device)
        {
            Device mapDevice = _mapper.Map <Device>(device);

            _deviceRepository.Add(mapDevice);
            bool success = true;

            try
            {
                await _deviceRepository.SaveChanges();
            }
            catch
            {
                success = false;
            }

            return(success);
        }
        // GET: Device
        public async Task <ActionResult> Index()
        {
            DTODevice device = new DTODevice();

            device.Id = await db.Devices.Select(x => x.Id).ToListAsync();

            var distinctFrequencies = db.Wifis.Select(x => x.Frequency).Distinct();

            try {
                foreach (var freq in distinctFrequencies)
                {
                    var count = await db.Wifis.Distinct().CountAsync(x => x.Frequency == freq);

                    device.frequencies.Add(new Frequency()
                    {
                        frequency    = freq,
                        numberOfUses = count
                    });
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
            }

            device.sumOfBluetoothCapture = await db.Bluetooths.Select(x => x.MAC).Distinct().CountAsync();

            device.sumOfWifisCapture = await db.Wifis.Select(x => x.BSSID).Distinct().CountAsync();

            device.totalCaptures = device.sumOfWifisCapture + device.sumOfBluetoothCapture;

            device.uniqueBSSIDCount = await db.Wifis.Select(x => x.BSSID).Distinct().CountAsync();

            device.uniqueMACsCount = await db.Bluetooths.Select(x => x.MAC).Distinct().CountAsync();

            device.numberOfOpenWifis = await db.Wifis.Where(x => x.Security.Equals("[ESS]")).Select(y => y.BSSID).Distinct().CountAsync();


            return(View(device));
        }
Esempio n. 7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="deviceDTO"></param>
 /// <returns></returns>
 public DTOResponse useDevice(DTODevice inDeviceDTO)
 {
     return(DTOFactory.BuildUseDeviceResponseDTO(inDeviceDTO));
 }
Esempio n. 8
0
 public async Task <CustomResponse <DTODevice> > SaveDevice(DTODevice device)
 {
     throw new NotImplementedException();
 }