Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("LoreID,WorldID,Title,Details")] Lore lore)
        {
            if (id != lore.LoreID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(lore);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LoreExists(lore.LoreID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["WorldID"] = new SelectList(_context.Worlds, "WorldID", "Name", lore.WorldID);
            return(View(lore));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("Name,Summary,WorldID")] World world)
        {
            if (id != world.WorldID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(world);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!WorldExists(world.WorldID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(world));
        }
        public async Task <IActionResult> Edit(int id, [Bind("RelationshipID,Character1ID,Character2ID,RelationshipTypeID,Details")] Relationship Relationship)
        {
            if (id != Relationship.RelationshipID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(Relationship);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RelationshipExists(Relationship.RelationshipID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RelationshipTypeID"] = new SelectList(_context.RelationshipTypes, "RelationshipTypeID", "Description", Relationship.RelationshipTypeID);
            return(View(Relationship));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Edit(int id, [Bind("LocationID,WorldID,Name,Summary")] Location location)
        {
            if (id != location.LocationID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var change = _context.Locations.AsNoTracking().FirstOrDefault(m => m.LocationID == id);
                    _context.Update(location);
                    await _context.SaveChangesAsync();

                    if (change.WorldID != location.WorldID)
                    {
                        var worldContext = await _context.Characters.Include(c => c.World).Where(m => m.LocationID == location.LocationID).ToListAsync();

                        foreach (var character in worldContext)
                        {
                            character.World   = location.World;
                            character.WorldID = location.WorldID;
                            _context.Update(character);
                            await _context.SaveChangesAsync();
                        }
                    }
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LocationExists(location.LocationID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["WorldID"] = new SelectList(_context.Worlds, "WorldID", "Name", location.WorldID);
            return(View(location));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Edit(int id, [Bind("Name,CharacterID,WorldID,LocationID,Summary")] Character character)
        {
            if (id != character.CharacterID)
            {
                return(NotFound());
            }

            var location = await _context.Locations.Include(l => l.World).FirstOrDefaultAsync(m => m.LocationID == character.LocationID);

            ViewBag.data = null;
            if (character.LocationID != null && character.WorldID != location.WorldID)
            {
                ViewData["LocationID"] = new SelectList(_context.Locations, "LocationID", "Name", character.LocationID);
                ViewData["WorldID"]    = new SelectList(_context.Worlds, "WorldID", "Name", character.WorldID);
                ViewBag.location       = location;
                return(View(character));
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(character);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CharacterExists(character.CharacterID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["LocationID"] = new SelectList(_context.Locations, "LocationID", "Name", character.LocationID);
            ViewData["WorldID"]    = new SelectList(_context.Worlds, "WorldID", "Name", character.WorldID);
            return(View(character));
        }
Ejemplo n.º 6
0
 public void UpdateTrip(Trip trip)
 {
     _context.Update(trip);
 }