예제 #1
0
        public async Task <IActionResult> GetDevice(long id)
        {
            var result = await LocationService.GetDevice(id);

            if (result == null)
            {
                return(NotFound());
            }
            return(Ok(result));
        }
예제 #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)));
        }
예제 #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)));
        }