public IActionResult AddArticle(int prisonerId, int articleId) { Prisoner prisoner = _prisonerDalService.Get(prisonerId); Article article = _articleDalService.Get(articleId); if (prisoner is null || article is null) { return(Json(new { redirectToUrl = Url.Action("Edit", new { id = prisonerId }) })); } prisoner.Articles.Add(article); _prisonerDalService.Update(prisoner); return(Json(new { redirectToUrl = Url.Action("Edit", new { id = prisonerId }) })); }
public string GetArticleNames(int[] ids) { List <Article> articles = new List <Article>(); foreach (var id in ids) { Article article = _articleDalService.Get(id); if (article is null) { continue; } articles.Add(article); } if (!articles.Any()) { return("-- не выбрано --"); } return(string.Join(", ", articles.Select(a => a.Name))); }