public void FillBrigades()
        {
            var searcher = ExamineManager.Instance.SearchProviderCollection["AdvertismentSearcher"]; // InternalSearcher
            //var searcher = ExamineManager.Instance.SearchProviderCollection["AdvertismentSearcher"];
            var criteria = searcher.CreateSearchCriteria(UmbracoExamine.IndexTypes.Content);
            Examine.SearchCriteria.IBooleanOperation filter = null;

            criteria.OrderBy(new string[] { "DateCreate" });
            filter = criteria.NodeTypeAlias("dtAdvertisement");

            #region Hledani v nazvu inzeratu
            if (!String.IsNullOrWhiteSpace(fulltext))
            {
                var values = new List<Examine.SearchCriteria.IExamineValue>();
                var searchTerms = fulltext.Trim().ToLower().Split(' '); // rozdělení vyhledávaného výrazu na jednotlivé termíny
                foreach (var term in searchTerms) // přidání každého termínu zvlášť do skupiny vyhledáváných slov v názvu
                {
                    if (string.IsNullOrWhiteSpace(term)) continue;
                    values.Add(term.MultipleCharacterWildcard()); // MultipleCharacterWildcard zajistí relevantnější prohledávání - i uprostřed slov apod.
                }
                if (values.Count() > 0)
                {
                    filter.And().GroupedOr(new string[] { "nodeName" }, values.ToArray<IExamineValue>());
                }
            }
            #endregion

            if (!String.IsNullOrEmpty(workingField))
            {
                filter.And().Field("aWorkingField", workingField);
            }

            if (!String.IsNullOrEmpty(region))
                filter.And().Field("aRegion", region);

            if (!String.IsNullOrEmpty(typeOfWork))
                filter.And().Field("aTypeOfWork", typeOfWork);

            if (IsZTP)
                filter.And().Field("aZtp", ("1"));

            //if (String.IsNullOrEmpty(fulltext)) fulltext = "Pozice?";
            if (String.IsNullOrEmpty(region)) region = "";
            if (String.IsNullOrEmpty(workingField)) workingField = "";
            if (String.IsNullOrEmpty(typeOfWork)) typeOfWork = "";

            //if (String.IsNullOrEmpty(fulltext)) fulltext = "Pracovní pozice?";
            if (String.IsNullOrEmpty(region)) region = "Kde?";
            if (String.IsNullOrEmpty(workingField)) workingField = "Obor?";
            slRegions = this.GetRegionSelectListItem(region);
            slWorkingFields = this.GetWorkingFieldSelectListItem(workingField);
            slTypeOfWork = this.GetTypeOfWorkSelectListItem(typeOfWork);

            List<Advertisement> advertisements = new List<Advertisement>();
            var searchResult = searcher.Search(filter.Compile());
            foreach (var result in searchResult)
            {
                //Advertisement advertisement = this.DynamicToAdverisement(result);
                Advertisement advertisement = new Advertisement();
                advertisement.DynamicToAdverisement(result);
                if (advertisement != null && advertisement.ID > 0 && JobsplusConstants.BrigadeWorkTypes.Contains(advertisement.TypeOfWork.Name))
                    advertisements.Add(advertisement);
            }
            lAdvertisements = advertisements;
        }
 public void Fill(IEnumerable<IPublishedContent> advertisementList)
 {
     if (advertisementList != null)
     {
         List<Advertisement> advertisements = new List<Advertisement>();
         foreach (var result in advertisementList)
         {
             //Advertisement advertisement = this.DynamicToAdverisement(result.Id);
             Advertisement advertisement = new Advertisement();
             advertisement.DynamicToAdverisement(result.Id);
             if (advertisement != null && advertisement.ID > 0) advertisements.Add(advertisement);
         }
         lAdvertisements = advertisements;
     }
     else
         lAdvertisements = new List<Advertisement>();
 }
        public void Fill()
        {
            /*
            var rootNode = new Node(-1);
            var allAdverts = rootNode.ChildrenAsList.Where(x => x.NodeTypeAlias.Equals("dtAdvertisement"));

            if (!String.IsNullOrEmpty(workingField))
                allAdverts = allAdverts.Where(x => x.GetProperty("aWorkingField").Equals(workingField));
            if (!String.IsNullOrEmpty(region))
                allAdverts = allAdverts.Where(x => x.GetProperty("aRegion").Equals(region));
            if (IsZTP)
                allAdverts = allAdverts.Where(x => x.GetProperty("aZtp").Equals("1"));

            var excludedDoctypes = new[] { "BlogPost", "NewsArticle" };
            DynamicNode node = Model; // your start node
            var childNodes = node.ChildrenAsList.Where(x => !excludedDoctypes.Contains(x.NodeTypeAlias));*/

            var searcher = ExamineManager.Instance.SearchProviderCollection["AdvertismentSearcher"]; // InternalSearcher
            //var searcher = ExamineManager.Instance.SearchProviderCollection["AdvertismentSearcher"];
            var criteria = searcher.CreateSearchCriteria(UmbracoExamine.IndexTypes.Content);
            Examine.SearchCriteria.IBooleanOperation filter = null;

            criteria.OrderBy(new string[] { "DateCreate" });
            filter = criteria.NodeTypeAlias("dtAdvertisement");

            #region Hledani v nazvu inzeratu
            // VYHLEDAVAC 1.0
            // DKO: puvodni vyhledavani - CASE SENSITIVE, pouze celá slova
            /*if (!String.IsNullOrEmpty(fulltext))
                filter.And().GroupedOr(new string[] { "nodeName" }, fulltext.Trim().ToLower()); */

            // VYHLEDAVAC 2.0
            // DKO: dalsi pokus o vyhledavani - CASE INSENSITIVE, pouze celá slova, bere v potaz i vyhledání uprostřed slov v názvu,
            // pokud uživatel zadá více jak jedno slovo, nefunguje :-(
            /*
            if (!String.IsNullOrEmpty(fulltext))
                filter.And().GroupedOr(new string[] { "nodeName" }, fulltext.Trim().ToLower().MultipleCharacterWildcard());*/

            // VYHLEDAVAC 3.0
            if (!String.IsNullOrWhiteSpace(fulltext))
            {
                var values = new List<Examine.SearchCriteria.IExamineValue>();
                var searchTerms = fulltext.Trim().ToLower().Split(' '); // rozdělení vyhledávaného výrazu na jednotlivé termíny
                foreach (var term in searchTerms) // přidání každého termínu zvlášť do skupiny vyhledáváných slov v názvu
                {
                    if (string.IsNullOrWhiteSpace(term)) continue;
                    values.Add(term.MultipleCharacterWildcard()); // MultipleCharacterWildcard zajistí relevantnější prohledávání - i uprostřed slov apod.
                }
                if (values.Count() > 0)
                {
                    filter.And().GroupedOr(new string[] { "nodeName" }, values.ToArray<IExamineValue>());
                }
            }
            #endregion

            if (!String.IsNullOrEmpty(workingField))
            {
                filter.And().Field("aWorkingField", workingField);
            }

            if (!String.IsNullOrEmpty(region))
                filter.And().Field("aRegion", region);

            if (!String.IsNullOrEmpty(typeOfWork))
                filter.And().Field("aTypeOfWork", typeOfWork);

            if (IsZTP)
                filter.And().Field("aZtp", ("1"));

            //if (String.IsNullOrEmpty(fulltext)) fulltext = "Pozice?";
            if (String.IsNullOrEmpty(region)) region = "";
            if (String.IsNullOrEmpty(workingField)) workingField = "";
            if (String.IsNullOrEmpty(typeOfWork)) typeOfWork = "";

            //if (String.IsNullOrEmpty(fulltext)) fulltext = "Pracovní pozice?";
            if (String.IsNullOrEmpty(region)) region = "Kde?";
            if (String.IsNullOrEmpty(workingField)) workingField = "Obor?";
            slRegions = this.GetRegionSelectListItem(region);
            slWorkingFields = this.GetWorkingFieldSelectListItem(workingField);
            slTypeOfWork = this.GetTypeOfWorkSelectListItem(typeOfWork);

            List<Advertisement> advertisements = new List<Advertisement>();
            var searchResult = searcher.Search(filter.Compile());
            foreach (var result in searchResult)
            {
                //Advertisement advertisement = this.DynamicToAdverisement(result);
                Advertisement advertisement = new Advertisement();
                advertisement.DynamicToAdverisement(result);
                if (advertisement != null && advertisement.ID > 0 && !JobsplusConstants.BrigadeWorkTypes.Contains(advertisement.TypeOfWork.Name))
                    advertisements.Add(advertisement);
            }
            lAdvertisements = advertisements;
        }
        public ActionResult JobTemplateSubmit(Advertisement model)
        {
            if (ViewData["slJobTemplate"] == null)
                ViewData["slJobTemplate"] = GetJobTemplateSelectListItem(String.Empty);
            if (ViewData["slRegion"] == null)
                ViewData["slRegion"] = GetRegionSelectListItem(String.Empty);
            if (ViewData["slWorkingField"] == null)
                ViewData["slWorkingField"] = GetWorkingFieldSelectListItem(String.Empty);
            if (ViewData["slTypeOfWork"] == null)
                ViewData["slTypeOfWork"] = GetTypeOfWorkSelectListItem(String.Empty);
            if (ViewData["slRequiredEducation"] == null)
                ViewData["slRequiredEducation"] = GetRequiredEducationSelectListItem(String.Empty);

            JobTemplate jobTemplate = DBContext.GetJobTemplateById(model.JobTemplateID);
            if (jobTemplate != null)
            {
                model.Name = jobTemplate.JobName;
                model.JobDescription = jobTemplate.JobDescription;
                model.JobOfferings = jobTemplate.JobOfferings;
                model.JobRequirements = jobTemplate.JobRequirements;
            }

            if (TempData.ContainsKey("JobTemplate")) TempData.Remove("JobTemplate");
            TempData.Add("JobTemplate", jobTemplate);

            return RedirectToCurrentUmbracoPage();
        }
        public ActionResult Details(int? id)
        {
            Advertisement advertisement = new Advertisement();
            if (id.HasValue)
            {
                if (TempData.ContainsKey("VisibleJobTemplate")) TempData.Remove("VisibleJobTemplate");
                advertisement.DynamicToAdverisement(id.Value);

                if (!String.IsNullOrEmpty(advertisement.Region.Name))
                    advertisement.RegionID = lRegions.Find(r => r.Name == advertisement.Region.Name).Id.Value;
                if (!String.IsNullOrEmpty(advertisement.WorkingField.Name))
                    advertisement.WorkingFieldID = lWorkingFields.Find(r => r.Name == advertisement.WorkingField.Name).Id.Value;
                if (!String.IsNullOrEmpty(advertisement.TypeOfWork.Name))
                    advertisement.TypeOfWorkID = lTypeOfWorks.Find(r => r.Name == advertisement.TypeOfWork.Name).Id.Value;
                if (!String.IsNullOrEmpty(advertisement.RequiredEducation.Name))
                    advertisement.RequiredEducationID = lRequiredEducations.Find(r => r.Name == advertisement.RequiredEducation.Name).Id.Value;

                ViewData["slRegion"] = GetRegionSelectListItem(advertisement.Region.Name);
                ViewData["slWorkingField"] = GetWorkingFieldSelectListItem(advertisement.WorkingField.Name);
                ViewData["slTypeOfWork"] = GetTypeOfWorkSelectListItem(advertisement.TypeOfWork.Name);
                ViewData["slRequiredEducation"] = GetRequiredEducationSelectListItem(advertisement.RequiredEducation.Name);
            }
            else
            {
                if (TempData.ContainsKey("VisibleJobTemplate")) TempData.Remove("VisibleJobTemplate");
                TempData.Add("VisibleJobTemplate", true);

                if (TempData.ContainsKey("JobTemplate"))
                {
                    JobTemplate jobTemplate = (JobTemplate)TempData["JobTemplate"];
                    if (jobTemplate != null)
                    {
                        advertisement.Name = jobTemplate.JobName;
                        advertisement.JobDescription = jobTemplate.JobDescription;
                        advertisement.JobOfferings = jobTemplate.JobOfferings;
                        advertisement.JobRequirements = jobTemplate.JobRequirements;
                        if (jobTemplate.Id > 0)
                            advertisement.JobTemplateID = jobTemplate.Id;
                        ViewData["slJobTemplate"] = GetJobTemplateSelectListItem(jobTemplate.Id.ToString());
                    }
                }
                else
                {
                    ViewData["slJobTemplate"] = GetJobTemplateSelectListItem(String.Empty);
                }

                ViewData["slRegion"] = GetRegionSelectListItem(String.Empty);
                ViewData["slWorkingField"] = GetWorkingFieldSelectListItem(String.Empty);
                ViewData["slTypeOfWork"] = GetTypeOfWorkSelectListItem(String.Empty);
                ViewData["slRequiredEducation"] = GetRequiredEducationSelectListItem(String.Empty);

            }

            return PartialView(advertisement);
        }
        public ActionResult AdvertisementSubmit(Advertisement model)
        {
            if (!ModelState.IsValid)
                return CurrentUmbracoPage();

            var companyContent = CompanyContent();

            var contentService = Services.ContentService;
            IContent produkt = null;
            if (model.ID > 0)
            {
                produkt = contentService.GetById(model.ID);// (model.Name, companyContent.Id, "dtAdvertisement");
            }
            else
            {
                produkt = contentService.CreateContent(model.Name, companyContent.Id, "dtAdvertisement", Members.GetCurrentMemberId());
            }
            produkt.SetValue("aContent", !String.IsNullOrEmpty(model.Content) ? model.Content : " ");
            produkt.SetValue("aTypeOfWork", model.TypeOfWorkID);
            produkt.SetValue("aRegion", model.RegionID);
            produkt.SetValue("aWorkingField", model.WorkingFieldID);
            produkt.SetValue("aRequiredEducation", model.RequiredEducationID);
            produkt.SetValue("aCity", !String.IsNullOrEmpty(model.City) ? model.City : " ");
            produkt.SetValue("aZTP", model.ZTP ? "1" : "0");
            produkt.SetValue("aJobDescription", !String.IsNullOrEmpty(model.JobDescription) ? model.JobDescription : " ");
            produkt.SetValue("aJobOfferings", !String.IsNullOrEmpty(model.JobOfferings) ? model.JobOfferings : " ");
            produkt.SetValue("aJobRequirements", !String.IsNullOrEmpty(model.JobRequirements) ? model.JobRequirements : " ");

            var status = contentService.SaveAndPublishWithStatus(produkt);

            if (TempData.ContainsKey("AdvertisementSubmitIsSuccess")) TempData.Remove("AdvertisementSubmitIsSuccess");
            if (status.Success) TempData.Add("AdvertisementSubmitIsSuccess", "save");

            return Redirect("/firma/inzeraty");
        }