public bool RetrieveExpressImportStatus()
        {
            try
            {
                var headerValues = Request.Headers.GetValues("Authorization");
                var token = headerValues.FirstOrDefault();
                var credentialsFromToken = Token.GetCredentialsFromToken(token);

                var siteUrl = ConfigurationManager.AppSettings["url"];
                var sharepointContext = new SharepointContext(siteUrl, credentialsFromToken[0], credentialsFromToken[1]);

                var streamReader = new StreamReader(HttpContext.Current.Request.InputStream);
                var retrievedPostData = streamReader.ReadToEnd();
                var jObject = JObject.Parse(retrievedPostData);
                var resourceId = (string)jObject["resourceId"];

                var query = string.Format(Query.ExpressImport, resourceId);
                var retrievedListItems = sharepointContext.RetrieveListItems(query, List.ExpressImports);

                return retrievedListItems.ToList().Count != 0;
            }
            catch (Exception)
            {
                return false;
                throw;
            }
        }
        public bool AddExpressImportEntry()
        {
            try
            {
                var headerValues = Request.Headers.GetValues("Authorization");
                var token = headerValues.FirstOrDefault();
                var credentialsFromToken = Token.GetCredentialsFromToken(token);

                var siteUrl = ConfigurationManager.AppSettings["url"];
                var sharepointContext = new SharepointContext(siteUrl, credentialsFromToken[0], credentialsFromToken[1]);

                var streamReader = new StreamReader(HttpContext.Current.Request.InputStream);
                var retrievedPostData = streamReader.ReadToEnd();
                var jObject = JObject.Parse(retrievedPostData);
                var resourceId = (int)jObject["resourceId"];
                var startDate = (DateTime)jObject["startDate"];
                var endDate = (DateTime)jObject["endDate"];

                var addValuesDictionary = new Dictionary<string, object>
                {
                    {Column.ResourceKey, new FieldLookupValue { LookupId = resourceId }},
                    {Column.ImportFromDate,startDate },
                    {Column.ImportToDate,endDate}
                };

                sharepointContext.AddListItem(List.ExpressImports, addValuesDictionary);

                return true;

            }
            catch (IdcrlException)
            {
                return false;
            }
        }
        public List<CustomerModel> GetProjectsList()
        {
            try
            {
                var headerValues = Request.Headers.GetValues("Authorization");
                var token = headerValues.FirstOrDefault();
                var credentialsFromToken = Token.GetCredentialsFromToken(token);

                var siteUrl = ConfigurationManager.AppSettings["url"];
                var sharepointContext = new SharepointContext(siteUrl, credentialsFromToken[0], credentialsFromToken[1]);

                var retrievedListItems = sharepointContext.RetrieveListItems(Query.Customers, List.Customers);
                var customerList = retrievedListItems.Select(item => new CustomerModel(item)).ToList();

                return customerList.Count == 0 ? null : customerList;
            }
            catch (IdcrlException)
            {
                return null;
            }
            catch (InvalidOperationException)
            {
                return null;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public List<ResourceModel> GetAuthenticationWithToken()
        {
            try
            {
                var headerValues = Request.Headers.GetValues("Authorization");
                var token = headerValues.FirstOrDefault();

                var siteUrl = ConfigurationManager.AppSettings["url"];
                var credentialsFromToken = Token.GetCredentialsFromToken(token);
                var sharepointContext = new SharepointContext(siteUrl, credentialsFromToken[0], credentialsFromToken[1]);
                var query = string.Format(Query.ResourceId, credentialsFromToken[0]);

                const string listTitle = List.Resources;

                var retrievedListItems = sharepointContext.RetrieveListItems(query, listTitle);
                var idList = retrievedListItems.Select(item => new ResourceModel(item)).ToList();

                return idList.Count == 0 ? null : idList;
            }
            catch (IdcrlException)
            {
                return null;
            }
        }
        public List<ResourceModel> AuthenticationWithCredentials()
        {
            try
            {
                var streamReader = new StreamReader(HttpContext.Current.Request.InputStream);
                var retrievedPostData = streamReader.ReadToEnd();
                var jObject = JObject.Parse(retrievedPostData);
                var username = Token.DecryptStringAes((string)jObject["username"]);
                var password = Token.DecryptStringAes((string)jObject["password"]);

                var siteUrl = ConfigurationManager.AppSettings["url"];
                var sharepointContext = new SharepointContext(siteUrl, username, password);
                var query = string.Format(Query.ResourceId, username);

                var retrievedListItems = sharepointContext.RetrieveListItems(query, List.Resources);
                var idList = retrievedListItems.Select(item => new ResourceModel(item)).ToList();

                return idList.Count == 0 ? null : idList;
            }
            catch (IdcrlException)
            {
                return null;
            }
        }
        private SharepointContext CreateSharepointContext()
        {
            var credentialsFromToken = GetCredentialsFromHeader();
            var siteUrl = ConfigurationManager.AppSettings["url"];
            var sharepointContext = new SharepointContext(siteUrl, credentialsFromToken[0], credentialsFromToken[1]);

            return sharepointContext;
        }