예제 #1
0
        // GET: Movies
        public ActionResult Index()
        {
            var articles = _service.GetArticles();
            var vm       = ArticleView.CreateList(articles);

            return(View(vm));
        }
예제 #2
0
        public void Update(ArticleView item)
        {
            Article newart = CustomMap.ReverseArticle(item);

            repo.Articles.Update(newart);
            repo.Save();
        }
예제 #3
0
        /// <summary>
        /// Completes user authentication if it had been started.
        /// </summary>
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            string bookmarkId = "";

            if (App.MainViewModel.IsDataLoaded && (!ArticleViewModel.IsDataLoaded || App.SettingsViewModel.IsUpdated))
            {
                if (NavigationContext.QueryString.TryGetValue("bookmarkId", out bookmarkId))
                {
                    //DisplayScrollBar.Foreground = ColorToBrush(255, App.SettingsViewModel.Themes[App.SettingsViewModel.CurrentTheme].ForegroundColor);
                    LayoutRoot.Background       = ColorToBrush(255, App.SettingsViewModel.Themes[App.SettingsViewModel.CurrentTheme].BackgroundColor);
                    DisplayScrollBar.Background = ColorToBrush(255, App.SettingsViewModel.Themes[App.SettingsViewModel.CurrentTheme].ForegroundColor);

                    await ArticleViewModel.LoadData(bookmarkId);

                    ArticleView.LoadCompleted += ArticleView_LoadCompleted;
                    ArticleView.NavigateToString(Head +
                                                 "<body>" +
                                                 "<h1>" + ArticleViewModel.Title + "</h1>" +
                                                 "<h3>" + ArticleViewModel.Author + "</h3>" +
                                                 ArticleViewModel.Content +
                                                 Script +
                                                 "</body>");
                }
            }
        }
예제 #4
0
        public static ArticleView ConvertToView(ArticleModel article)
        {
            var articleView = new ArticleView
            {
                Id            = article.Id,
                Title         = article.Title,
                Content       = article.Content,
                Excerpt       = article.Excerpt,
                IsDraft       = article.IsDraft,
                CommentStatus = article.CommentStatus,
                Slug          = article.Slug,
                User          = article.User,
                FullUrl       = article.FullUrl
            };

            // Sprawdzamy czy zdjęcie wyrożniające jest ustawione
            if (article.Image == null)
            {
                articleView.ImageUrl = "/admin/images/img-placeholder.png";
            }
            else
            {
                articleView.ImageUrl = article.Image.Url;
            }

            // Sprawdzamy czy wystepują jakieś tagi bądź kategorie
            if (article.Taxonomies.Count != 0)
            {
                articleView.Categories = GetCategoryFromTaxonomy(article.Taxonomies);
                articleView.Tags       = GetTagFromTaxonomy(article.Taxonomies);
            }

            return(articleView);
        }
예제 #5
0
        public ActionResult Create(ArticleView art, string[] selectedWriter, string[] selectedMagazine, HttpPostedFileBase File)
        {
            ExploreData.EditArtilce(art, selectedWriter, selectedMagazine, db, File);


            return(RedirectToAction("Index"));
        }
예제 #6
0
        // GET: /<controller>/
        public ViewResult Index()
        {
            var articles = _service.GetArticles(Axe.Recherche);
            var vm       = ArticleView.CreateList(articles);

            return(View(vm));
        }
예제 #7
0
        // Artikel - Neu
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            ArticleView window = new ArticleView(db);

            window.Owner = this;
            window.ShowDialog();
        }
예제 #8
0
        public ActionResult Details(int id)
        {
            var model = db.GetArticleById(id);

            if (!model.ContentUrl.IsNullOrEmptyOrWhiteSpace() && model.ContentUrl.IsUrl())
            {
                var     link = model.ContentUrl;
                WebPage page = new WebPage(link);
                page.Load();
                //if (!page.Title.IsNullOrEmptyOrWhiteSpace())
                //{
                //    if (!page.IsGoogleDoc())
                //    {
                //        model.Title = page.Title;
                //    }
                //}
                if (!page.HtmlContent.IsNullOrEmptyOrWhiteSpace())
                {
                    //model.Content = page.GetNodesByClass("contents")
                    //    .FirstOrDefault()
                    //    .InnerHtml;
                    model.Content = page.GetNodeById("contents")
                                    .InnerHtml;
                    //model.Content = page.HtmlContent;
                }
            }

            ViewBag.Title = model.Title;
            ArticleView view = Mappers.Mapper.ArticleToView(model);

            return(View(view));
        }
