/// <summary> /// Returns a Response XML element with the name of all properties /// of a collection or resource. /// </summary> /// <param name="url"></param> /// <param name="calendarResourceId"></param> /// <returns></returns> private async Task <XmlTreeStructure> PropNameFillTree(string url, string calendarResourceId = null) { #region Adding the response of the collection or resource. //A "response" structure with all its children is build in this method. var treeChild = new XmlTreeStructure("response", "DAV:"); #region Adding the <D:href>/api/v1/caldav/{userEmail}/calendars/{collectionName}/{calendarResourceId}?</D:href> var href = new XmlTreeStructure("href", "DAV:"); href.AddValue(SystemProperties._baseUrl + url); treeChild.AddChild(href); #endregion #region Adding the propstat //in this section is where the "propstat" structure its build. var propstat = new XmlTreeStructure("propstat", "DAV:"); #region Adding nested status //each "propstat" has a "status" with the message that define it. //"propname" is always "200 OK" because you are only accessing the name of the established properties. var status = new XmlTreeStructure("status", "DAV:"); status.AddValue("HTTP/1.1 200 OK"); propstat.AddChild(status); #endregion #region Adding nested prop var prop = new XmlTreeStructure("prop", "DAV:"); List <XmlTreeStructure> properties; //Depending if the target is a collection or a resource this section //will find the object in the database and get from there all names of properties. if (calendarResourceId == null) { //var collection = _collectionRepository.Get(url).Result; properties = (await _collectionRepository.GetAllPropname(url)).Select(p => new XmlTreeStructure(p.Key, p.Value)) .ToList(); //properties = collection.GetAllPropertyNames(); } else { properties = (await _resourceRespository.GetAllPropname(url)).Select(p => new XmlTreeStructure(p.Key, p.Value)) .ToList(); } //Here i add all properties to the prop. foreach (var property in properties) { prop.AddChild(property); } propstat.AddChild(prop); #endregion treeChild.AddChild(propstat); #endregion return(treeChild); #endregion }