예제 #1
0
        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));
        }
예제 #2
0
        protected override FindFaqItemByIdQueryResult OnExecuting(IdCriterion criterion)
        {
            FaqItem item = DataContext.FaqItems.Find(criterion.Id);

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

            return(result);
        }
예제 #3
0
        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));
            }
        }
예제 #4
0
        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;
        }
예제 #6
0
 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
     });
 }
예제 #7
0
        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"
                }
            };
        }
예제 #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));
            }
        }
예제 #9
0
        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;
        }
예제 #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
                });
            }
        }
예제 #11
0
        protected FaqItemViewModel ToViewModel(FaqItem item)
        {
            FaqItemViewModel vm = Mapper.Map <FaqItemViewModel>(item);

            return(vm);
        }