/// <summary>
        /// Updates the specified DrinkingClub
        /// </summary>
        /// <param name="id">The DrinkingClub identifier.</param>
        /// <param name="drinkingClub">The drinkingClub.</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/drinkingclubs/{id}
        /// </remarks>
        public HttpResponseMessage Put(int id, DrinkingClub drinkingClub, bool updateGraph = false)
        {
            this.drinkingClubService.UpdateDrinkingClub(id, drinkingClub, updateGraph);

            // Success
            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
        /// <summary>
        /// Adds a new DrinkingClub
        /// </summary>
        /// <param name="drinkingClub">The DrinkingClub.</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/DrinkingClubs
        /// </remarks>
        public HttpResponseMessage Post(DrinkingClub drinkingClub, bool updateGraph = false)
        {
            int drinkingClubId = this.drinkingClubService.InsertDrinkingClub(drinkingClub, updateGraph);

            // Success, return a uri to the created resource in the response header
            var response = new HttpResponseMessage(HttpStatusCode.Created);

            response.Headers.Location = new Uri(this.Request.RequestUri.AbsoluteUri + "/" + drinkingClubId.ToString());

            return(response);
        }
        /// <summary>
        /// Updates the specified DrinkingClub.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <param name="drinkingClub">The DrinkingClub.</param>
        /// <param name="updateGraph">if set to <c>true</c> any child objects of the entity will also be persisted.</param>
        public void UpdateDrinkingClub(int id, DrinkingClub drinkingClub, bool updateGraph)
        {
            using (var unitOfWork = this.unitOfWorkFactory.Create())
            {
                // Get the entity repository
                IEntityRepository <DrinkingClub> entityRepository = unitOfWork.GetRepository <DrinkingClub, int>();

                // Update the entity
                if (updateGraph)
                {
                    entityRepository.InsertOrUpdateGraph(drinkingClub);
                }
                else
                {
                    entityRepository.Update(drinkingClub);
                }

                // Persist the changes
                unitOfWork.Save();
            }
        }
        /// <summary>
        /// Adds the DrinkingClub to the database.
        /// </summary>
        /// <param name="drinkingClub">The DrinkingClub.</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 drinkingClub added to database</returns>
        public int InsertDrinkingClub(DrinkingClub drinkingClub, bool updateGraph)
        {
            using (var unitOfWork = this.unitOfWorkFactory.Create())
            {
                // Get the entity repository
                IEntityRepository <DrinkingClub> entityRepository = unitOfWork.GetRepository <DrinkingClub, int>();

                // Insert the entity
                if (updateGraph)
                {
                    // Update any entities in the graph
                    entityRepository.InsertOrUpdateGraph(drinkingClub);
                }
                else
                {
                    // Update just the root entity
                    entityRepository.Insert(drinkingClub);
                }

                // Persist the changes and return Id
                return(unitOfWork.Save().GetInsertedEntityKey <int>("DrinkingClubs"));
            }
        }
 public DrinkingClubDto(DrinkingClub dc)
 {
     this.Id   = dc.Id;
     this.Name = dc.Name;
 }