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"); }
public IEnumerable <DeviceTypePropertiesNestedDto> Create(DeviceTypeCreateDto input) { if (input.Id == 0) { int id = _deviceTypeRepository.InsertAndGetId(ObjectMapper.Map <Models.DeviceType>(input)); return(DeviceTypeTreeWithProperties(id)); } else { var deviceType = _deviceTypeRepository.Get(input.Id); ObjectMapper.Map(input, deviceType); return(DeviceTypeTreeWithProperties(input.Id)); } }