/// <summary>
        /// Method is used a a constructor, because the constructor needs to be parameterless
        /// </summary>
        public void InitVm(Municipality m)
        {
            _model = m;

            // URL for testserver
           //_model.APIUrl = "http://os2indberetningmobil/api";

            _storage = DependencyService.Get<ISecureStorage>();
        }
 /// <summary>
 /// Method is used as a constructor. The real constructor needs to be parameterless
 /// </summary>
 /// <param name="m">Municipality that the user is trying to couple with</param>
 public void SetMunicipality(Municipality m)
 {
     _municipality = m;
     Definitions.TextColor = _municipality.TextColor;
     Definitions.PrimaryColor = _municipality.PrimaryColor;
     Definitions.SecondaryColor = _municipality.SecondaryColor;
     Definitions.MunIcon = new UriImageSource {Uri = new Uri(m.ImgUrl)};
     Definitions.MunUrl = _municipality.APIUrl;
     this.Content = SetContent();
 }
        /// <summary>
        /// Fetches the UserInfoModel belonging to the token.
        /// </summary>
        /// <param name="authorization">the token belonging to the user.</param>
        /// <param name="mun">the Municipality the user belongs to.</param>
        /// <returns>ReturnUserModel</returns>
        public static async Task<ReturnUserModel> RefreshModel(Authorization authorization, Municipality mun)
        {
            var model = new ReturnUserModel();
            try
            {
                HttpClientHandler handler = new HttpClientHandler();
                _httpClient = new HttpClient(handler);
                HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, mun.APIUrl + "/userInfo");

                var json = JsonConvert.SerializeObject(authorization);

                var stringContent = new StringContent(json, Encoding.UTF8, "application/json");
                request.Content = stringContent;

                // Send request
                HttpResponseMessage response = await _httpClient.SendAsync(request);
                
                // Read response
                string jsonString = await response.Content.ReadAsStringAsync();
                var isValid = IsValidJson(jsonString);

                if (response.IsSuccessStatusCode && isValid)
                {
                    // Deserialize string to object
                    UserInfoModel user = JsonConvert.DeserializeObject<UserInfoModel>(jsonString);
                    user = RemoveTrailer(user);
                    model.User = user;
                    model.Error = new Error(); // tom
                }
                else if (string.IsNullOrEmpty(jsonString) || !isValid)
                {
                    model.Error = new Error
                    {
                        Message = "Netværksfejl",
                        ErrorCode = "404",
                    };
                    model.User = null;
                }
                else if (!response.IsSuccessStatusCode)
                {
                    model.Error = DeserializeError(jsonString);
                    model.User = null;
                }

                //return model;
                return model;
                
                
            }
            catch (Exception e)
            {
                model.User = null;
                model.Error = new Error
                {
                    Message = e.Message,
                };
                return model;
            }
        }