public ProviderViewModel CreateProvider(ProviderViewModel viewModel)
        {
            var provider = ProviderMappers.Map <ProviderViewModel, Provider>(viewModel);

            provider.IsMigrated = true;

            provider = _providerService.CreateProvider(provider);

            return(ProviderMappers.Map <Provider, ProviderViewModel>(provider));
        }
Exemple #2
0
        public async Task <ActionResult <Provider> > PostProvider([FromBody] PostProviderDTO provider)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            var mappedProvider = mapper.Map <PostProviderDTO, Provider>(provider);
            await providerService.CreateProvider(mappedProvider);

            return(Ok());
        }
 private IHttpActionResult TryToCreateProviderWhileCheckingForUnauthorizedAccessException(Provider newProvider)
 {
     try
     {
         int id = providerService.CreateProvider(newProvider, signedInUsername);
         return(CreatedAtRoute("TodoPagosApi", new { id = newProvider.ID }, newProvider));
     }
     catch (UnauthorizedAccessException)
     {
         return(Unauthorized());
     }
 }
Exemple #4
0
        public async Task <IActionResult> Post([FromBody] ProviderVM provider)
        {
            try
            {
                var id = await _providerService.CreateProvider(provider);

                return(Json(new { Id = id.ToString() }));
            }
            catch (Exception ex)
            {
                return(BadRequest($"Something went wrong {ex.Message}"));
            }
        }
        public IActionResult CreateProvider([FromBody] ProviderDtoForCreation payload)
        {
            var finalProvider = _mapper
                                .Map <Provider>(payload);

            _providerService.CreateProvider(finalProvider);

            var createdProviderToReturn = _mapper
                                          .Map <ProviderDto>(finalProvider);

            return(CreatedAtRoute(
                       "GetProvider",
                       new { id = finalProvider.Id },
                       createdProviderToReturn));
        }
        public IActionResult CreateProvider(ProviderDTO providerDTO)
        {
            if (!ModelState.IsValid)
            {
                _logger.LogWarning(HttpStatusCode.BadRequest.ToString());
                return(BadRequest(HttpStatusCode.BadRequest));
            }

            var provider = _providerService.CreateProvider(providerDTO);

            if (provider == null)
            {
                _logger.LogWarning(HttpStatusCode.BadRequest.ToString());
                return(BadRequest(HttpStatusCode.BadRequest));
            }

            return(Ok(provider));
        }