public IActionResult AddBrand([FromBody] BrandDTO brandDTO) { _logger?.LogInformation($"Inicio del servicio: [Post] https://localhost:5001/api/brands "); try { BrandMapper brandMapper = MapperFactory.CreateBrandMapper(); Entity entity = brandMapper.CreateEntity(brandDTO); _logger?.LogInformation($" Se transformó de DTO a Entity "); AddBrandCommand command = CommandFactory.CreateAddBrandCommand((Brand)entity); _logger?.LogInformation($" Ejecución del comando "); command.Execute(); return(Ok("ok " + command.GetResult())); } catch (RequiredAttributeException ex) { _logger?.LogWarning("Atributo requerido: " + ex.Message); return(StatusCode(400, ex.Message)); } catch (UniqueAttributeException ex) { _logger?.LogWarning(ex.Message); return(StatusCode(500, ex.Message)); } catch (InternalServerErrorException ex) { _logger?.LogError("Error: " + ex.Ex.Message); return(StatusCode(500, ex.Message)); } catch (Exception) { _logger?.LogError("Error inesperado"); return(StatusCode(400)); } }
public ItemsViewController(IAppBLL bll) { _bll = bll; _brandMapper = new BrandMapper(); _categoryMapper = new CategoryMapper(); _itemMapper = new ItemMapper(); }
public SearchPageController(IAppBLL bll) { _bll = bll; _brandMapper = new BrandMapper(); _categoryMapper = new CategoryMapper(); _itemMapper = new ItemMapper(); }
public IActionResult UpdateBrand([FromBody] BrandDTO brandDTO) { _logger?.LogInformation($"Inicio del servicio: [PUT] https://localhost:5001/api/brands/brandId "); try{ BrandMapper brandMapper = MapperFactory.CreateBrandMapper(); Entity entity = brandMapper.CreateEntity(brandDTO); _logger?.LogInformation($" Se transformó de DTO a Entity "); UpdateBrandCommand command = CommandFactory.CreateUpdateBrandCommand((Brand)entity); _logger?.LogInformation($" Ejecución del comando "); command.Execute(); if (command.GetResult()) { return(Ok("La modificación fue realizada exitosamente")); } else { return(StatusCode(400)); } } catch (RequiredAttributeException ex) { _logger?.LogWarning("Atributo requerido: " + ex.Message); return(StatusCode(400, ex.Message)); } catch (UniqueAttributeException ex) { _logger?.LogWarning(ex.Message); return(StatusCode(500, ex.Message)); } catch (BrandNotFoundException ex) { _logger?.LogWarning("La marca con Id : " + ex.BrandId + "no encontrado"); return(StatusCode(404, ex.Message + ex.BrandId)); } catch (InternalServerErrorException ex) { _logger?.LogError("Error: " + ex.Ex.Message); return(StatusCode(500, ex.Message)); } catch (Exception) { _logger?.LogError("Error inesperado"); return(StatusCode(400)); } }
public ICollection <TRelatedModel> GetRelated <TRelatedModel>(int objectID) where TRelatedModel : BusinessBase { IMapper mapper = null; if (typeof(TRelatedModel) == typeof(Brand)) { mapper = new BrandMapper(); } else if (typeof(TRelatedModel) == typeof(Cancellation)) { mapper = new CancellationMapper(); } if (typeof(TRelatedModel) == typeof(Contact)) { mapper = new ContactMapper(); } else if (typeof(TRelatedModel) == typeof(LegalCase)) { mapper = new LegalCaseMapper(); } else if (typeof(TRelatedModel) == typeof(Opposition)) { mapper = new OppositionMapper(); } else if (typeof(TRelatedModel) == typeof(TMRepresentative)) { mapper = new TMRepresentativeMapper(); } else if (typeof(TRelatedModel) == typeof(Trademark)) { mapper = new TrademarkMapper(); } else if (typeof(TRelatedModel) == typeof(TrademarkOwner)) { mapper = new TrademarkOwnerMapper(); } using (var repository = new Repository <TModel>(this._connectionString, mapper)) { return(repository.GetRelated <TRelatedModel>(objectID, mapper)); } }
public ActionResult <BrandDTO> GetBrandById(int brandId) { _logger?.LogInformation($"Inicio del servicio: [GET] https://localhost:5001/api/brands/brandId "); try { GetBrandByIdCommand command = CommandFactory.CreateGetBrandByIdCommand(brandId); _logger?.LogInformation($" Ejecución del comando "); command.Execute(); BrandMapper brandMapper = MapperFactory.CreateBrandMapper(); return(Ok(brandMapper.CreateDTO(command.GetResult()))); } catch (BrandNotFoundException ex) { _logger?.LogWarning("La marca con Id : " + ex.BrandId + "no encontrado"); return(StatusCode(404, ex.Message + ex.BrandId)); } catch (InternalServerErrorException ex) { _logger?.LogError("Error: " + ex.Ex.Message); return(StatusCode(500, ex.Message)); } catch (Exception) { _logger?.LogError("Error inesperado"); return(StatusCode(400)); } }
public ActionResult <IEnumerable <BrandDTO> > GetBrands() { _logger?.LogInformation($"Inicio del servicio: [GET] https://localhost:5001/api/brands "); List <Brand> brands = new List <Brand>(); try { BrandMapper brandMapper = MapperFactory.CreateBrandMapper(); GetBrandsCommand command = CommandFactory.CreateGetBrandsCommand(); _logger?.LogInformation($" Ejecución del comando "); command.Execute(); return(Ok(brandMapper.CreateDTOList(command.GetResult()))); } catch (WithoutExistenceOfBrandsException ex) { _logger?.LogWarning($"No existen marcas en la base de datos"); return(StatusCode(404, ex.Message)); } catch (InternalServerErrorException ex) { _logger?.LogError("Error: " + ex.Ex.Message); return(StatusCode(500, ex.Message)); } catch (Exception) { _logger?.LogError("Error inesperado"); return(StatusCode(400)); } }
/// <summary> /// Brands for customers /// </summary> /// <param name="bll"></param> public BrandsViewController(IAppBLL bll) { _bll = bll; _brandMapper = new BrandMapper(); }
public BrandMapperTest() { _brandMapper = new BrandMapper(); }