Exemplo n.º 1
0
 public IActionResult ChangeLevel(int id, UpdateLevelDTO lvl)
 {
     //Always keep the admin for one person
     _ctxt.User.Find(id).Level = lvl.Level;
     _ctxt.SaveChanges();
     return(Ok("The level has been updated! Keep an eye on it"));
 }
Exemplo n.º 2
0
        public ActionResult <Object> Put([FromBody] UpdateLevelDTO newLevelDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var levelFound = _repo.SelecionarPorNome(newLevelDTO.Name);

            if (levelFound == null)
            {
                return(NotFound(new { message = "Name '" + newLevelDTO.Name + "' not found!" }));
            }
            levelFound.Name = newLevelDTO.NewName;
            _repo.Alterar(levelFound);
            return(Ok(new { success = "Level updated!" }));
        }