public TasksPublishController(ILogger logger, IDataTypeValueService dataTypeValueService, IMediaUploadService mediaUploadService)
        {
            _logger = logger;
            _dataTypeValueService = dataTypeValueService;
            _mediaUploadService   = mediaUploadService;

            loggedMember = GetLoggedMember();
        }
        public void UpdateArticleGridFields(IContent article, UmbracoArticleModel model)
        {
            loggedMember = GetLoggedMember();
            var memberUdi = Current.Services.MemberService.GetById(loggedMember.MemberId).GetUdi();

            article.Name = model.ArticleName;
            article.SetValue(Article.GetModelPropertyType(x => x.Title).Alias, model.Title);
            article.SetValue(Article.GetModelPropertyType(x => x.AuthorName).Alias, model.AuthorName);
            article.SetValue(Article.GetModelPropertyType(x => x.ArticleDate).Alias, model.ArticleDate);
            article.SetValue(Article.GetModelPropertyType(x => x.MetaName).Alias, model.MetaName);
            article.SetValue(Article.GetModelPropertyType(x => x.ArticleMember).Alias, memberUdi);
        }
        public void UpdateApprenticeshipGridFields(IContent content, UmbracoApprenticeshipModel model)
        {
            loggedMember = GetLoggedMember();
            var memberUdi = Current.Services.MemberService.GetById(loggedMember.MemberId).GetUdi();

            content.Name = model.ApprenticeshipName;
            content.SetValue(Apprenticeship.GetModelPropertyType(x => x.Title).Alias, model.Title);
            content.SetValue(Apprenticeship.GetModelPropertyType(x => x.PostDate).Alias, model.PostDate);
            content.SetValue(Apprenticeship.GetModelPropertyType(x => x.StartDate).Alias, model.StartDate);
            content.SetValue(Apprenticeship.GetModelPropertyType(x => x.EndDate).Alias, model.EndDate);
            content.SetValue(Apprenticeship.GetModelPropertyType(x => x.MetaName).Alias, model.MetaName);
            content.SetValue(Apprenticeship.GetModelPropertyType(x => x.Employer).Alias, memberUdi);
        }
        public List <UmbracoApprenticeshipModel> GetUmbracoApprenticeships()
        {
            List <UmbracoApprenticeshipModel> model = new List <UmbracoApprenticeshipModel>();

            loggedMember = GetLoggedMember();

            IPublishedContent homePage           = Umbraco.ContentAtRoot().Where(f => f.IsDocumentType(HOMEPAGE_DOCTYPE_ALIAS)).FirstOrDefault();
            IPublishedContent apprenticeshipList = homePage.Descendants().Where(x => x.IsDocumentType(APPR_LIST_DOCTYPE_ALIAS)).FirstOrDefault();

            foreach (IPublishedContent item in apprenticeshipList.Children.OrderBy(x => x.Name))
            {
                // switch case here for member type
                int memberId = GetEmployerTypeId(item, loggedMember.MemberType);

                if (memberId == loggedMember.MemberId)
                {
                    int      apprenticeshipId   = item.Id;
                    string   apprenticeshipName = item.Name;
                    DateTime postDate           = (DateTime)item.GetProperty("postDate").GetValue();
                    DateTime startDate          = (DateTime)item.GetProperty("startDate").GetValue();
                    DateTime endDate            = (DateTime)item.GetProperty("endDate").GetValue();
                    string   title           = item.GetProperty("title").GetValue().ToString();
                    string   country         = item.GetProperty("country").GetValue().ToString();
                    string   metaName        = item.GetProperty("metaName").GetValue().ToString();
                    string   metaDescription = item.GetProperty("metaDescription").GetValue().ToString();
                    string[] metaKeywords    = (string[])item.GetProperty("metaKeywords").GetValue();
                    string[] categories      = (string[])item.GetProperty("category").GetValue();
                    string   jobSector       = item.GetProperty("jobSector").GetValue().ToString();

                    model.Add(new UmbracoApprenticeshipModel()
                    {
                        ApprenticeshipId   = apprenticeshipId,
                        ApprenticeshipName = apprenticeshipName,
                        PostDate           = postDate,
                        StartDate          = startDate,
                        EndDate            = endDate,
                        Title              = title,
                        Country            = country,
                        MemberId           = memberId,
                        MetaName           = metaName,
                        MetaDescription    = metaDescription,
                        MetaKeywords       = utilities.ConcatenateStringArray(metaKeywords),
                        JobSector          = jobSector,
                        SelectedCategories = categories
                    });
                }
            }
            return(model);
        }
        public List <UmbracoArticleModel> GetUmbracoArticles()
        {
            List <UmbracoArticleModel> model = new List <UmbracoArticleModel>();

            loggedMember = GetLoggedMember();

            IPublishedContent homePage     = Umbraco.ContentAtRoot().Where(f => f.IsDocumentType(HOMEPAGE_DOCTYPE_ALIAS)).FirstOrDefault();
            IPublishedContent articlesList = homePage.Descendants().Where(x => x.IsDocumentType(ARTICLELIST_DOCTYPE_ALIAS)).FirstOrDefault();

            foreach (IPublishedContent item in articlesList.Children.OrderBy(x => x.Name))
            {
                // switch case here for member type
                int memberId = GetMemberTypeId(item, loggedMember.MemberType);

                if (memberId == loggedMember.MemberId)
                {
                    int      articleId       = item.Id;
                    string   name            = item.Name;
                    DateTime articleDate     = (DateTime)item.GetProperty("articleDate").GetValue();
                    string   authorName      = item.GetProperty("authorName").GetValue().ToString();
                    string   title           = item.GetProperty("title").GetValue().ToString();
                    var      description     = item.GetProperty("description").GetValue();
                    string   country         = item.GetProperty("country").GetValue().ToString();
                    string   metaName        = item.GetProperty("metaName").GetValue().ToString();
                    string   metaDescription = item.GetProperty("metaDescription").GetValue().ToString();
                    string[] metaKeywords    = (string[])item.GetProperty("metaKeywords").GetValue();
                    string[] categories      = (string[])item.GetProperty("category").GetValue();

                    model.Add(new UmbracoArticleModel()
                    {
                        ArticleId          = articleId,
                        ArticleName        = name,
                        ArticleDate        = articleDate,
                        AuthorName         = authorName,
                        Title              = title,
                        Description        = (HtmlString)description,
                        Country            = country,
                        MemberId           = memberId,
                        MetaName           = metaName,
                        MetaDescription    = metaDescription,
                        MetaKeywords       = utilities.ConcatenateStringArray(metaKeywords),
                        SelectedCategories = categories
                    });
                }
            }
            return(model);
        }
        /// <summary>
        /// Gets current logged in Member. Returns Id, Name, and Type
        /// </summary>
        /// <returns>model with Id, Name and member Type</returns>
        public LoggedMemberModel GetLoggedMember()
        {
            string            memberType   = "";
            int               memberId     = 0;
            string            memberName   = "";
            IPublishedContent loggedMember = Members.GetCurrentMember();

            if (loggedMember != null)
            {
                memberType = loggedMember.ContentType.Alias.ToString();
                memberId   = loggedMember.Id;
                memberName = loggedMember.Name;
            }
            LoggedMemberModel model = new LoggedMemberModel()
            {
                MemberId   = memberId,
                MemberName = memberName,
                MemberType = memberType
            };

            return(model);
        }