public async Task <IActionResult> GetDevice(long id)
        {
            var result = await LocationService.GetDevice(id);

            if (result == null)
            {
                return(NotFound());
            }
            return(Ok(result));
        }
Esempio n. 2
0
        public async Task <IActionResult> Edit(long?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var item = await locationService.GetDevice(id ?? 0);

            if (item == null)
            {
                return(NotFound());
            }
            return(View(Mapper.Map <DeviceViewModel>(item)));
        }
Esempio n. 3
0
        public async Task <IActionResult> UpdateDevice(long id, DeviceViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var result = await locationService.GetDevice(id);

            if (result == null)
            {
                NotFound();
            }

            var item = await locationService.UpdateDevice("", id, Mapper.Map <DeviceDto>(model));

            return(Ok(Mapper.Map <DeviceDto>(item)));
        }