예제 #1
0
        public async Task <IHttpActionResult> PutAlchemyCost(int id, AlchemyCost alchemyCost)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != alchemyCost.Id)
            {
                return(BadRequest());
            }

            db.Entry(alchemyCost).State = EntityState.Modified;

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <ActionResult> Create([Bind(Include = "Id,Name,Initial,StrokeColor,FillColor")] AlchemyElement alchemyElement)
        {
            if (ModelState.IsValid)
            {
                _db.AlchemyElements.Add(alchemyElement);
                await _db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(alchemyElement));
        }
예제 #3
0
        public async Task <ActionResult> Create([Bind(Include = "Id,Name,ShortName")] AlchemyRank alchemyRank)
        {
            if (ModelState.IsValid)
            {
                db.AlchemyRanks.Add(alchemyRank);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(alchemyRank));
        }
        public async Task <ActionResult> Create([Bind(Include = "Id,Element,Name,VictoryPoints,Rank,Costs")] AlchemyCard alchemyCard)
        {
            if (ModelState.IsValid)
            {
                _db.AlchemyCards.Add(alchemyCard);
                await _db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.Element = new SelectList(_db.AlchemyElements, "Id", "Name", alchemyCard.Element);
            ViewBag.Rank    = new SelectList(_db.AlchemyRanks, "Id", "Name", alchemyCard.Rank);
            return(View(alchemyCard));
        }