public PublicationPreviewViewModel(List<Article> articles, MyBlogRepository rep, string tag)
 {
     this.Articles = new List<Article>();
     int tagId = rep.Tags.Where(x => x.TagName == tag).Select(x => x.Id).FirstOrDefault();
     List<int> articlesId = rep.GetArticlesToTags(tagId);
     foreach(int articleId in articlesId)
     {
         this.Articles.Add(rep.Articles.Find(x => x.Id == articleId));
     }
 }
Exemplo n.º 2
0
 public NewPublicationViewModel(MyBlogRepository repository, int id)
 {
     this.Id = id;
     var publication =  repository.Articles.Find(x => x.Id == id);
     this.Title = publication.ArticleTitle;
     this.ArticleText = publication.ArticleText;
     var selectedTagsId = repository.GetTagsIdToArticle(id);
     this.Tags = repository.Tags.Select(x => new SelectListItem()
     {
         Value = x.Id.ToString(),
         Text = x.TagName
     }).ToList();
     foreach(int curSelTagId in selectedTagsId)
     {
         for (int i = 0; i < this.Tags.Count; i++ )
         {
             if (curSelTagId.ToString() == this.Tags[i].Value)
             {
                 this.Tags[i].Selected = true;
             }
         }
     }
 }
Exemplo n.º 3
0
 public AboutSelfFormViewModel(MyBlogRepository repository)
 {
     AboutSelf = new AboutSelf();
     genderText = new List<String> { "мужской", "женский" };
     hobbyText = new List<String> { "спорт", "видеоигры", "коллекционирование", "йога" };
 }
Exemplo n.º 4
0
 public void FillTags(MyBlogRepository repository)
 {
     this.Tags = repository.Tags.Select(x => new SelectListItem()
     {
         Value = x.Id.ToString(),
         Text = x.TagName
     }).ToList();
 }
Exemplo n.º 5
0
 public NewPublicationViewModel(MyBlogRepository repository)
 {
     FillTags(repository);
 }