Пример #1
0
        public void Pathway(string id)
        {
            int recordId = 0;
            var label    = "Pathway";
            var response = new ApiResponse();

            var           entity        = new MD.Pathway();
            bool          skippingCache = FormHelper.GetRequestKeyValue("skipCache", false);
            List <string> messages      = new List <string>();

            try
            {
                if (int.TryParse(id, out recordId))
                {
                    entity = API.PathwayServices.GetDetailForAPI(recordId, skippingCache);
                }
                else if (ServiceHelper.IsValidCtid(id, ref messages))
                {
                    entity = API.PathwayServices.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);
            }
        }
Пример #2
0
        private static ThisEntityDetail MapToAPI(ThisEntity input)
        {
            var output = new ThisEntityDetail()
            {
                Meta_Id               = input.Id,
                CTID                  = input.CTID,
                Name                  = input.Name,
                FriendlyName          = HttpUtility.UrlPathEncode(input.Name),
                Description           = input.Description,
                SubjectWebpage        = input.SubjectWebpage,
                EntityTypeId          = 8,
                CredentialRegistryURL = RegistryServices.GetResourceUrl(input.CTID),
                RegistryData          = ServiceHelper.FillRegistryData(input.CTID)
            };

            return(output);
        }