public IHttpActionResult Put([FromODataUri] int key, Family family)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var currentFamily = _ctx.Families.FirstOrDefault(c => c.CategoryId == key);

            if (currentFamily == null)
            {
                return(NotFound());
            }

            family.FamilyId = currentFamily.FamilyId;


            _ctx.Entry(currentFamily).CurrentValues.SetValues(family);

            _ctx.SaveChanges();

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #2
0
        public IHttpActionResult Put([FromODataUri] int key, Catalog catalog)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var currentCatalog = _ctx.Catalogs.FirstOrDefault(c => c.CatalogId == key);

            if (currentCatalog == null)
            {
                return(NotFound());
            }

            catalog.CatalogId = currentCatalog.CatalogId;


            _ctx.Entry(currentCatalog).CurrentValues.SetValues(catalog);

            _ctx.SaveChanges();

            return(StatusCode(HttpStatusCode.NoContent));
        }