public void Put(ProductBll model) { if (model.Name == null || model.Category == null) { throw new InvalidProductExeptions("The required fields are missing"); } try { var product = new ProductBll() { Id = model.Id, Category = model.Category, Name = model.Name, Price = model.Price }; Products.ToList().Add(product); } catch (InvalidProductExeptions) { throw new InvalidProductExeptions("The required fields are missing"); } catch (NullReferenceException ex) { throw new NullReferenceException($"Exception caught: {ex}"); } catch (Exception ex) { throw new Exception($"Exception occurred: {ex}"); } }
public void Post(ProductBll model) { if (model.Name == null) { throw new InvalidProductExeptions("Unable to add product without name"); } try { var product = new ProductBll() { Id = model.Id, Category = model.Category, Name = model.Name, Price = model.Price }; Products.ToList().Add(product); } catch (InvalidProductExeptions) { throw new InvalidProductExeptions("Unable to add product without name"); } catch (NullReferenceException ex) { throw new NullReferenceException($"Exception caught: {ex}"); } catch (Exception ex) { throw new Exception($"Exception occurred: {ex}"); } }