Ejemplo n.º 1
0
        public EntityDetails AddEntityDetails(EntityDetails detail)
        {
            if (detail.RDate != null && detail.RTime != null)
            {
                var date = DateTime.MinValue;
                if (DateTime.TryParse($"{detail.RDate}T{detail.RTime}", out date))
                {
                    detail.RemainderDate = date;
                }
            }
            var r = StaticFunctions.Request(
                "Farms/Properties/Entities/Details/",
                JsonConvert.SerializeObject(detail),
                HttpMethod.Post,
                User.FindFirst(claim => claim.Type == "Token")?.Value
                );

            if (detail.ExpenseFlag && detail.Cost != null && detail.Cost != 0)
            {
                var r2 = AddExpense(new IncomeAndExpeneses {
                    Fuid        = new Guid(Sessions.CurrentFarmUID),
                    Cost        = (decimal)detail.Cost,
                    Date        = DateTime.Now,
                    Head        = detail.Name,
                    Description = detail.Description
                });
            }
            if (r != null)
            {
                var _detail = JsonConvert.DeserializeObject <EntityDetails>(r);
                return(_detail);
            }
            return(null);
        }
        /// <summary>
        /// Populates the EntityDetails object's properties from the given Content's object's properties.
        /// </summary>
        /// <param name="thisObject">Current entity details model on which the extension method is called</param>
        /// <param name="content">ContentInputViewModel model from which values to be read</param>
        public static void SetValuesFrom(this EntityDetails thisObject, EntityInputBaseViewModel content)
        {
            if (content != null)
            {
                if (thisObject == null)
                {
                    thisObject = new EntityDetails();
                }

                thisObject.Name        = content.Name;
                thisObject.ID          = content.ID.HasValue ? content.ID.Value : 0;
                thisObject.Description = content.Description;
                thisObject.CategoryID  = content.CategoryID;
                thisObject.CreatedByID = content.OwnerID;

                // Set parent properties.
                if (content.ParentID.HasValue)
                {
                    thisObject.ParentID = content.ParentID.Value;
                }

                // Set thumbnail properties.
                thisObject.Thumbnail = new FileDetail()
                {
                    AzureID = content.ThumbnailID
                };

                thisObject.Tags = content.Tags;
            }
        }
        /// <summary>
        /// Populates the EntityDetails object's properties from the given Content's object's properties.
        /// </summary>
        /// <param name="thisObject">Current entity details model on which the extension method is called</param>
        /// <param name="content">Content model from which values to be read</param>
        public static void SetValuesFrom(this EntityDetails thisObject, Content content)
        {
            if (content != null)
            {
                if (thisObject == null)
                {
                    thisObject = new EntityDetails();
                }

                thisObject.Name        = content.Title;
                thisObject.ID          = content.ContentID;
                thisObject.Description = content.Description;
                thisObject.IsOffensive = content.IsOffensive ?? false;

                // Set parent details.
                var parent = content.CommunityContents.FirstOrDefault();
                if (parent != null)
                {
                    thisObject.ParentName = parent.Community.Name;
                    thisObject.ParentID   = parent.Community.CommunityID;
                    thisObject.ParentType = parent.Community.CommunityTypeID.ToEnum(CommunityTypes.None);
                }

                thisObject.CategoryID  = content.CategoryID;
                thisObject.CreatedByID = content.CreatedByID;
                thisObject.TypeID      = content.TypeID;
                thisObject.Thumbnail   = new FileDetail()
                {
                    AzureID = content.ThumbnailID ?? Guid.Empty
                };

                if (content.AccessType != null)
                {
                    thisObject.AccessTypeName = content.AccessType.Name;
                }


                thisObject.CreatedDatetime     = content.CreatedDatetime;
                thisObject.LastUpdatedDatetime = content.ModifiedDatetime;

                if (content.ContentRatings.Any())
                {
                    thisObject.AverageRating = content.ContentRatings.Average(rating => rating.Rating);
                    thisObject.RatedPeople   = content.ContentRatings.Count();
                }

                var tags = content.ContentTags.Select(tag => tag.Tag.Name);

                if (tags.Any())
                {
                    thisObject.Tags = string.Join(", ", tags.ToList());
                }

                thisObject.AccessTypeID = content.AccessTypeID ?? 0;
            }
        }
        public override string ToString()
        {
            StringBuilder __sb    = new StringBuilder("GetActivitiesV2Response(");
            bool          __first = true;

            if (Data != null && __isset.data)
            {
                if (!__first)
                {
                    __sb.Append(", ");
                }
                __first = false;
                __sb.Append("Data: ");
                __sb.Append(Data.ToDebugString());
            }
            if (EntityDetails != null && __isset.entityDetails)
            {
                if (!__first)
                {
                    __sb.Append(", ");
                }
                __first = false;
                __sb.Append("EntityDetails: ");
                __sb.Append(EntityDetails.ToDebugString());
            }
            if (Authors != null && __isset.authors)
            {
                if (!__first)
                {
                    __sb.Append(", ");
                }
                __first = false;
                __sb.Append("Authors: ");
                __sb.Append(Authors.ToDebugString());
            }
            if (NextCursor != null && __isset.nextCursor)
            {
                if (!__first)
                {
                    __sb.Append(", ");
                }
                __first = false;
                __sb.Append("NextCursor: ");
                __sb.Append(NextCursor);
            }
            __sb.Append(")");
            return(__sb.ToString());
        }
