public void TransferValue(string id) { int recordId = 0; var label = "TransferValue"; var response = new ApiResponse(); var entity = new MD.TransferValueProfile(); bool skippingCache = FormHelper.GetRequestKeyValue("skipCache", false); List <string> messages = new List <string>(); try { if (int.TryParse(id, out recordId)) { entity = API.TransferValueServices.GetDetailForAPI(recordId, skippingCache); } else if (ServiceHelper.IsValidCtid(id, ref messages)) { entity = API.TransferValueServices.GetDetailByCtidForAPI(id, skippingCache); } else { messages.Add("ERROR - Invalid request. Either provide a CTID which starts with 'ce-' or the number. "); } if (entity.Meta_Id == 0) { messages.Add(string.Format("ERROR - Invalid request - the {0} was not found. ", label)); } if (messages.Any()) { response.Successful = false; response.Messages.AddRange(messages); SendResponse(response); } else { //map to new ActivityServices.SiteActivityAdd(label, "View", "Detail", string.Format("User viewed {0}: {1} ({2})", label, entity.Name, entity.Meta_Id), 0, 0, recordId); response.Successful = true; response.Result = entity; SendResponse(response); } } catch (Exception ex) { LoggingHelper.LogError(ex, string.Format("API {0} Detail exception. Id: {1}", label, id)); response.Successful = false; response.Messages.Add(ex.Message); SendResponse(response); } }
private static WMA.TransferValueProfile MapToAPI(ThisEntity input) { var output = new WMA.TransferValueProfile() { Meta_Id = input.Id, CTID = input.CTID, Name = input.Name, FriendlyName = HttpUtility.UrlPathEncode(input.Name), Description = input.Description, SubjectWebpage = input.SubjectWebpage, EntityTypeId = 26, StartDate = input.StartDate, EndDate = input.EndDate, CredentialRegistryURL = RegistryServices.GetResourceUrl(input.CTID), RegistryData = ServiceHelper.FillRegistryData(input.CTID) }; if (input.OwningOrganizationId > 0) { output.OwnedByLabel = ServiceHelper.MapDetailLink("Organization", input.OrganizationName, input.OwningOrganizationId); } var orgOutline = ServiceHelper.MapToOutline(input.OwningOrganization, "organization"); //var work = ServiceHelper.MapOrganizationRoleProfileToOutline( input.OrganizationRole, Entity_AgentRelationshipManager.ROLE_TYPE_OWNER ); output.OwnedBy = ServiceHelper.MapOutlineToAJAX(orgOutline, "Owning Organization"); // // output.Identifier = ServiceHelper.MapIdentifierValue(input.Identifier); //transferValue output.TransferValue = ServiceHelper.MapValueProfile(input.TransferValue, ""); //for var work = new List <WMA.Outline>(); foreach (var target in input.TransferValueFor) { if (target != null && !string.IsNullOrWhiteSpace(target.Name)) { work.Add(ServiceHelper.MapToOutline(target, "")); } } output.TransferValueFor = ServiceHelper.MapOutlineToAJAX(work, "Includes {0} Transfer Value For"); //from work = new List <WMA.Outline>(); foreach (var target in input.TransferValueFrom) { if (target != null && !string.IsNullOrWhiteSpace(target.Name)) { work.Add(ServiceHelper.MapToOutline(target, "")); } } output.TransferValueFrom = ServiceHelper.MapOutlineToAJAX(work, "Includes {0} Transfer Value From"); // if (input.DevelopmentProcess.Any()) { output.DevelopmentProcess = ServiceHelper.MapAJAXProcessProfile("Development Process", "", input.DevelopmentProcess); } // output.InLanguage = null; return(output); }