Beispiel #1
0
        public IActionResult PostUpdateUser([FromBody] UserViewModel userVmdl)
        {
            try
            {
                Person user;
                if (_bl.IsAdmin || _bl.IsVerwalter)
                {
                    user = _bl.GetUsers(_bl.GetCurrentUid());
                }
                else
                {
                    user = _bl.GetUsers(userVmdl.Uid);
                }


                userVmdl.ApplyChangesTelRoom(user);
                userVmdl.Refresh(user);
                _bl.SaveChanges();
                _log.LogInformation("User '{0}' updated by '{1}'", userVmdl.Uid, User.Identity.Name);

                return(Ok(userVmdl));
            }
            catch (SecurityException)
            {
                _log.LogWarning("'{0}' tried to Update user '{1}'", _bl.GetCurrentUid(), userVmdl.Uid);
                return(Unauthorized());
            }
            catch (Exception ex)
            {
                _log.LogError("Exception: {0}", ex);
                return(StatusCode(500));
            }
        }