/// <summary author="Jared Greenfield" created="2019/02/09"> /// Updates an Offering with a new Offering. /// </summary> /// <updates> /// /// <update author="Jared Greenfield" date="2019/02/09"> /// Added IsValid() check /// </update> /// </updates> /// <param name="oldOffering">The old Offering.</param> /// <param name="newOffering">The updated Offering.</param> /// <exception cref="SQLException">Insert Fails (example of exception tag)</exception> /// <returns>True if the update was successful, false if not.</returns> public bool UpdateOffering(Offering oldOffering, Offering newOffering) { bool result = false; if (newOffering.IsValid()) { if (1 == _offeringAccessor.UpdateOffering(oldOffering, newOffering)) { result = true; } } else { throw new ArgumentException("Data for this New Offering is not valid."); } return(result); }
/// <summary author="Jared Greenfield" created="2019/01/25"> /// Adds a Recipe to the database and its lines. /// </summary> /// <updates> /// <update author="Jared Greenfield" date="2019/02/21"> /// Added the validation and exception throwing /// </update> /// <update author="Jared Greenfield" date="2019/03/05"> /// Added the optional offering validation if the offering wasn't null. Offerings are only needed /// in specific circumstances and the validation doesn't work if the Offering is null. /// </update> /// </updates> /// <param name="recipe">The new recipe.</param> /// <param name="item">The new Item object</param> /// <param name="offering">The new Offering object</param> /// <exception cref="SQLException">Insert Fails (example of exception tag)</exception> /// <returns>ID of Recipe.</returns> public int CreateRecipe(Recipe recipe, Item item, Offering offering) { int id = 0; if (item.CustomerPurchasable && offering != null) { if (recipe.IsValid() && item.IsValid() && offering.IsValid()) { try { id = _recipeAccessor.InsertRecipe(recipe, item, offering); } catch (Exception ex) { ExceptionLogManager.getInstance().LogException(ex); throw ex; } } else { throw new ArgumentException("Given inputs were invalid."); } } else { if (recipe.IsValid() && item.IsValid()) { try { id = _recipeAccessor.InsertRecipe(recipe, item, offering); } catch (Exception ex) { ExceptionLogManager.getInstance().LogException(ex); throw ex; } } else { throw new ArgumentException("Given inputs were invalid."); } } return(id); }
/// <summary author="Jared Greenfield" created="2019/01/26"> /// Adds an Offering to the database. /// </summary> /// <updates> /// <update author="Jared Greenfield" date="2019/02/09"> /// Added IsValid() check /// </update> /// </updates> /// <param name="offering">The Offering to be added.</param> /// <exception cref="SQLException">Insert Fails (example of exception tag)</exception> /// <returns>Id of Offering</returns> public int CreateOffering(Offering offering) { int returnedID = 0; if (offering.IsValid()) { try { returnedID = _offeringAccessor.InsertOffering(offering); } catch (Exception ex) { ExceptionLogManager.getInstance().LogException(ex); throw ex; } } else { throw new ArgumentException("Data for this Offering is not valid."); } return(returnedID); }