Пример #1
0
        public IActionResult Details(int locationId)
        {
            locationId++;

            string userId = User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
            Player player = db.Players.Include(p => p.Location)
                            .FirstOrDefault(p => p.UserId == userId);

            player.LocationId = locationId;

            db.Entry(player).State = EntityState.Modified;
            var locationCount = db.Locations.ToList().Count;

            if (player.LocationId <= locationCount)
            {
                db.SaveChanges();
                ViewBag.player = player;
                List <PlayerInventory> inventory = db.PlayerInventory.Include(pi => pi.Item)
                                                   .Where(pi => pi.PlayerId == player.Id).ToList();
                foreach (PlayerInventory invetoryEntry in inventory)
                {
                    ViewBag.items.Add(invetoryEntry.Item);
                }
                return(View(player.Location));
            }
            else
            {
                player.LocationId      = 1;
                db.Entry(player).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index", "Account"));
            }
        }
Пример #2
0
        public IActionResult Edit(IdentityRole role)
        {
            try
            {
                var thisRole = db.Roles.FirstOrDefault(r => r.Id == role.Id);
                thisRole.Name            = role.Name;
                thisRole.NormalizedName  = role.Name.ToUpper();
                db.Entry(thisRole).State = EntityState.Modified;
                Debug.WriteLine("try" + thisRole.Name);

                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            catch
            {
                Debug.WriteLine("***************************************" + role.Name);
                return(View());
            }
        }