Exemplo n.º 1
0
        public async Task <IActionResult> CreateDeviceType(DeviceTypeCreateDto deviceTypeCreateDto)
        {
            var deviceType = _mapper.Map <DeviceType>(deviceTypeCreateDto);

            int?parentId = deviceTypeCreateDto.ParentId;

            if (await _deviceTypeService.CreateDeviceTypeAsync(parentId, deviceType))
            {
                var deviceTypeReturn = _mapper.Map <DeviceTypeDetailDto>(deviceType);
                return(CreatedAtRoute("GetDeviceType", new { id = deviceType.Id }, deviceTypeReturn));
            }

            throw new Exception("Creating device type failed on save");
        }