예제 #9
0
        public ActionResult CreateArticle(ArticleView articleView)
        {
            using (var repository = _repositoryProvider.GetRepository())
            {
                if (!articleView.HasData)
                {
                    var categories = repository.Get<Category>().ToList();
                    articleView.Categories = new SelectList(Mapper.Map<List<Category>, List<CategoryView>>(categories), "Id", "Title");
                    return View(articleView);
                }
                Article article;
                if (articleView.IsDirty)
                {
                    article = Mapper.Map<ArticleView, Article>(articleView);
                    article.AddedBy = HttpContext.User.Identity.Name;
                    var category =
                        repository.Get<Category>().Where(c => c.Id == int.Parse(articleView.CategoryTitle)).
                            FirstOrDefault();
                    article.ArticleCategory = category;
                    category.Articles.Add(article);
                    repository.Save(article);

                    ViewBag.SuccessMessage = "Your article has been posted";
                    return RedirectToAction("ViewArticle", new { articleId = article.Id, path = article.Path });
                }
                return View(articleView);
            }
        }
예제 #10
0
        public ArticleModel ToModel(ArticleView view)
        {
            ArticleModel _model = new ArticleModel();

            _model.Id                = view.Id;
            _model.ProjectId         = view.ProjectId;
            _model.CourseId          = view.CourseId;
            _model.Tags              = view.Tags;
            _model.CreatedBy         = view.CreatedBy;
            _model.CreatedDate       = view.CreatedDate;
            _model.UpdatedDate       = view.UpdatedDate;
            _model.UpdatedBy         = view.UpdatedBy;
            _model.Title             = view.Title;
            _model.Summary           = view.Summary;
            _model.Content           = view.Content;
            _model.EnglishContent    = view.EnglishContent;
            _model.VietnameseContent = view.VietnameseContent;
            _model.Followers         = view.Followers;
            _model.CategoryId        = view.CategoryId;
            _model.Status            = view.Status;
            _model.Scope             = view.Scope;
            _model.AvatarPath        = view.AvatarPath;
            _model.CountViews        = view.CountViews;

            return(_model);
        }
예제 #11
0
        public async Task <IActionResult> Add(ArticleView result)
        {
            //if (await _articleService.CheckIfSlugExist(result.Slug))
            //{
            //    ModelState.AddModelError("", "Artykuł z tym linkiem już istnieje!");
            //}

            //if (!ModelState.IsValid)
            //{
            //    ViewBag.Categories = await _categoryService.GetAll();
            //    ViewBag.Tags = await _tagService.GetAll();

            //    return View(result);
            //}

            var user = await _userManager.GetUserAsync(User);

            var articleModel = ArticleHelpers.ConvertToModel(result, user, "https://theraphosidae.pl");
            var article      = await _articleService.Create(articleModel);

            if (article == false)
            {
                return(RedirectToAction("Index", "Dashboard"));
            }

            var photo = await _cloudinaryService.AddFile(result.FeaturedImg, articleModel);

            //await _taxonomyService.SaveCategories(await _categoryService.GetCategoriesByName(result.Categories), articleModel);
            //await _taxonomyService.SaveTags(await _tagService.GetCategoriesByNames(result.Tags), articleModel);

            return(RedirectToAction("List"));
        }
예제 #12
0
        public static ArticleView ArticleToView(ArticleModel model)
        {
            ArticleView view = new ArticleView();

            view.Id          = model.Id;
            view.CreatedDate = model.CreatedDate;
            view.Title       = GetRawText(model.Title);
            view.Description = GetRawText(model.Description);


            view.Content = DecorHtml(model.Content);
            if (!model.Tags.IsNullOrEmptyOrWhiteSpace())
            {
                view.Tags = model.Tags.Split(new char[] { ',', ';' }, StringSplitOptions.None);
            }
            view.IsPublished     = model.IsPublished;
            view.CreatedBy       = model.CreatedBy;
            view.MetaKeywords    = model.Tags + ";" + model.MetaKeywords;
            view.MetaDescription = model.MetaDescription;
            view.ImageUrl        = model.ImageUrl;
            view.ContentUrl      = model.ContentUrl;
            view.DocumentId      = model.DocumentId;

            view.EditLink = "https://docs.google.com/document/d/" + model.DocumentId + "/edit";
            return(view);
        }
