예제 #1
0
        public void Create(JournalUpdateViewModel journalView)
        {
            var     mapp    = new AutoMapperForJournal();
            Journal journal = mapp.Mapp(journalView);

            _journalRepository.Create(journal);
            //var articleInJournal = new List<ArticleInJournal>();
            //if (journalView.Articles.Count != 0)
            //{
            //    foreach (Article article in journalView.Articles)
            //    {
            //        articleInJournal.Add(new ArticleInJournal { Journal = journalView.Juornal, Article = article });
            //    }
            //}
            //if (journalView.Articles.Count == 0)
            //{
            //    articleInJournal.Add(new ArticleInJournal { Journal = journalView.Juornal });
            //}
            //_journalRepository.Create(articleInJournal);
        }
예제 #2
0
        public JournalUpdateViewModel GetJournal(int id)
        {
            Journal journalRepository = _journalRepository.Get(id);
            var     journalView       = new JournalUpdateViewModel();

            if (journalRepository != null)
            {
                var mapp = new AutoMapperForJournal();
                journalView = mapp.Mapp(journalRepository);
            }
            //List<ArticleInJournal> journal = _articleInjournalRepository.GetJournal(id).ToList();
            //var journalView = new JournalGetViewModel();
            //if (journal != null)
            //{
            //    journalView = journal.GroupBy(x => x.Journal.Id).Select(x => new JournalGetViewModel()
            //    {
            //        Juornal = x.First().Journal,
            //        Articles = x.Select(z => z.Article).ToList()
            //    }).First();
            //}
            return(journalView);
        }