/// <summary>
 /// Set reference relation types for specified locale.
 /// </summary>
 /// <param name="referenceRelationTypes">Reference relation types.</param>
 /// <param name="locale">Currently used locale.</param>
 protected override void SetReferenceRelationTypes(ReferenceRelationTypeList referenceRelationTypes, ILocale locale)
 {
     lock (ReferenceRelationTypes)
     {
         ReferenceRelationTypes[locale.ISOCode] = referenceRelationTypes;
     }
 }
        /// <summary>
        /// The get reference list.
        /// </summary>
        /// <param name="guid">
        /// The guid.
        /// </param>
        /// <returns>
        /// The <see cref="List"/>.
        /// </returns>
        private List <ReferenceViewModel> GetReferenceList(string guid)
        {
            ReferenceRelationTypeList referenceTypes = CoreData.ReferenceManager.GetReferenceRelationTypes(user);
            ReferenceRelationList     references     = CoreData.ReferenceManager.GetReferenceRelations(user, guid);
            var list = new List <ReferenceViewModel>();

            foreach (IReferenceRelation referenceRelation in references)
            {
                var reference = referenceRelation.GetReference(user);

                IReferenceRelationType referenceType;
                referenceType = null;
                foreach (IReferenceRelationType tempReferenceRelationType in referenceTypes)
                {
                    if (tempReferenceRelationType.Id == referenceRelation.Type.Id)
                    {
                        referenceType = tempReferenceRelationType;
                    }
                }

                if (referenceType.IsNull())
                {
                    referenceType = referenceTypes[0];
                }

                Int32 year = reference.Year.HasValue ? reference.Year.Value : -1;
                list.Add(new ReferenceViewModel(reference.Id, reference.Name, year, reference.Title, referenceType.Description, referenceType.Id));
            }

            return(list);
        }
        /// <summary>
        /// Get reference relation types for specified locale.
        /// </summary>
        /// <param name="locale">Currently used locale.</param>
        /// <returns>Reference relation types for specified locale.</returns>
        protected override ReferenceRelationTypeList GetReferenceRelationTypes(ILocale locale)
        {
            ReferenceRelationTypeList referenceRelationTypes = null;

            lock (ReferenceRelationTypes)
            {
                if (ReferenceRelationTypes.ContainsKey(locale.ISOCode))
                {
                    referenceRelationTypes = (ReferenceRelationTypeList)(ReferenceRelationTypes[locale.ISOCode]);
                }
            }

            return(referenceRelationTypes);
        }
        /// <summary>
        /// Convert a list of WebReferenceRelationType instances
        /// to a ReferenceRelationTypeList.
        /// </summary>
        /// <param name="userContext">
        /// Information about the user that makes this method call.
        /// </param>
        /// <param name="webReferenceRelationTypes">List of WebReferenceRelationType instances.</param>
        /// <returns>Reference relation types.</returns>
        private ReferenceRelationTypeList GetReferenceRelationTypes(IUserContext userContext,
                                                                    List <WebReferenceRelationType> webReferenceRelationTypes)
        {
            ReferenceRelationTypeList referenceRelationTypes;

            referenceRelationTypes = new ReferenceRelationTypeList();
            if (webReferenceRelationTypes.IsNotEmpty())
            {
                foreach (WebReferenceRelationType webReferenceRelationType in webReferenceRelationTypes)
                {
                    referenceRelationTypes.Add(GetReferenceRelationType(userContext, webReferenceRelationType));
                }
            }

            return(referenceRelationTypes);
        }
Ejemplo n.º 5
0
        public static List <ReferenceViewModel> GetReferences(string guid)
        {
            IUserContext userContext = CoreData.UserManager.GetCurrentUser();
            ReferenceRelationTypeList referenceTypes = CoreData.ReferenceManager.GetReferenceRelationTypes(userContext);
            ReferenceRelationList     references     = CoreData.ReferenceManager.GetReferenceRelations(userContext, guid);

            var list = new List <ReferenceViewModel>();

            foreach (IReferenceRelation referenceRelation in references)
            {
                IReference reference = referenceRelation.GetReference(userContext);
                Int32      year      = reference.Year.HasValue ? reference.Year.Value : -1;
                list.Add(new ReferenceViewModel(reference.Id, reference.Name, year, reference.Title, referenceRelation.Type.Description, referenceRelation.Type.Id));
            }

            return(list);
        }
        /// <summary>
        /// Creates a html-string for a select box where the user can
        /// select what type of reference this is.
        /// </summary>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        private string CreateReferenceTypesSelectBoxString()
        {
            ReferenceRelationTypeList referenceTypes = CoreData.ReferenceManager.GetReferenceRelationTypes(user);

            StringBuilder sb = new StringBuilder();

            sb.Append("<select name=\"usageType\" style=\"width: 100%\">");
            sb.Append("<option value=-1 selected=\"selected\">" + HttpUtility.HtmlEncode(DyntaxaResource.ReferenceAddChooseType) + "</option>");
            foreach (IReferenceRelationType referenceRelationType in referenceTypes)
            {
                sb.AppendFormat(
                    "<option value=\"{0}\">{1}</option>",
                    referenceRelationType.Id,
                    HttpUtility.HtmlEncode(referenceRelationType.Description));
            }

            sb.Append("</select>");
            return(sb.ToString());
        }
 /// <summary>
 /// Set reference relation types for specified locale.
 /// </summary>
 /// <param name="referenceRelationTypes">Reference relation types.</param>
 /// <param name="locale">Currently used locale.</param>
 protected virtual void SetReferenceRelationTypes(ReferenceRelationTypeList referenceRelationTypes,
                                                  ILocale locale)
 {
     ReferenceRelationTypes[locale.ISOCode] = referenceRelationTypes;
 }