public ActionResult Edit(int id)
        {
            FindFaqItemByIdQueryResult result = Query.For <FindFaqItemByIdQueryResult>().ById(id);

            if (!result.IsFounded)
            {
                return(RedirectToAction("Index"));
            }

            FaqItem item = result.Item;

            EditFaqItemViewModel vm = new EditFaqItemViewModel
            {
                Id                      = id,
                FaqCategoryId           = item.FaqCategoryId,
                Title                   = item.Title,
                ShortContent            = item.ShortContent,
                HtmlContent             = item.HtmlContent,
                IsDysplayOnMainScreen   = item.IsDysplayOnMainScreen,
                IsHtmlContentDisplay    = item.IsHtmlContentDisplay,
                IsPublished             = item.IsPublished,
                CategorySelectListItems = GetFaqCategoriesList(item.FaqCategoryId)
            };

            return(View(vm));
        }
        protected override FindFaqItemByIdQueryResult OnExecuting(IdCriterion criterion)
        {
            FaqItem item = DataContext.FaqItems.Find(criterion.Id);

            FindFaqItemByIdQueryResult result = new FindFaqItemByIdQueryResult
            {
                Item      = item,
                IsFounded = item != null
            };

            return(result);
        }
        public HttpResponseMessage SelectById(int id)
        {
            try
            {
                FaqItem faqItem = _faqItemService.SelectById(id);
                return(Request.CreateResponse(HttpStatusCode.OK, faqItem));
            }

            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message));
            }
        }
        protected override void OnHandling(PublishFaqItemCommand command, CommandResult result)
        {
            FaqItem item = DataContext.FaqItems.Find(command.Id);

            if (item == null)
            {
                result.ResultCode = CommandResultCode.Cancelled;
                return;
            }

            item.IsPublished = true;

            DataContext.Entry(item).State = EntityState.Modified;
        }
        protected override void OnHandling(HideOnMainScreenFaqItemCommand command, CommandResult result)
        {
            FaqItem item = DataContext.FaqItems.Find(command.Id);

            if (item == null)
            {
                result.ResultCode = CommandResultCode.Cancelled;
                return;
            }

            item.IsDysplayOnMainScreen = false;

            DataContext.Entry(item).State = EntityState.Modified;
        }
 protected FaqItemDetailsViewModel ToViewModel(FaqItem item)
 {
     return(new FaqItemDetailsViewModel
     {
         Id = item.Id,
         Title = item.Title,
         ShortContent = item.ShortContent,
         HtmlContent = item.HtmlContent,
         IsDeleted = item.IsDeleted,
         IsPublished = item.IsPublished,
         IsDysplayOnMainScreen = item.IsDysplayOnMainScreen,
         IsHtmlContentDisplay = item.IsHtmlContentDisplay,
         FaqCategory = item.FaqCategory
     });
 }
        public FaqDetailViewModel(FaqItem item = null)
        {
            Title       = item?.Text;
            Item        = item;
            Description = item?.FullDescription;

            CarouselImages = new ObservableCollection <CarouselImage>
            {
                new CarouselImage {
                    Source = "beard1"
                },
                new CarouselImage {
                    Source = "beard2"
                },
                new CarouselImage {
                    Source = "beard3"
                }
            };
        }
Exemple #8
0
        public async Task <ActionResult> CreateAsync(FaqItemViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var item = new FaqItem
                {
                    Title         = viewModel.Title,
                    Content       = viewModel.Content,
                    DisplayOrder  = viewModel.DisplayOrder,
                    TitleFontSize = viewModel.TitleFontSize
                };
                await _FaqRepository.CreateAsync(item);

                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                return(View("CreateEdit", viewModel));
            }
        }
        protected override void OnHandling(EditFaqItemCommand command, CommandResult result)
        {
            FaqItem item = DataContext.FaqItems.Find(command.Id);

            if (item == null)
            {
                result.ResultCode = CommandResultCode.Cancelled;
                return;
            }

            item.Title                 = command.Title;
            item.ShortContent          = command.ShortContent;
            item.HtmlContent           = command.HtmlContent;
            item.FaqCategoryId         = command.FaqCategoryId;
            item.IsPublished           = command.IsPublished;
            item.IsHtmlContentDisplay  = command.IsHtmlContentDisplay;
            item.IsDysplayOnMainScreen = command.IsDysplayOnMainScreen;

            DataContext.Entry(item).State = EntityState.Modified;
        }
Exemple #10
0
        protected override void OnHandling(AddFaqItemCommand command, CommandResult result)
        {
            FaqItem item = new FaqItem
            {
                Title                 = command.Title,
                ShortContent          = command.ShortContent,
                HtmlContent           = command.HtmlContent,
                FaqCategoryId         = command.FaqCategoryId,
                IsPublished           = command.IsPublished,
                IsHtmlContentDisplay  = command.IsHtmlContentDisplay,
                IsDysplayOnMainScreen = command.IsDysplayOnMainScreen
            };

            DataContext.FaqItems.Add(item);

            if (command.RequestId.HasValue)
            {
                new ConfirmRequestCommandHandler().Handle(new ConfirmRequestCommand
                {
                    Id = command.RequestId.Value
                });
            }
        }
Exemple #11
0
        protected FaqItemViewModel ToViewModel(FaqItem item)
        {
            FaqItemViewModel vm = Mapper.Map <FaqItemViewModel>(item);

            return(vm);
        }