public ActionResult <ProviderDTO> Get(string id) { try { var result = service.Get(id); return(mapper.Map <ProviderDTO>(result)); } catch (Exception) { return(StatusCode(500)); } }
public ActionResult Post([FromBody] ProductDTO value) { TryValidateModel(value); try { var product = this.mapper.Map <Product>(value); product.ProductType = productTypeService.Get(value.ProductTypeId); if (product.ProductType == null) { return(Ok(new { Success = false, Message = "ProductType not found" })); } product.Provider = providerService.Get(value.ProviderId); if (product.Provider == null) { return(Ok(new { Success = false, Message = "Provider not found" })); } this.service.Create(product); value.Id = product.Id; return(Ok(new { Success = true, Message = "", data = value })); } catch { return(Ok(new { Success = false, Message = "The name is already in use" })); } }
public async Task ShouldCallTheSelectByCnpj_WhenACnpjIsInformed() { ProviderService service = CreateServiceMock(); var document = "02.981.659/0001-00"; var result = await service.Get(document); _repositoryMock.Verify(repo => repo.SelectByCnpj(It.IsAny <string>()), Times.Once()); }
public void SearchProvider_FoundByTitleOrDescriptionProvider_ProviderWithId1() { var applicationContext = new ApplicationContext(); var providerRepository = new ProviderRepository(applicationContext); var providerService = new ProviderService(providerRepository, null, null, null); var expected = providerService.Get(1); var searchQuery = "provider"; var actual = providerService.SearchProvider(searchQuery).First(); Assert.AreEqual(expected.Id, actual.Id); }
public ActionResult <ProviderDTO> Get(string id) { try { var lookUpProvider = service.Get(id); return(this.mapper.Map <ProviderDTO>(lookUpProvider)); } catch { return(new StatusCodeResult(StatusCodes.Status500InternalServerError)); } }
public ActionResult <List <Provider> > Get() => _providerService.Get();