Exemplo n.º 1
0
        public async Task <DriverModel> CreateDriver(int businessId, DriverModel driver)
        {
            await validateBusiness(businessId);

            var driverEntity = _mapper.Map <DriverEntity>(driver);

            _libraryRepository.CreateDriver(driverEntity);
            var saveResult = await _libraryRepository.SaveChangesAsync();

            if (!saveResult)
            {
                throw new Exception("Error saving Driver");
            }

            var modelToReturn = _mapper.Map <DriverModel>(driverEntity);

            modelToReturn.BusinessId = businessId;
            return(modelToReturn);
        }