예제 #1
0
        public async Task <string> Create(CreateCompanyVm vm)
        {
            if (await _companyRepository.IsNameDuplicate(vm.Name))
            {
                throw new Exception($"'{vm.Name}' already exists. Please choose a different name.");
            }
            var company = new Core.Model.Company(vm.Name);

            _companyRepository.Add(company);
            await _companyRepository.SaveChanges();

            return(company.Id);
        }
예제 #2
0
        public void Add_Business(string name)
        {
            // Arrange

            var model = new CreateCompanyVm
            {
                Name = name,
            };

            // Act
            var id = _commandService.Create(model).Result;

            var result = _context.Company.First(x => x.Id == id);

            // Assert
            result.Should().NotBeNull();
            result.Name.Should().Be(model.Name);
        }
 public async Task <string> Add([Service] ICompanyCommandService service, CreateCompanyVm model)
 {
     return(Ok(await service.Create(model)));
 }
예제 #4
0
 public async Task <string> Create(CreateCompanyVm vm)
 {
     return(await _command.Create(vm));
 }