public ActionResult Edit(int id) { PublishingDTO publishing = publishingService.GetPublishing(id); if (publishing == null) { return(null); } PublishingEditViewModel editViewModel = new PublishingEditViewModel { Publishing = mapper.Map <PublishingViewModel>(publishing), AvailableTopics = mapper .Map <IEnumerable <TopicViewModel> >(publishingService.GetTopicsNotInPublishing(id)), TopicsAtPublishing = mapper .Map <IEnumerable <TopicViewModel> >(publishing.Topics), EditorsAtPublishing = mapper .Map <IEnumerable <PublishingEmployeeViewModel> >(publishing.Editors), JournalistsAtPublishing = mapper .Map <IEnumerable <PublishingEmployeeViewModel> >(publishing.Journalists), AvailableEditors = mapper .Map <IEnumerable <PublishingEmployeeViewModel> >(publishingService.GetEditorsNotInPublishing(id)), AvailableJournalists = mapper .Map <IEnumerable <PublishingEmployeeViewModel> >(publishingService.GetJournalistsNotInPublishing(id)), }; return(View(editViewModel)); }
public IHttpActionResult GetPublishings(int id) { var publishing = publishingService.GetPublishing(id); if (publishing != null) { return(Ok(new { publishing.Id, publishing.Title })); } else { return(StatusCode(HttpStatusCode.NoContent)); } }
/// <summary> /// Метод создания списка рецензий /// </summary> /// <param name="reviwerId">Id редактора</param> /// <returns>Список рецензий. Каждая рецензия содержит наименование издания, рубрики, имя автора, /// наименование статьи, id статьи и флаг одобрения рецензии</returns> public IEnumerable <DetailedReviewDTO> CreateDetailedReviewList(int reviwerId) { var reviews = db.Reviews.GetUserReviews(reviwerId); return(reviews.Select(x => { var article = articleService.GetArticleById(x.ArticleId); var author = employeeService.GetEmployeeById(article.AuthorId); var publishing = publishingService.GetPublishing(article.PublishingId); var topic = publishingService.GetTopic(article.TopicId); return new DetailedReviewDTO { // Заполняем поля модели рецензии из ответа сервиса статей и объекта рецензии ArticleId = article.Id, ReviwerId = reviwerId, Article = article.Title, Approved = x.Approved, Author = $"{author.FirstName} {author.MiddleName} {author.LastName}", Publishing = publishing.Title, Topic = topic.Name }; })); }