Ejemplo n.º 5
0
        public EntityDetails UpdateEntityDetail(EntityDetails entityDetail)
        {
            var r = StaticFunctions.Request(
                "Farms/Properties/Entities/Details/",
                JsonConvert.SerializeObject(entityDetail),
                HttpMethod.Post,
                User.FindFirst(claim => claim.Type == "Token")?.Value
                );

            if (r != null)
            {
                var _r = JsonConvert.DeserializeObject <EntityDetails>(r);
                return(_r);
            }
            return(null);
        }
        /// <summary>
        /// Create associated content from file details.
        /// </summary>
        /// <param name="thisObject">Current Content instance on which the extension method is called</param>
        /// <param name="contentDetails">Content details.</param>
        /// <param name="dataDetails">Associated file details.</param>
        public static void SetValuesFrom(this Content thisObject, EntityDetails contentDetails, DataDetail dataDetails)
        {
            if (thisObject != null && contentDetails != null && dataDetails != null)
            {
                thisObject.SetValuesFrom(dataDetails);

                thisObject.Title           = dataDetails.Name;
                thisObject.Description     = dataDetails.Name;
                thisObject.CategoryID      = contentDetails.CategoryID;
                thisObject.AccessTypeID    = contentDetails.AccessTypeID;
                thisObject.CreatedByID     = contentDetails.CreatedByID;
                thisObject.CreatedDatetime = thisObject.ModifiedDatetime = contentDetails.CreatedDatetime;

                thisObject.IsSearchable = false;
                thisObject.IsDeleted    = false;
                thisObject.IsOffensive  = false;
            }
        }
        /// <summary>
        /// Populates the EntityDetails object's properties from the given Community object's properties.
        /// </summary>
        /// <param name="thisObject">Current entity details model on which the extension method is called</param>
        /// <param name="community">Community model from which values to be read</param>
        public static void SetValuesFrom(this EntityDetails thisObject, Community community)
        {
            if (thisObject != null && community != null)
            {
                Mapper.Map(community, thisObject as CommunityDetails);

                // Set parent details.
                var parent = community.CommunityRelation1.FirstOrDefault();
                if (parent != null)
                {
                    thisObject.ParentName = parent.Community.Name;
                    thisObject.ParentID   = parent.Community.CommunityID;
                    thisObject.ParentType = parent.Community.CommunityTypeID.ToEnum <int, CommunityTypes>(CommunityTypes.None);
                }

                if (community.CommunityRatings.Count() > 0)
                {
                    thisObject.AverageRating = community.CommunityRatings.Average(rating => rating.Rating);
                    thisObject.RatedPeople   = community.CommunityRatings.Count();
                }

                var tags = community.CommunityTags.Select(tag => tag.Tag.Name);

                if (tags.Count() > 0)
                {
                    thisObject.Tags = string.Join(", ", tags.ToList());
                }

                if (community.User != null)
                {
                    // Produced by is equivalent to created by.
                    thisObject.ProducedBy = community.User.FirstName + " " + community.User.LastName;
                }

                // Set Thumbnail properties.
                var thumbnailDetail = new FileDetail();
                thumbnailDetail.AzureID = community.ThumbnailID.HasValue ? community.ThumbnailID.Value : Guid.Empty;
                thisObject.Thumbnail    = thumbnailDetail;
            }
        }
        /// <summary>
        /// Populates the EntityViewModel object's properties from the given EntityDetail object's properties.
        /// </summary>
        /// <param name="thisObject">Current entity view model on which the extension method is called</param>
        /// <param name="entityDetails">EntityDetails model from which values to be read</param>
        /// <returns>Values populated EntityViewModel instance</returns>
        public static EntityViewModel SetValuesFrom(this EntityViewModel thisObject, EntityDetails entityDetails)
        {
            if (entityDetails != null)
            {
                if (thisObject == null)
                {
                    thisObject = new EntityViewModel();
                }

                thisObject.Id   = entityDetails.ID;
                thisObject.Name = entityDetails.Name;

                // Parse the category string
                thisObject.Category   = entityDetails.CategoryID.ToEnum <int, CategoryType>(CategoryType.All);
                thisObject.AccessType = (AccessType)entityDetails.AccessTypeID;

                thisObject.ParentId       = entityDetails.ParentID;
                thisObject.ParentName     = entityDetails.ParentName;
                thisObject.ParentType     = entityDetails.ParentType;
                thisObject.UserPermission = entityDetails.UserPermission;

                if (entityDetails.Tags != null)
                {
                    thisObject.Tags = entityDetails.Tags;
                }

                thisObject.Rating      = (double)entityDetails.AverageRating;
                thisObject.RatedPeople = entityDetails.RatedPeople;
                if (entityDetails.Thumbnail != null)
                {
                    thisObject.ThumbnailID = entityDetails.Thumbnail.AzureID;
                }

                thisObject.Producer   = entityDetails.ProducedBy;
                thisObject.ProducerId = entityDetails.CreatedByID;
            }

            return(thisObject);
        }
Ejemplo n.º 9
0
 public MyEntity()
 {
     Details = new EntityDetails();
 }