Example #1
0
        public ActionResult Create(Player player)
        {
            if (string.IsNullOrEmpty(player.Name))
            {
                log.Error("Player name shouldn't be empty");
                throw new ArgumentException("Player name shouldn't be empty");
            }
            player.Id = Guid.NewGuid();
            db.Players.Add(player);
            db.SaveChanges();

            var actions = new IndexAction <Player>[]
            {
                IndexAction.Upload(player)
            };
            var batch = IndexBatch.New(actions);

            try
            {
                _soccerIndex.Documents.Index(batch);
            }
            catch (IndexBatchException e)
            {
                // Sometimes when your Search service is under load, indexing will fail for some of the documents in
                // the batch. Depending on your application, you can take compensating actions like delaying and
                // retrying. For this simple demo, we just log the failed document keys and continue.
                Console.WriteLine(
                    "Failed to index some of the documents: {0}",
                    String.Join(", ", e.IndexingResults.Where(r => !r.Succeeded).Select(r => r.Key)));
            }

            return(RedirectToAction("Index"));
        }
 public ActionResult Create(Player player)
 {
     //Добавляем игрока в таблицу
     db.Players.Add(player);
     db.SaveChanges();
     // перенаправляем на главную страницу
     return(RedirectToAction("Index"));
 }
Example #3
0
        public ActionResult Create(Player player)
        {
            //Добавляем игрока в таблицу
            db.Players.Add(player);
            db.SaveChanges();

            SearchHelper.AddToIndex(new List <Player>()
            {
                player
            });

            // перенаправляем на главную страницу
            return(RedirectToAction("Index"));
        }