public void Update(int id, UpdateTurbineTypeDto dto) { var turbineType = _turbineTypeRepository.FindById(id); if (turbineType == null) { throw new Exception("TurbineType was not found"); } if (dto.Model != null) { turbineType.Model = dto.Model; } if (dto.Capacity != 0) { turbineType.Capacity = dto.Capacity; } if (dto.TowerHeight != 0) { turbineType.TowerHeight = dto.TowerHeight; } if (dto.RotorDiameter != 0) { turbineType.RotorDiameter = dto.RotorDiameter; } if (dto.SweptArea != 0) { turbineType.SweptArea = dto.SweptArea; } if (dto.ManufacturerId != turbineType.Manufacturer.Id) { var manufacturer = _manufacturerRepository.FindById(dto.ManufacturerId); if (manufacturer != null) { turbineType.Manufacturer = manufacturer; } } _turbineTypeRepository.Update(turbineType); }
public void UpdateTurbineType(int id, TurbineTypeDto dto) { var turbineType = turbineTypeRepository.FindById(id); if (turbineType == null) { throw new Exception("TurbineType wasn't found"); } if (dto.Model != null) { turbineType.Model = dto.Model; } if (dto.Capacity != 0) { turbineType.Capacity = dto.Capacity; } turbineTypeRepository.Update(turbineType); }