コード例 #1
0
        public ManufacturerDto CreateManufacturer(ManufacturerDto manufacturerDto)
        {
            manufacturerDto.Slug = _slugService.CreateSlug(manufacturerDto.Name);
            var manufacturerToInsert = _mapper.Map <ManufacturerEntity>(manufacturerDto);
            var manufacturer         = _manufacturerRepository.Insert(manufacturerToInsert);

            return(_mapper.Map <ManufacturerDto>(manufacturer));
        }
コード例 #2
0
        public BikeModelDto CreateBikeModel(BikeModelDto bikeModelDto)
        {
            bikeModelDto.Slug = _slugService.CreateSlug(bikeModelDto.ModelName);

            if (_bikeModelRepository.GetBySlug(bikeModelDto.Slug) == null)
            {
                var modelToInsert = _mapper.Map <BikeModelEntity>(bikeModelDto);
                var model         = _bikeModelRepository.Insert(modelToInsert);
                return(_mapper.Map <BikeModelDto>(model));
            }
            else
            {
                throw new Exception();
            }
        }