コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }