Esempio n. 1
0
        // PUT: odata/Stavke(5)
        /// <summary>
        /// Puts the specified key.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="delta">The delta.</param>
        /// <returns>
        /// Returns updated stavka
        /// </returns>
        public IHttpActionResult Put([FromODataUri] int key, Delta <Stavka> delta)
        {
            Validate(delta.GetEntity());

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            // Get the existing stavka from the database
            var stavkaToUpdate = stavkaRepository.GetById(key);

            //Overwrite existing data with the new one
            delta.Put(stavkaToUpdate);

            //Update the entity with new data
            stavkaRepository.Update(key, stavkaToUpdate);

            return(Updated(stavkaToUpdate));
        }