/// <summary> /// Updates the provided web resource /// </summary> /// <param name="wr">Web resource to update</param> internal void UpdateWebResource(WebResource wr) { try { if (wr.Id == Guid.Empty) { Entity existingEntity = RetrieveWebResource(wr.ToString()); if (existingEntity == null) { wr.Create(innerService); } else { wr.Id = existingEntity.Id; if (existingEntity.Contains("displayname") && string.IsNullOrEmpty(wr.EntityDisplayName)) { wr.EntityDisplayName = existingEntity.GetAttributeValue <string>("displayname"); } if (existingEntity.Contains("description") && string.IsNullOrEmpty(wr.EntityDescription)) { wr.EntityDescription = existingEntity.GetAttributeValue <string>("description"); } if (existingEntity.Contains("dependencyxml") && string.IsNullOrEmpty(wr.EntityDependencyXml)) { wr.EntityDependencyXml = existingEntity.GetAttributeValue <string>("dependencyxml"); } if (existingEntity.Contains("languagecode") && wr.EntityLanguageCode == 0) { wr.EntityLanguageCode = existingEntity.GetAttributeValue <int>("languagecode"); } wr.Update(innerService); } } else { wr.Update(innerService); } } catch (Exception error) { throw new Exception("Error while updating web resource: " + error.Message); } }