예제 #13
0
        public async Task <IActionResult> Edit(ArticleView result)
        {
            var article = await _articleService.Get(result.Id);

            // sprawdzamy dopiero jeżeli tytuł się
            if (result.Slug != article.Slug)
            {
                // sprawdzic czy sam sobą nie jest czasem
                if (await _articleService.CheckIfSlugExist(result.Slug))
                {
                    ModelState.AddModelError("", "Wpis o podanym linku istnieje");
                }
            }

            if (!ModelState.IsValid)
            {
                // 1. Pobieranie listy tagów oraz kategorii
                ViewBag.Categories = await _categoryService.GetAll();

                ViewBag.Tags = await _tagService.GetAll();

                return(View(result));
            }

            // 2. Poprawnie zwalidowane post zapisuję do bazy danych

            // a. Jeżeli nastąpiła zamiana zdjęcia do zapisujemy
            if (result.IsPhotoEdited)
            {
                // Usuwanie starego zdjęcia tylko pod warunkiem jeżeli istnieje
                if (article.Image != null)
                {
                    // usuwanie starego zdjęcia
                    _cloudService.DeleteFile(article.Image.Id);
                }

                // Jeżeli zostało wgrane nowe zdjęcie to je zapisz i przypisz
                if (result.FeaturedImg != null)
                {
                    var medium = await _cloudService.AddFile(result.FeaturedImg);

                    article.Image = medium;
                }
            }

            // b. Aktualizacja wpisu
            var seoSettings = await _seoService.GetSeoSettings();

            await _articleService.Update(ArticleHelpers.MergeViewWithModel(article, result, seoSettings.MainUrl));

            // c. Aktualizacja taxonomies
            await _taxonomyService.Delete(result.Id);

            await _taxonomyService.SaveCategories(await _categoryService.GetCategoriesByNames(result.Categories), article);

            await _taxonomyService.SaveTags(await _tagService.GetCategoriesByNames(result.Tags), article);

            return(RedirectToAction("List"));
        }
예제 #14
0
        public JWWebViewDelegate(UIViewController controller, JWWebView jwWebView)
        {
            this.jwWebView  = jwWebView;
            this.controller = controller;

            articleView = (ArticleView)jwWebView.Parent.Parent;
            Navigated  += JWWebViewDelegate_Navigated;
        }
예제 #15
0
        // GET: /<controller>/
        public ViewResult Article(string url)
        {
            var     articles = _service.GetArticles(Axe.Recherche);
            Article article  = articles.Where(s => s.Titre == url).FirstOrDefault();
            var     vm       = ArticleView.Create(article);

            return(View("Article", vm));
        }
예제 #16
0
 public static ArticleModel Map(this ArticleView source)
 => source == null ? null : new ArticleModel
 {
     Id             = source.Id,
     Title          = source.Title,
     SequenceNumber = source.SequenceNumber,
     SeriesName     = source.SeriesName,
     SeriesIndex    = source.SeriesIndex
 };
예제 #17
0
        public ActionResult ShowPopularity()
        {
            //宣告一個新頁面模型
            ArticleView Data = new ArticleView();

            //取得頁面所需的人氣資料陣列
            Data.DataList = articleService.GetPopularityDataList();
            //將資料傳入View中
            return(View(Data));
        }
예제 #18
0
        public static Article ReverseArticle(ArticleView item)
        {
            Mapper.Initialize(p =>
            {
                p.CreateMap <ArticleView, Article>();
                p.CreateMap <WriterView, Writer>().ForMember(c => c.Articles, d => d.Ignore()).ForMember(c => c.Books, d => d.Ignore());
                p.CreateMap <MagazineView, Magazine>().ForMember(c => c.Articles, d => d.Ignore());
            });

            return(Mapper.Map <ArticleView, Article>(item));;
        }
예제 #19
0
 public ArticleViewForWeb(ArticleView view)
 {
     id          = view.id;
     url         = view.url;
     content     = ArticleInfoOper.Instance.GetSomeContent(view.content, 20);
     isArticle   = view.isArticle;
     articleName = view.articleName;
     status      = view.status;
     lastTime    = Convert.ToDateTime(view.lastTime).ToString("yyyy-MM-dd HH:mm:ss");
     articleType = view.articleType;
 }
예제 #20
0
 public void Create(ArticleView item)
 {
     if (item != null)
     {
         Article newart = CustomMap.ReverseArticle(item);
         repo.Articles.Create(newart);
         repo.Save();
         return;
     }
     throw new ValidationException("Объект не создан", "");
 }
