public static UpdateAssetDataResponse UpdateAssetData(string Title, string Description, string Keywords, string License, string pid) { APIWrapper api = null; if (Membership.GetUser() != null && Membership.GetUser().IsApproved) api = new APIWrapper(Membership.GetUser().UserName, null); else api = new APIWrapper(vwarDAL.DefaultUsers.Anonymous[0], null); vwar.service.host.Metadata md = api.GetMetadata(pid, "00-00-00"); if(md == null) return new UpdateAssetDataResponse(false); UpdateAssetDataResponse response = new UpdateAssetDataResponse(true); response.Keywords = md.Keywords.Split(new char[] { ',', '|' }); for (int i = 0; i < response.Keywords.Length; i++) response.Keywords[i] = response.Keywords[i].ToLower().Trim(); switch (License.ToLower().Trim()) { case "by-nc-sa": response.LicenseURL = "http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode"; response.LicenseImage = "../styles/images/by-nc-sa.png"; response.LicenseTitle = "by-nc-sa"; break; case "by-nc-nd": response.LicenseURL = "http://creativecommons.org/licenses/by-nc-nd/3.0/legalcode"; response.LicenseImage = "../styles/images/by-nc-nd.png"; response.LicenseTitle = "by-nc-nd"; break; case "by-nc": response.LicenseURL = "http://creativecommons.org/licenses/by-nc/3.0/legalcode"; response.LicenseImage = "../styles/images/by-nc.png"; response.LicenseTitle = "by-nc"; break; case "by-nd": response.LicenseURL = "http://creativecommons.org/licenses/by-nd/3.0/legalcode"; response.LicenseImage = "../styles/images/by-nd.png"; response.LicenseTitle = "by-nd"; break; case "by-sa": response.LicenseURL = "http://creativecommons.org/licenses/by-sa/3.0/legalcode"; response.LicenseImage = "../styles/images/by-sa.png"; response.LicenseTitle = "by-sa"; break; case "publicdomain": response.LicenseURL = "http://creativecommons.org/publicdomain/mark/1.0/"; response.LicenseImage = "../styles/images/publicdomain.png"; response.LicenseTitle = "Public Domain"; break; case "by": response.LicenseURL = "http://creativecommons.org/licenses/by/3.0/legalcode"; response.LicenseImage = "../styles/images/by.png"; response.LicenseTitle = "by"; break; } md.Title = Title; md.Description = Description; md.Keywords = Keywords; md.License = response.LicenseURL; response.Title = md.Title; response.Description = md.Description; string result = api.UpdateMetadata(md, pid, "00-00-00"); if(result != "Ok") return new UpdateAssetDataResponse(false); return response; }
public static UpdateAssetDataResponse UpdateAssetData(string Title, string Description, string Keywords, string License, string pid) { APIWrapper api = null; if (Membership.GetUser() != null && Membership.GetUser().IsApproved) { api = new APIWrapper(Membership.GetUser().UserName, null); } else { api = new APIWrapper(vwarDAL.DefaultUsers.Anonymous[0], null); } vwar.service.host.Metadata md = api.GetMetadata(pid, "00-00-00"); if (md == null) { return(new UpdateAssetDataResponse(false)); } UpdateAssetDataResponse response = new UpdateAssetDataResponse(true); response.Keywords = md.Keywords.Split(new char[] { ',', '|' }); for (int i = 0; i < response.Keywords.Length; i++) { response.Keywords[i] = response.Keywords[i].ToLower().Trim(); } switch (License.ToLower().Trim()) { case "by-nc-sa": response.LicenseURL = "http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode"; response.LicenseImage = "../styles/images/by-nc-sa.png"; response.LicenseTitle = "by-nc-sa"; break; case "by-nc-nd": response.LicenseURL = "http://creativecommons.org/licenses/by-nc-nd/3.0/legalcode"; response.LicenseImage = "../styles/images/by-nc-nd.png"; response.LicenseTitle = "by-nc-nd"; break; case "by-nc": response.LicenseURL = "http://creativecommons.org/licenses/by-nc/3.0/legalcode"; response.LicenseImage = "../styles/images/by-nc.png"; response.LicenseTitle = "by-nc"; break; case "by-nd": response.LicenseURL = "http://creativecommons.org/licenses/by-nd/3.0/legalcode"; response.LicenseImage = "../styles/images/by-nd.png"; response.LicenseTitle = "by-nd"; break; case "by-sa": response.LicenseURL = "http://creativecommons.org/licenses/by-sa/3.0/legalcode"; response.LicenseImage = "../styles/images/by-sa.png"; response.LicenseTitle = "by-sa"; break; case "publicdomain": response.LicenseURL = "http://creativecommons.org/publicdomain/mark/1.0/"; response.LicenseImage = "../styles/images/publicdomain.png"; response.LicenseTitle = "Public Domain"; break; case "by": response.LicenseURL = "http://creativecommons.org/licenses/by/3.0/legalcode"; response.LicenseImage = "../styles/images/by.png"; response.LicenseTitle = "by"; break; } md.Title = Title; md.Description = Description; md.Keywords = Keywords; md.License = response.LicenseURL; response.Title = md.Title; response.Description = md.Description; string result = api.UpdateMetadata(md, pid, "00-00-00"); if (result != "Ok") { return(new UpdateAssetDataResponse(false)); } return(response); }