Esempio n. 1
0
        //
        // POST: MySummoners
        public ActionResult DeleteSummoner(Summoner summoner)
        {
            using (var database = new SumonnerDbContext())
            {
                var summonerToDel = database.Summoners
                                    .Where(u => u.SummonerName == summoner.SummonerName)
                                    .First();

                database.Summoners.Remove(summonerToDel);
                database.SaveChanges();

                return(Redirect("/Search/MySummoners"));
            }
        }
Esempio n. 2
0
        public ActionResult AddSummoner(Summoner summoner)
        {
            if (ModelState.IsValid)
            {
                using (var database = new SumonnerDbContext())
                {
                    // Get ownerId
                    var ownerId = database.Users
                                  .Where(u => u.UserName == this.User.Identity.Name)
                                  .First()
                                  .Id;

                    // Set ownerId
                    summoner.OwnerId = ownerId;

                    database.Summoners.Add(summoner);
                    database.SaveChanges();

                    return(Redirect("/Search/MySummoners"));
                }
            }
            return(View(summoner));
        }