public async Task <IActionResult> Edit(int id, [Bind("AnimeInfoId,StudioName,Status,AgeRating,Type,Description,Source,Season")] AnimeInfo animeInfo)
        {
            if (id != animeInfo.AnimeInfoId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(animeInfo);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AnimeInfoExists(animeInfo.AnimeInfoId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(animeInfo));
        }
Пример #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Info,CategoryId")] Manga manga)
        {
            if (id != manga.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(manga);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MangaExists(manga.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Name", manga.CategoryId);
            return(View(manga));
        }
Пример #3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,YearBirth,Information,CountryId")] GenManagers genManagers)
        {
            if (id != genManagers.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(genManagers);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GenManagersExists(genManagers.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CountryId"] = new SelectList(_context.Countries, "Id", "Id", genManagers.CountryId);
            return(View(genManagers));
        }
Пример #4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Information")] Products products)
        {
            if (id != products.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(products);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductsExists(products.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(products));
        }
Пример #5
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Info,DateTime,BookId")] Comment comment)
        {
            if (id != comment.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(comment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CommentExists(comment.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BookId"] = new SelectList(_context.Books, "Id", "Fb2", comment.BookId);
            return(View(comment));
        }
Пример #6
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Info")] Reader reader)
        {
            if (id != reader.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(reader);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ReaderExists(reader.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(reader));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Price,Information,CompProdId,ColorId")] ModelsOfProduct modelsOfProduct)
        {
            if (id != modelsOfProduct.Id)
            {
                return(NotFound());
            }
            var compProdId = modelsOfProduct.CompProdId;
            var CompProd   = _context.CompanyProducts.Where(c => c.Id == compProdId).FirstOrDefault();

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(modelsOfProduct);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ModelsOfProductExists(modelsOfProduct.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                //return RedirectToAction(nameof(Index));
                return(RedirectToAction("Index", "ModelsOfProducts", new { id = modelsOfProduct.CompProdId, companyId = CompProd.CompanyId, productId = CompProd.ProductId }));
            }
            ViewData["ColorId"]    = new SelectList(_context.Colors, "Id", "Id", modelsOfProduct.ColorId);
            ViewData["CompProdId"] = new SelectList(_context.CompanyProducts, "Id", "Id", modelsOfProduct.CompProdId);
            //return View(modelsOfProduct);
            return(RedirectToAction("Index", "ModelsOfProducts", new { id = modelsOfProduct.CompProdId, companyId = CompProd.CompanyId, productId = CompProd.ProductId }));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,MangaId,AuthorId")] AuthorsManga authorsManga)
        {
            if (id != authorsManga.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(authorsManga);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AuthorsMangaExists(authorsManga.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AuthorId"] = new SelectList(_context.Authors, "Id", "Name", authorsManga.AuthorId);
            ViewData["MangaId"]  = new SelectList(_context.Mangas, "Id", "Name", authorsManga.MangaId);
            return(View(authorsManga));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,ReaderId,MangaId,StatusId,PlanReturn,FactReturn")] ReadersManga readersManga)
        {
            if (id != readersManga.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(readersManga);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ReadersMangaExists(readersManga.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MangaId"]  = new SelectList(_context.Mangas, "Id", "Name", readersManga.MangaId);
            ViewData["ReaderId"] = new SelectList(_context.Readers, "Id", "Name", readersManga.ReaderId);
            ViewData["StatusId"] = new SelectList(_context.Statuses, "Id", "Name", readersManga.StatusId);
            return(View(readersManga));
        }
Пример #10
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Year,CountryId,GenManagerId")] Companies companies)
        {
            if (id != companies.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(companies);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CompaniesExists(companies.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }

            ViewData["CountryId"]    = new SelectList(_context.Countries, "Id", "Name", companies.CountryId);
            ViewData["GenManagerId"] = new SelectList(_context.GenManagers, "Id", "Name", companies.GenManagerId);
            return(View(companies));
        }
        public async Task <IActionResult> Edit(int id, [Bind("AnimeId,Poster,AnimeName,Rating,AnimeInfoId")] Anime anime)
        {
            if (id != anime.AnimeId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(anime);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AnimeExists(anime.AnimeId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AnimeInfoId"] = new SelectList(_context.AnimeInfos, "AnimeInfoId", "Description", anime.AnimeInfoId);
            return(View(anime));
        }
Пример #12
0
        public async Task <IActionResult> Edit(int id, [Bind("CountryId,CountryName")] Country country)
        {
            if (id != country.CountryId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(country);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CountryExists(country.CountryId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(country));
        }
Пример #13
0
        public async Task <IActionResult> Edit(int id, [Bind("MatchId,MatchName,MatchResult,FirstClubId,SecondClubId,MatchDate")] ClubMatch clubMatch)
        {
            if (id != clubMatch.MatchId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(clubMatch);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClubMatchExists(clubMatch.MatchId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["FirstClubId"]  = new SelectList(_context.Clubs, "ClubId", "ClubId", clubMatch.FirstClubId);
            ViewData["SecondClubId"] = new SelectList(_context.Clubs, "ClubId", "ClubId", clubMatch.SecondClubId);
            return(View(clubMatch));
        }
Пример #14
0
        public async Task <IActionResult> Edit(int id, [Bind("GenreId,GenreName,Description")] Genre genre)
        {
            if (id != genre.GenreId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(genre);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GenreExists(genre.GenreId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(genre));
        }
Пример #15
0
        public async Task <IActionResult> Edit(int id, [Bind("TransferId,SellerId,BuyerId,PlayerId,CostOfPlayer,Date")] Transfer transfer)
        {
            if (id != transfer.TransferId)
            {
                return(NotFound());
            }

            if (transfer.CostOfPlayer < 0)
            {
                ModelState.AddModelError("CostOfPlayer", "Ціна не може бути від'ємною");
                ViewData["BuyerId"]  = new SelectList(_context.Clubs, "ClubId", "ClubName");
                ViewData["PlayerId"] = new SelectList(_context.Players.Where(x => x.ClubId > 0), "PlayerId", "LastName");
                ViewData["SellerId"] = new SelectList(_context.Clubs, "ClubId", "ClubName");
                return(View(transfer));
            }

            if (_context.Players.Where(x => x.ClubId == transfer.SellerId).Any(x => x.PlayerId == transfer.PlayerId))
            {
                if (ModelState.IsValid)
                {
                    if (transfer.SellerId != transfer.BuyerId)
                    {
                        try
                        {
                            _context.Update(transfer);
                            await _context.SaveChangesAsync();
                        }
                        catch (DbUpdateConcurrencyException)
                        {
                            if (!TransferExists(transfer.TransferId))
                            {
                                return(NotFound());
                            }
                            else
                            {
                                throw;
                            }
                        }
                        return(RedirectToAction(nameof(Index)));
                    }
                    else
                    {
                        ModelState.AddModelError("BuyerId", "Команди співпадають");
                    }
                }
            }
            else
            {
                ModelState.AddModelError("PlayerId", "Гравець не з команди продавця");
            }
            ViewData["BuyerId"]  = new SelectList(_context.Clubs, "ClubId", "ClubName");
            ViewData["PlayerId"] = new SelectList(_context.Players.Where(x => x.ClubId > 0), "PlayerId", "LastName");
            ViewData["SellerId"] = new SelectList(_context.Clubs, "ClubId", "ClubName");
            return(View(transfer));
        }
Пример #16
0
        public async Task <IActionResult> Edit(int id, [Bind("PlayerId,FirstName,LastName,DateOfBirth,CountryId,Biography")] Player player)
        {
            var playerToEdit = await _context.Players.FirstOrDefaultAsync(x => x.PlayerId == id);

            playerToEdit.FirstName   = player.FirstName;
            playerToEdit.LastName    = player.LastName;
            playerToEdit.DateOfBirth = player.DateOfBirth;
            playerToEdit.CountryId   = player.CountryId;
            playerToEdit.Biography   = player.Biography;

            if (id != player.PlayerId)
            {
                return(NotFound());
            }

            if ((DateTime.Now.Year - player.DateOfBirth.Value.Year) < 18 || (DateTime.Now.Year - player.DateOfBirth.Value.Year) > 120)
            {
                ViewData["ClubId"]    = new SelectList(_context.Clubs, "ClubId", "ClubName", player.ClubId);
                ViewData["CountryId"] = new SelectList(_context.Countries, "CountryId", "CountryName", player.CountryId);
                ModelState.AddModelError("DateOfBirth", "Неправильна дата");
                return(View(player));
            }


            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(playerToEdit);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PlayerExists(player.PlayerId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            string messages = string.Join("; ", ModelState.Values
                                          .SelectMany(x => x.Errors)
                                          .Select(x => x.ErrorMessage));

            ViewData["ClubId"]    = new SelectList(_context.Clubs, "ClubId", "ClubName", player.ClubId);
            ViewData["CountryId"] = new SelectList(_context.Countries, "CountryId", "CountryName", player.CountryId);

            return(View(player));
        }
Пример #17
0
        public async Task <IActionResult> Edit(int id, [Bind("ClubId,ClubName,CoachFirstName,CoachLastName,CoachDateOfBirth,StadiumName,StadiumCapacity,CoachBiography")] Club club)
        {
            if (id != club.ClubId)
            {
                return(NotFound());
            }

            if ((DateTime.Now.Year - club.CoachDateOfBirth.Value.Year) < 18 || (DateTime.Now.Year - club.CoachDateOfBirth.Value.Year) > 120)
            {
                ModelState.AddModelError("CoachDateOfBirth", "Неправильна дата");
                return(View(club));
            }

            if (club.StadiumCapacity < 0)
            {
                ModelState.AddModelError("StadiumCapacity", "Місткість не може бути від'ємною");
                return(View(club));
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(club);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClubExists(club.ClubId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(club));
        }
Пример #18
0
        public async Task <IActionResult> Edit(int id, [Bind("TeamId,CountryId,CoachFirstName,CoachLastName,CoachDateOfBirth,CoachBiography")] Team team)
        {
            if (id != team.TeamId)
            {
                return(NotFound());
            }

            if ((DateTime.Now.Year - team.CoachDateOfBirth.Year) < 18 || (DateTime.Now.Year - team.CoachDateOfBirth.Year) > 120)
            {
                ViewData["CountryId"] = new SelectList(_context.Countries, "CountryId", "CountryId", team.CountryId);
                ModelState.AddModelError("CoachDateOfBirth", "Неправильна дата");
                return(View(team));
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(team);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TeamExists(team.TeamId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CountryId"] = new SelectList(_context.Countries, "CountryId", "CountryId", team.CountryId);
            return(View(team));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,CompanyId,ProductId")] CompanyProducts companyProducts)
        {
            if (id != companyProducts.Id)
            {
                return(NotFound());
            }


            string?productName = _context.Products.Where(c => c.Id == companyProducts.ProductId).FirstOrDefault().Name;

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(companyProducts);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CompanyProductsExists(companyProducts.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                //return RedirectToAction(nameof(Index));
                return(RedirectToAction("Index", "CompanyProducts", new { id = companyProducts.ProductId, name = productName }));
            }
            ViewData["CompanyId"] = new SelectList(_context.Companies, "Id", "Name", companyProducts.CompanyId);
            ViewData["ProductId"] = new SelectList(_context.Products, "Id", "Name", companyProducts.ProductId);
            return(RedirectToAction("Index", "CompanyProducts", new { id = companyProducts.ProductId, name = productName }));
            //return View(companyProducts);
        }
Пример #20
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Amount,CompanyId,CountryId")] Filials filials)
        {
            int?   companyId   = filials.CompanyId;
            string?companyName = _context.Companies.Where(c => c.Id == companyId).FirstOrDefault().Name;

            if (id != filials.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(filials);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FilialsExists(filials.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index", "Filials", new { id = companyId, name = companyName }));
            }
            ViewData["CompanyId"] = new SelectList(_context.Companies, "Id", "Id", filials.CompanyId);
            ViewData["CountryId"] = new SelectList(_context.Countries, "Id", "Id", filials.CountryId);
            return(RedirectToAction("Index", "Filials", new { id = companyId, name = companyName }));

            //return View(filials);
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Info,Fb2,Pdf,PagesQuantity,Picture")] Book book, int[] genres, int[] authors)
        {
            if (id != book.Id)
            {
                return(NotFound());
            }

            var AreRepeats = _context.Books.Where(obj => obj.Id != book.Id && obj.Name == book.Name && obj.PagesQuantity == book.PagesQuantity);

            foreach (var a in AreRepeats)
            {
                bool flag   = false;
                var  aBooks = _context.AuthorsBooks.Where(obj => obj.BookId == a.Id);
                foreach (var author in authors)
                {
                    if (aBooks.Where(obj => obj.AuthorId == author).Count() > 0)
                    {
                        flag = true;
                    }
                    break;
                }
                if (flag)
                {
                    ModelState.AddModelError("", "Така книга вже існує");
                    break;
                }
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(book);
                    foreach (var item in _context.GenresBooks)
                    {
                        if (item.BookId == book.Id)
                        {
                            _context.GenresBooks.Remove(item);
                        }
                    }
                    foreach (var item in _context.AuthorsBooks)
                    {
                        if (item.BookId == book.Id)
                        {
                            _context.AuthorsBooks.Remove(item);
                        }
                    }

                    foreach (int GId in genres)
                    {
                        GenresBook gb = new GenresBook {
                            GenreId = GId, BookId = book.Id
                        };
                        book.GenresBooks.Add(gb);
                    }


                    foreach (int AId in authors)
                    {
                        AuthorsBook ab = new AuthorsBook {
                            AuthorId = AId, BookId = book.Id
                        };
                        book.AuthorsBooks.Add(ab);
                    }

                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BookExists(book.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }

            var thisGenres = _context.GenresBooks.Where(obj => obj.BookId == id).Join(_context.Genres, b => b.GenreId, g => g.Id, (b, g) => new
            {
                Id   = b.GenreId,
                Name = g.Name
            });

            List <string> thisNames = new List <string>();

            foreach (var g in thisGenres)
            {
                thisNames.Add(g.Name);
            }

            ViewBag.ThisGenres  = thisGenres;
            ViewBag.OtherGenres = _context.Genres.Where(obj => !thisNames.Contains(obj.Name)).ToList();

            var thisAuthors = _context.AuthorsBooks.Where(obj => obj.BookId == id).Join(_context.Authors, b => b.AuthorId, a => a.Id, (b, a) => new
            {
                Id       = b.AuthorId,
                FullName = a.FirstName + " " + a.LastName
            });

            List <string> thisFullNames = new List <string>();

            foreach (var a in thisAuthors)
            {
                thisFullNames.Add(a.FullName);
            }

            ViewBag.ThisAuthors  = thisAuthors;
            ViewBag.OtherAuthors = _context.Authors.Where(obj => !thisFullNames.Contains(obj.FirstName + " " + obj.LastName)).ToList();
            return(View(book));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,Info,BirthYear,DeathYear")] Author author, int[] countries)
        {
            if (id != author.Id)
            {
                return(NotFound());
            }

            var IsRepeat = _context.Authors.Where(obj => obj.Id != author.Id && obj.FirstName == author.FirstName && obj.LastName == author.LastName && obj.BirthYear == author.BirthYear);

            foreach (var item in IsRepeat)
            {
                bool flag = false;
                var  IsRepeatCountries = thisAuthorCountries(item.Id);
                foreach (var c in countries)
                {
                    if (IsRepeatCountries.Where(obj => obj.CountryId == c).Count() > 0)
                    {
                        flag = true;
                        break;
                    }
                }
                if (flag)
                {
                    ModelState.AddModelError("", "Такий автор вже існує");
                    break;
                }
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(author);
                    var authorsCountries = thisAuthorCountries(id);
                    foreach (var item in authorsCountries)
                    {
                        _context.AuthorsCountries.Remove(item);
                    }

                    {
                        foreach (var cID in countries)
                        {
                            AuthorsCountry ac = new AuthorsCountry {
                                AuthorId = author.Id, CountryId = cID
                            };
                            author.AuthorsCountries.Add(ac);
                        }
                    }
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AuthorExists(author.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }

            var thisC = _context.AuthorsCountries.Where(obj => obj.AuthorId == id).Join(_context.Countries, a => a.CountryId, c => c.Id, (a, c) => new
            {
                Id   = a.CountryId,
                Name = c.Name
            });

            List <string> CNames = new List <string>();

            foreach (var tC in thisC)
            {
                CNames.Add(tC.Name);
            }

            ViewBag.OtherCountries = _context.Countries.Where(obj => !CNames.Contains(obj.Name)).ToList();

            ViewBag.ThisCountries = thisC;

            return(View(author));
        }