public void Delete(int id) { CategoryDetailRepository categoryDetailRepository; BlobFileBO blobFileBO; CategoryDetail categoryDetail; try { if (id == 0) { throw new Exception("ID inválido"); } else { categoryDetailRepository = new CategoryDetailRepository(_loggerFactory, _config); blobFileBO = new BlobFileBO(_loggerFactory, _config); categoryDetail = Get(id); if (categoryDetail != null) { if (!string.IsNullOrEmpty(categoryDetail.TitleIconID)) { blobFileBO.Delete(categoryDetail.TitleIconID); } categoryDetailRepository.Delete(id); } } } catch (Exception ex) { throw ex; } }
public List <CategoryDetail> Get(int?categoryID = null) { CategoryDetailRepository categoryDetailRepository; List <CategoryDetail> categoryDetails; try { categoryDetailRepository = new CategoryDetailRepository(_loggerFactory, _config); categoryDetails = categoryDetailRepository.Get(categoryID); } catch (Exception ex) { throw ex; } return(categoryDetails); }
public CategoryDetail Get(int id) { CategoryDetailRepository categoryDetailRepository; ProductBO productBO; CategoryDetail categoryDetail; try { categoryDetailRepository = new CategoryDetailRepository(_loggerFactory, _config); productBO = new ProductBO(_loggerFactory, _config); categoryDetail = categoryDetailRepository.Get(id); categoryDetail.Products = productBO.Get(categoryDetailID: categoryDetail.ID); } catch (Exception ex) { throw ex; } return(categoryDetail); }
public CategoryDetail Update(CategoryDetail categoryDetail) { CategoryDetailRepository categoryDetailRepository; try { categoryDetailRepository = new CategoryDetailRepository(_loggerFactory, _config); if (categoryDetail.ID == 0) { throw new Exception("ID diferente de 0, avalie a utilização do POST"); } else { categoryDetailRepository.Update(categoryDetail); } } catch (Exception ex) { throw ex; } return(categoryDetail); }