public void Remove(Gift item)
 {
     try
     {
         _dbSet.Remove(item);
         _dbContext.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public bool Update(Gift item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("entityToUpdate");
            }

            _dbContext.Gifts.Attach(item);
            _dbContext.Entry(item).State = EntityState.Modified;
            _dbContext.SaveChanges();

            return true;
        }
        public Gift Add(Gift item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            item.Id = Tools.GetRandomKey();

            _dbSet.Add(item);
            _dbContext.SaveChanges();

            return item;
        }
        public async Task<IHttpActionResult> Post(Gift gift)
        {
            if (!ModelState.IsValid)
            {
                var errors = ModelState.SelectMany(x => x.Value.Errors.Select(z => z.Exception));
                return BadRequest(ModelState);
            }

            try
            {
                //Récupération de l'id de l'utilisateur en cours
                ApplicationUser user = System.Web.HttpContext.Current.GetOwinContext().GetUserManager<ApplicationUserManager>().FindById(System.Web.HttpContext.Current.User.Identity.GetUserId());
                gift.OwnerUserId = user.Id;

                Gift createdGift = repository.Add(gift);
                return Ok(createdGift);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            //return CreatedAtRoute("DefaultApi", new { id = product.ProductId }, product);
        }
        public IHttpActionResult PutGift(string id, Gift gift)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != gift.Id)
            {
                return BadRequest();
            }
                       
            try
            {
                if (!repository.Update(gift))
                {
                    throw new HttpResponseException(HttpStatusCode.NotFound);
                }                
            }
            catch (Exception ex) 
            {
                return NotFound();                
            }

            return StatusCode(HttpStatusCode.OK);
            
        }