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); }
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); }