示例#1
0
 // Logoff User
 public async Task Logout()
 {
     // Only if Login was successfull
     if (LoginAPICallStatus == HttpStatusCode.OK)
     {
         //IDMToolsAsync.UserCredentials = UserCredentials;
         LogoutAPICallStatus = await IDMToolsAsync.Logout();
     }
 }
示例#2
0
        // Retrieve Entities + status of API call
        // If parameter "force" is true = always do request
        // P.S. Authorization NOT needed
        public async Task RetrieveEntities(bool force = false)
        {
            Tuple <RootObjectEntities, HttpStatusCode> responce = null;

            if (force || Entities.Count <= 0)
            {
                responce = await IDMToolsAsync.GetEntitiesAsync();

                // Get responce values
                Entities = responce.Item1.entities.entity;
                RetriveEntitiesAPICallStatus = responce.Item2;
            }
        }
示例#3
0
        // Create Item + status of API call
        // P.S. Authorization needed
        public async Task CreateItem(ItemCreate item)
        {
            Tuple <HttpStatusCode, Error> responce;

            try
            {
                // Login user
                await Login();

                // If Login successfull, go on and create item
                if (LoginAPICallStatus == HttpStatusCode.OK)
                {
                    // Wrap item with root element (for JSON formating during serialization)
                    RootObjectItemCreate rootObjectItemCreate = new RootObjectItemCreate(item);

                    responce = await IDMToolsAsync.CreateItemAsync(rootObjectItemCreate);

                    // Get responce values
                    CreateItemAPICallStatus        = responce.Item1;
                    CreateItemAPICallResponceError = responce.Item2;
                }
                // If not... do whatever you want, just not cry... take a candy ;)
                else
                {
                }
            }
            catch (Exception)
            {
                // handle Exception here
                throw;
            }
            finally
            {
                // Logout user
                await Logout();
            }
        }
示例#4
0
 // Login User
 public async Task Login()
 {
     IDMToolsAsync.UserCredentials = UserCredentials;
     LoginAPICallStatus            = await IDMToolsAsync.Login();
 }