/// <summary> /// Updates the specified EventBeverage /// </summary> /// <param name="id">The EventBeverage identifier.</param> /// <param name="eventBeverage">The eventBeverage.</param> /// <param name="updateGraph">if set to <c>true</c> any child objects of the entity will also be persisted.</param> /// <returns> /// A HttpResponseMessage containing the result of the PUT /// </returns> /// <remarks> /// PUT: api/eventbeverages/eventbeverages/{id} /// </remarks> public HttpResponseMessage Put(int id, EventBeverage eventBeverage, bool updateGraph = false) { this.eventBeverageService.UpdateEventBeverage(id, eventBeverage, updateGraph); // Success return(new HttpResponseMessage(HttpStatusCode.OK)); }
/// <summary> /// Adds a new EventBeverage /// </summary> /// <param name="eventBeverage">The EventBeverage.</param> /// <param name="updateGraph">if set to <c>true</c> any child objects of the entity will also be persisted.</param> /// <returns> /// A HttpResponseMessage containing the result of the POST /// </returns> /// <remarks> /// POST: api/eventbeverages/EventBeverages /// </remarks> public HttpResponseMessage Post(EventBeverage eventBeverage, bool updateGraph = false) { int eventBeverageId = this.eventBeverageService.InsertEventBeverage(eventBeverage, updateGraph); // Success, return a uri to the created resource in the response header HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.Created); response.Headers.Location = new Uri(this.Request.RequestUri.AbsoluteUri + "/" + eventBeverageId.ToString()); return(response); }
/// <summary> /// Updates the specified EventBeverage. /// </summary> /// <param name="id">The identifier.</param> /// <param name="eventBeverage">The EventBeverage.</param> /// <param name="updateGraph">if set to <c>true</c> any child objects of the entity will also be persisted.</param> public void UpdateEventBeverage(int id, EventBeverage eventBeverage, bool updateGraph) { using (var unitOfWork = this.unitOfWorkFactory.Create()) { // Get the entity repository IEntityRepository <EventBeverage> entityRepository = unitOfWork.GetRepository <EventBeverage, int>(); // Update the entity if (updateGraph) { entityRepository.InsertOrUpdateGraph(eventBeverage); } else { entityRepository.Update(eventBeverage); } // Persist the changes unitOfWork.Save(); } }
/// <summary> /// Adds the EventBeverage to the database. /// </summary> /// <param name="eventBeverage">The EventBeverage.</param> /// <param name="updateGraph">if set to <c>true</c> any child objects of the entity will also be persisted.</param> /// <returns>The identifier of the eventBeverage added to database</returns> public int InsertEventBeverage(EventBeverage eventBeverage, bool updateGraph) { using (var unitOfWork = this.unitOfWorkFactory.Create()) { // Get the entity repository IEntityRepository <EventBeverage> entityRepository = unitOfWork.GetRepository <EventBeverage, int>(); // Insert the entity if (updateGraph) { // Update any entities in the graph entityRepository.InsertOrUpdateGraph(eventBeverage); } else { // Update just the root entity entityRepository.Insert(eventBeverage); } // Persist the changes and return Id return(unitOfWork.Save().GetInsertedEntityKey <int>("EventBeverages")); } }