public WebApiResponse GetSetting([FromBody] string[] keys) { WebApiResponse response = new WebApiResponse(); try { Dictionary <string, string> keyValues = new Dictionary <string, string>(keys.Length); // Try reading all keys from the database foreach (string key in keys) { keyValues.Add(key, UserManager.GetSetting(key, true)); } // construct response message response.Data = keyValues; response.Code = WebApiResponseCode.Ok; } catch (KeyNotExistException e) { response.Code = WebApiResponseCode.KeyNotExist; response.Data = e.Key; } catch (InvalidKeyException e) { response.Code = WebApiResponseCode.InvalidKey; response.Data = e.Key; } return(response); }
public WebApiResponse UpdateSetting(FormDataCollection keyValues) { WebApiResponse response = new WebApiResponse(); try { // Try updating all keys foreach (var pair in keyValues) { UserManager.UpdateSetting(pair.Key, pair.Value, true); } // construct response message response.Code = WebApiResponseCode.Ok; } catch (KeyNotExistException e) { response.Code = WebApiResponseCode.KeyNotExist; response.Data = e.Key; } catch (InvalidKeyException e) { response.Code = WebApiResponseCode.InvalidKey; response.Data = e.Key; } return(response); }
public WebApiResponse GetInitialConfiguration() { WebApiResponse response = new WebApiResponse(); try { response.Data = UserManager.GetInitialConfiguration(); response.Code = WebApiResponseCode.Ok; } catch (Exception) { response.Code = WebApiResponseCode.ServerError; } return(response); }
public WebApiResponse TryLogin([FromBody] string un, [FromBody] string pw, [FromBody] bool rm) { WebApiResponse response = new WebApiResponse(); if (Membership.ValidateUser(un, pw)) { // User cridentials is valid FormsAuthentication.SetAuthCookie(un, rm); // Construct response (We should send Initial Configuration to the clients) response.Code = WebApiResponseCode.Ok; } else { response.Code = WebApiResponseCode.InvalidUsernameOrPassword; } return(response); }
public WebApiResponse RemoveAllSettings(int giid) { WebApiResponse response = new WebApiResponse(); try { // perform the check checkCurrentUserHasPermissionOnGadgetInstance(giid); _gadgetInstanceManager.RemoveAllSetting(true); } catch (AccessDeniedException) { response.Code = WebApiResponseCode.AccessDenied; } catch (KeyNotExistException e) { response.Code = WebApiResponseCode.KeyNotExist; response.Data = e.keys; } return(response); }
public WebApiResponse GetSetting(int giid, [FromBody] string[] keys) { WebApiResponse response = new WebApiResponse(); try { // perform the check checkCurrentUserHasPermissionOnGadgetInstance(giid); // get setting // response message response.Data = _gadgetInstanceManager.GetSetting(keys, true); response.Code = WebApiResponseCode.Ok; } catch (AccessDeniedException) { response.Code = WebApiResponseCode.AccessDenied; } catch (KeyNotExistException e) { response.Code = WebApiResponseCode.KeyNotExist; response.Data = e.keys; } return(response); }
public WebApiResponse UpdateSetting(int giid, FormDataCollection keyValues) { WebApiResponse response = new WebApiResponse(); try { // perform the check checkCurrentUserHasPermissionOnGadgetInstance(giid); // update _gadgetInstanceManager.UpdateSetting(keyValues.ToArray(), true); // response message response.Code = WebApiResponseCode.Ok; } catch (AccessDeniedException) { response.Code = WebApiResponseCode.AccessDenied; } catch (KeyNotExistException e) { response.Code = WebApiResponseCode.KeyNotExist; response.Data = e.keys; } return(response); }