Ejemplo n.º 1
0
        public IHttpActionResult Put(int id, [FromBody] MajorDto form)
        {
            if (ModelState.IsValid)
            {
                var majorInDb = _majorService.Get(id);

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

                try
                {
                    Mapper.Map(form, majorInDb);

                    _majorService.Update(majorInDb);

                    return(Ok());
                }
                catch (ForeignKeyEntityException fkee)
                {
                    ModelState.AddModelError("", fkee.Message);
                }
            }

            return(BadRequest(ModelState));
        }
Ejemplo n.º 2
0
 public IActionResult Put(int id, [FromBody] Major major)
 {
     majorService.Update(major);
     return(Ok());
 }