Ejemplo n.º 1
0
        public IActionResult NewsEditAdmin(int?id)
        {
            var entity = _newsServices.GetByWithCategoriesAndAuthorId((int)id);

            var model = new NewsModel()
            {
                NewsId      = entity.NewsId,
                Title       = entity.Title,
                Content     = entity.Content,
                Description = entity.Description,
                Date        = entity.Date,
                Image       = entity.Image,
                Url         = entity.Url,
                IsApproved  = entity.IsApproved,
                Tags        = entity.Tags,
                nCategories = entity.newsHCategories.Select(i => i.NCategories).ToList(),
                Authors     = entity.newsAuthors.Select(i => i.Author).ToList(),
                NCategoryId = entity.newsHCategories.Select(i => i.NCategoryId).FirstOrDefault(),
                AuthorId    = entity.newsAuthors.Select(i => i.AuthorId).FirstOrDefault()
            };

            ViewBag.NCategories = _nCategoryServices.GetAll();
            ViewBag.Authors     = _authorServices.GetAll();
            return(View(model));
        }