예제 #21
0
    protected void CreditPostback_Click(object sender, EventArgs e)
    {
        int InfluencerId = -1;

        if (Request.QueryString["ref"] != null)
        {
            InfluencerId = InfluencerCodeHelper.ToUserId(Request.QueryString["ref"]);
        }

        ArticleView.TryAdd(Article.Id, IP.Current, InfluencerId);
    }
 /// <summary>
 /// Constructor to edit data of an existing article.
 /// </summary>
 /// <param name="parentViewModel"></param>
 /// <param name="article"></param>
 public ArticleEditViewModel(ArticleView.ArticleTabViewModel parentViewModel, Article article)
 {
     ParentViewModel = parentViewModel;
     EditContentTabs = new ObservableCollection<UIElement>();
     ContextualTabGroup = parentViewModel.ContextualTabGroup;
     EditContentTabs.Add(new Contextual.Controls.ArticleEditControlTabItem());
     Article = article;
     EditMode = true;
     TabItem = new ArticleEditTabItem(this);
     Content = new ArticleEditTabContent(this);
 }
예제 #23
0
        /// <summary>
        /// Thread body
        /// </summary>
        /// <param name="state"></param>
        private void StartWork(object state)
        {
            ArticleView articleView  = state as ArticleView;
            article     savedArticle = null;
            article     theArticle   = new article();

            articleView.Merge(theArticle, editMode);

            // Save to backend
            AutoResetEvent nextOneAutoResetEvent             = new AutoResetEvent(false);
            EventHandler <save_ArticleCompletedEventArgs> h1 = (s, e) =>
            {
                // TODO: handle error from server side
                savedArticle = e.Result;
                nextOneAutoResetEvent.Set();
            };

            Globals.WSClient.save_ArticleCompleted += h1;
            Globals.WSClient.save_ArticleAsync(theArticle);
            nextOneAutoResetEvent.WaitOne();
            Globals.WSClient.save_ArticleCompleted -= h1;

            // Check return result. If failure, savedCategory will be null
            if (savedArticle != null)
            {
                this.Dispatcher.BeginInvoke(delegate()
                {
                    articleView.Restore(new ArticleView(savedArticle));
                });
            }
            else
            {
                ShopproHelper.ShowMessageWindow(this, "Error", "Fail to save this entry. It is probably because you are trying to save a entry with conficting fields. \n'Name' and 'Url' fields are required unique for category.", false);

                // Back to readonly mode
                this.Dispatcher.BeginInvoke(delegate()
                {
                    // Restore cached UI data
                    articleView.CancelEdit();
                    this.itemDataForm.CancelEdit();
                });
            }

            ShopproHelper.HideBusyIndicator(this);

            // No unsaved item
            this.editMode = DataFormMode.ReadOnly;

            // If only one new page, return to the original one
            if (this.ContentPageCtx.GotoAddNewPage)
            {
                ShopproHelper.GoToContentPage(this, PageEnum.ArticleListPage);
            }
        }
예제 #24
0
        public ArticleView ToView(ArticleModel model)
        {
            ArticleView _view = new ArticleView(model);

            if (model.CategoryId.HasValue)
            {
                _view.Category = _manager.GetCategory(model.CategoryId.Value);
            }
            _view.SetAvatar();
            _view.ResizeImages();
            return(_view);
        }
예제 #25
0
        public static ArticleModel MergeViewWithModel(ArticleModel model, ArticleView view, string mainUrl)
        {
            model.Title         = view.Title;
            model.Slug          = view.Slug;
            model.Content       = view.Content;
            model.CommentStatus = view.CommentStatus;
            model.IsDraft       = view.IsDraft;
            model.Excerpt       = view.Excerpt;
            model.FullUrl       = BuildArticleFullUrl(mainUrl, view.Slug);

            return(model);
        }
예제 #26
0
        public ActionResult Submit(ArticleView articleView)
        {
            var article = _context.Articles.FirstOrDefault(p => p.Id == articleView.Article.Id);

            article.IsViolation = articleView.Article.IsViolation;
            article.IsBeingRead = false;
            article.Comment     = articleView.Article.Comment;

            _context.SaveChanges();

            return(RedirectToAction("/Index"));
        }
예제 #27
0
        //將Page(頁數)預設為1
        public ActionResult List(string Search, int Page = 1)
        {
            //宣告一個新頁面模型
            ArticleView Data = new ArticleView();

            //將傳入值Search(搜尋)放入頁面模型中
            Data.Search = Search;
            //新增頁面模型中的分頁
            Data.Paging = new ForPaging(Page);
            //從Service中取得頁面所需陣列資料
            Data.DataList = articleService.GetDataList(Data.Paging, Data.Search);
            return(PartialView(Data)); //將頁面資料傳入View中
        }
