public HttpResponseMessage UpdateRole([FromBody] Authentication role, int id)
        {
            try
            {
                var form = new Dictionary <string, string>
                {
                    { "Role", "(required) Type:String" }
                };

                if (role.Role == null || (role.Role != "Admin" && role.Role != "User"))
                {
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, form));
                }

                Authentication utilizadorToUpdate = Authentication.GetUtilizadorById(id);
                utilizadorToUpdate.Role = role.Role;

                Utilizador utilizador = Utilizador.UpdateUtilizadorById(utilizadorToUpdate, id, "Admin");
                if (utilizador == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, form));
                }

                return(Request.CreateResponse(HttpStatusCode.OK, utilizador));
            }
            catch (Exception exception)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, exception));
            }
        }
        public HttpResponseMessage UpdateMyself([FromBody] Authentication user)
        {
            try
            {
                var form = new Dictionary <string, string>
                {
                    { "Nome", "(required) Type:String" },
                    { "Username", "(required UNIQUE) Type:String" },
                    { "Email", "(required UNIQUE) Type:String" },
                    { "Password", "(required) Type:String" }
                };

                if (user == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, form));
                }

                var    identity = (ClaimsPrincipal)Thread.CurrentPrincipal;
                int    id       = int.Parse(identity.Claims.Where(c => c.Type == ClaimTypes.Sid).Select(c => c.Value).SingleOrDefault());
                string role     = identity.Claims.Where(c => c.Type == ClaimTypes.Role).Select(c => c.Value).FirstOrDefault();

                Utilizador utilizador = Utilizador.UpdateUtilizadorById(user, id, role);
                if (utilizador == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, form));
                }

                return(Request.CreateResponse(HttpStatusCode.OK, utilizador));
            }
            catch (Exception exception)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, exception));
            }
        }