예제 #1
0
        public IActionResult Put(int id, [FromBody] Player player)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != player.PlayerId)
            {
                return(BadRequest());
            }

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

            try
            {
                _context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PlayerExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(new StatusCodeResult(StatusCodes.Status204NoContent));
        }
예제 #2
0
        public async Task <IActionResult> PutTavern([FromRoute] int id, [FromBody] Tavern tavern)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tavern.ID)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
예제 #3
0
 public ActionResult Edit([Bind(Include = "Id,Name")] Type type)
 {
     if (ModelState.IsValid)
     {
         db.Entry(type).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(type));
 }
 public ActionResult Edit([Bind(Include = "Id,DrinkId,Value")] Rating rating)
 {
     if (ModelState.IsValid)
     {
         db.Entry(rating).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.DrinkId = new SelectList(db.Drinks, "Id", "Name", rating.DrinkId);
     return(View(rating));
 }
 public ActionResult Edit([Bind(Include = "Id,Name,TypeId")] Ingredient ingredient)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ingredient).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.TypeId = new SelectList(db.Types, "Id", "Name", ingredient.TypeId);
     return(View(ingredient));
 }
예제 #6
0
 public ActionResult Edit([Bind(Include = "Id,DrinkId,IngredientId,Amount")] Recipe recipe)
 {
     if (ModelState.IsValid)
     {
         db.Entry(recipe).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.DrinkId      = new SelectList(db.Drinks, "Id", "Name", recipe.DrinkId);
     ViewBag.IngredientId = new SelectList(db.Ingredients, "Id", "Name", recipe.IngredientId);
     return(View(recipe));
 }
예제 #7
0
 public ActionResult Edit([Bind(Include = "Id,IngredientId,AttributeId,Value")] AttributeValue attributeValue)
 {
     if (ModelState.IsValid)
     {
         db.Entry(attributeValue).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.AttributeId  = new SelectList(db.Attributes, "Id", "Name", attributeValue.AttributeId);
     ViewBag.IngredientId = new SelectList(db.Ingredients, "Id", "Name", attributeValue.IngredientId);
     return(View(attributeValue));
 }
 public ActionResult Edit([Bind(Include = "Id,TypeId,AttributeId")] TypeAttribute typeAttribute)
 {
     if (ModelState.IsValid)
     {
         db.Entry(typeAttribute).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.AttributeId = new SelectList(db.Attributes, "Id", "Name", typeAttribute.AttributeId);
     ViewBag.TypeId      = new SelectList(db.Types, "Id", "Name", typeAttribute.TypeId);
     return(View(typeAttribute));
 }