public ProductsModel GetProduct(int id) { try { var product = _productsRepository.GetByID(id); return(new ProductsModel { Discontinued = product.Discontinued, ProductName = product.ProductName, QuantityPerUnit = product.QuantityPerUnit, ReorderLevel = product.ReorderLevel, UnitPrice = product.UnitPrice, UnitsInStock = product.UnitsInStock, UnitsOnOrder = product.UnitsOnOrder, ProductId = product.ProductId, Category = product.CategoryId.HasValue ? new CategoriesModel(product.CategoryId.Value) : new CategoriesModel(), Supplier = product.SupplierId.HasValue ? new SuppliersModel(product.SupplierId.Value) : new SuppliersModel() }); } catch (Exception e) { Log.Error("Product service error!" + Environment.NewLine + $"{e}"); throw; } }
public Stream GetCategoryImageStream(int categoryId) { try { return(new MemoryStream(_categoriesRepository.GetByID(categoryId).Picture)); } catch (Exception e) { Log.Error("Category service error!" + Environment.NewLine + $"{e}"); throw; } }