예제 #28
0
        public FileResult GetImage(int?id)
        {
            ArticleView art = db.Get(id);

            if (art != null)
            {
                return(File(art.ImageData, art.ImageMimeType));
            }
            else
            {
                return(null);
            }
        }
 /// <summary>
 /// Constructor if you want to create a new article.
 /// </summary>
 /// <param name="parentViewModel"></param>
 public ArticleEditViewModel(ArticleView.ArticleTabViewModel parentViewModel, int ID = -1)
 {
     ParentViewModel = parentViewModel;
     EditContentTabs = new ObservableCollection<UIElement>();
     ContextualTabGroup = parentViewModel.ContextualTabGroup;
     EditContentTabs.Add(new Contextual.Controls.ArticleEditControlTabItem());
     Article = new Article();
     if (ID != -1)
         Article.ArticleID = ID.ToString();
     EditMode = false;
     TabItem = new ArticleEditTabItem(this);
     Content = new ArticleEditTabContent(this);
 }
예제 #30
0
        public ActionResult Update(int id, [FromBody] ArticleView value)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Model is invalid"));
            }

            var article = mapper.Map <ArticleView, ArticleDto>(value);

            articleService.UpdateArticle(id, article);

            return(Ok($"Object (id: {id}) has been updated"));
        }
예제 #31
0
        public ActionResult Create([FromBody] ArticleView value)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Model is invalid"));
            }

            var article = mapper.Map <ArticleView, ArticleDto>(value);

            articleService.CreateArticle(article);

            return(Ok("Object has been created"));
        }
예제 #32
0
 public ActionResult CreateArticle()
 {
     List<Category> categories;
     using (var repository = _repositoryProvider.GetRepository())
     {
         categories = repository.Get<Category>().ToList();
     }
     var articleView = new ArticleView
     {
         Categories = new SelectList(Mapper.Map<List<Category>, List<CategoryView>>(categories), "Id", "Title")
     };
     return View(articleView);
 }
예제 #33
0
        private void OpenAddPanelByType(object sender, MouseButtonEventArgs e)
        {
            var    selectedItem = ListViewMenu.SelectedItem as SubItem;
            Window parentWindow = Window.GetWindow((DependencyObject)sender);

            if (parentWindow != null)
            {
                parentWindow.IsEnabled = false;
            }
            switch (selectedItem.Name)
            {
            case "Article":
                ArticleView p1 = new ArticleView();
                p1.Show();
                break;

            case "Book":
                BookView p2 = new BookView();
                p2.Show();
                break;

            case "InBook":
                InBookView p3 = new InBookView();
                p3.Show();
                break;

            case "InCollection":
                InCollectionView p4 = new InCollectionView();
                p4.Show();
                break;

            case "Manual":
                ManualView p5 = new ManualView();
                p5.Show();
                break;

            case "Conference":
                ConferenceView p6 = new ConferenceView();
                p6.Show();
                break;

            case "Booklet":
                BookletView p7 = new BookletView();
                p7.Show();
                break;

            default:
                break;
            }
        }
예제 #34
0
 public ActionResult Edit(ArticleView article)
 {
     if (ModelState.IsValid)
     {
         var newBLArticle = _mapper.Map <ArticleBL>(article);
         _articleService.Update(newBLArticle);
         return(RedirectToAction("Index"));
     }
     else
     {
         ViewBag.Message = "Not Valid";
         return(View(article));
     }
 }
예제 #35
0
        public ActionResult ListofArticles(string search, int page=1)
        {
            ArticleView dataForView=new ArticleView();
            dataForView.Search = search;
            dataForView.Paging=new ForPaging(page);
            dataForView.ArticleList = articleService.GetArticleList(dataForView.Paging, dataForView.Search);

            return PartialView(dataForView);
        }
예제 #36
0
 public ActionResult TopPopularity()
 {
     ArticleView dataForView= new ArticleView();
     dataForView.ArticleList = articleService.GetArticleListOrderByWatch();
     return View(dataForView);
 }
예제 #37
0
 public ActionResult EditArticle(ArticleView articleView)
 {
     using (var repository = _repositoryProvider.GetRepository())
     {
         var article = repository.Get<Article>().Where(a => a.Id == articleView.Id).FirstOrDefault();
         article.CommentsEnabled = articleView.CommentsEnabled;
         article.Approved = articleView.Approved;
         article.Listed = articleView.Listed;
         article.OnlyForMembers = articleView.OnlyForMembers;
         repository.Update(article);
     }
     articleView.IsDirty = false;
     ViewBag.PageTitle = "Edit Article";
     return RedirectToAction("ManageArticles", new { pageNum = 1 });
 }