Esempio n. 1
0
        public IActionResult Update([FromBody]  RealizationItem realizationItem)
        {
            if (realizationItem == null)
            {
                return(BadRequest());
            }

            _context.Update(realizationItem);

            _context.SaveChanges();
            return(CreatedAtRoute("GetRealizationItem", new { id = realizationItem.Id }, realizationItem));
        }
Esempio n. 2
0
        public IActionResult Update([FromBody]  Category category)
        {
            if (category == null)
            {
                return(BadRequest());
            }

            var dbCategory = _context.Categories.Find(category.Id);

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


            dbCategory.Name = category.Name;

            _context.Update(dbCategory);
            _context.SaveChanges();
            return(CreatedAtRoute("GetCategory", new { id = category.Id }, category));
        }
Esempio n. 3
0
        public IActionResult Update([FromBody]  Objective objective)
        {
            if (objective == null)
            {
                return(BadRequest());
            }


            if (!_context.Objectives.Contains(objective))
            {
                return(NotFound());
            }


            _context.Entry(objective.Category).State = _context.Categories.Contains(objective.Category) ? EntityState.Modified : EntityState.Added;

            _context.Update(objective);

            _context.SaveChanges();
            return(CreatedAtRoute("GetObjective", new { id = objective.Id }, objective));
        }