public async Task <CompanyViewModel> Create(CreateCompanyCommand command)
        {
            //arrange
            const int expectedNumberOfErrors = 0;

            //act
            var response = await appService.Create(command);

            //assert
            command.ValidateModelAnnotations().Count.Should().Be(expectedNumberOfErrors);
            response.Id.Should().NotBe(Guid.Empty);
            response.Name.Should().Be(command.Name);

            return(response);
        }
        public async Task <IHttpActionResult> CreateAsync([FromBody] CompanyCreate company)
        {
            var validationResults = new CompanyCreateValidator().Validate(company);

            if (!validationResults.IsValid)
            {
                return(this.BadRequest(string.Join(" , ", validationResults.Errors)));
            }

            var addressCreate = company.Address.ToEntity();
            var companyEntity = company.ToEntity(addressCreate);

            var createdCompany = await Task.Run(() => _companyAppService.Create(companyEntity));

            var companyRead = new CompanyRead(createdCompany);

            return(this.Ok(companyRead));
        }
Пример #3
0
        public IHttpActionResult CreateCompany(CompanyModel companyModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var companyDto = Mapper.Map <CompanyDto>(companyModel);

                _companyAppService.Create(companyDto, AuthHelper.GetCurrentUserId());

                return(Ok("Company Created"));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
        public async Task Create(CompanyDto companyDto)
        {
            companyDto.Logo = await SetLogo(companyDto.File);

            await _companyAppService.Create(companyDto);
        }
Пример #5
0
        public async Task <IActionResult> Create([FromBody] CreateCompanyCommand command)
        {
            var result = await appService.Create(command);

            return(Created(result.Id.ToString(), result));
        }
Пример #6
0
 public async Task <IActionResult> Post([FromBody] CreateCompanyCommand command)
 {
     return(Ok(await appService.Create(command)));
 }