Esempio n. 1
0
        public async Task <IActionResult> PutCharacterFridge(int id, CharacterFridge characterFridge)
        {
            if (id != characterFridge.CharacterFridgeId)
            {
                return(BadRequest());
            }

            _context.Entry(characterFridge).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CharacterFridgeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 2
0
        public async Task <ActionResult <CharacterFridge> > PostCharacterFridge(CharacterFridge characterFridge)
        {
            _context.CharacterFridge.Add(characterFridge);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetCharacterFridge", new { id = characterFridge.CharacterFridgeId }, characterFridge));
        }
Esempio n. 3
0
        public ActionResult <CharacterFridge> GetCharacterFridge(int fridgeID)
        {
            SqlParameter    param1           = new SqlParameter("@FridgeID", fridgeID);
            Character       sessionCharacter = HttpContext.Session.GetJson <Character>("Character");
            SqlParameter    param2           = new SqlParameter("@CharID", sessionCharacter.CharacterId);
            CharacterFridge charFridge       = _context.CharacterFridge.FromSqlRaw("Select * from characterfridge where fridgeid = @FridgeID and characterid = @CharID", param1, param2).FirstOrDefault();

            if (charFridge == null)
            {
                return(NotFound());
            }

            return(charFridge);
        }