예제 #1
0
        public Guid?AddNewInventory(InventoryViewModel inventoryViewModel)
        {
            var car = _mapper.Map <Car>(inventoryViewModel);

            car = NullifyDependantEntities(car);
            car = ManageCarAttributes(inventoryViewModel, car);

            Guid?newCarId = _carRepository.AddNewCar(car);

            if (newCarId == null)
            {
                return(null);
            }

            inventoryViewModel.CarId = (Guid)newCarId;

            var inventory = _mapper.Map <Inventory>(inventoryViewModel);


            Guid?newInventoryId = _inventoryRepository.AddInventory(inventory);

            inventoryViewModel.Id = (Guid)newInventoryId;


            var repairDetails = _mapper.Map <Repair>(inventoryViewModel);

            repairDetails.CarId = (Guid)newCarId;

            _repairRepository.AddNewRepair(repairDetails);

            return(newInventoryId);
        }