Пример #1
0
        public async Task <IActionResult> Create(PageViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                if (await _pageService.CheckExistTitleAsync(viewModel.Id, viewModel.Title))
                {
                    ModelState.AddModelError(nameof(viewModel.Title), "نام وارد شده تکراری است");
                    await PopulateCategoriesAsync(viewModel.CategoryId);

                    return(View(viewModel));
                }

                var result = await _pageService.InsertTubleAsync(viewModel);

                if (result.isSuccess)
                {
                    viewModel.Id = result.page.Id;
                    _searchManager.AddToIndex(viewModel);
                    return(RedirectToAction("Index", "Pages"));
                }

                await PopulateCategoriesAsync(viewModel.CategoryId);

                return(View(viewModel));
            }

            await PopulateCategoriesAsync(viewModel.CategoryId);

            return(View(viewModel));
        }
 public IActionResult CreateIndex()
 {
     IEnumerable<DeveloperModel> developers = (IEnumerable<DeveloperModel>)developerRepository.GetDevelopersForIndex();
     List<Searchable> searchables = new List<Searchable>();
     foreach (DeveloperModel item in developers)
     {
         SearchableDeveloper searchableDeveloper = new SearchableDeveloper(item);
         searchables.Add(searchableDeveloper);
     }
   
     
     searchManager.AddToIndex(searchables.ToArray());
     //developerRepository.MarkAsIndexed(developers);
 
     return Json("success");
 }