コード例 #1
0
        public async Task <ServiceTypeDto> CreateAsync(ServiceTypeCreateDto item)
        {
            if (await _serviceTypeRepository.AnyServiceAsync(x => x.Name == item.Name))
            {
                throw new FieldLogicException($"Service type with name {item.Name} already exists!", nameof(item.Name));
            }

            var service = Mapper.Map <ServiceType>(item);

            _serviceTypeRepository.Create(service);
            await SaveProvider.SaveAsync();

            return(Mapper.Map <ServiceTypeDto>(service));
        }