Beispiel #1
0
        public async Task <IActionResult> EditItemGoods(Guid id, [Bind("Id,Probability,Description,NeedAdditionalUpgrade,GoodsId,ItemId")] ItemGoods itemGoods)
        {
            if (id != itemGoods.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(itemGoods);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ItemGoodsExists(itemGoods.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(EditGoods), new { id = itemGoods.GoodsId }));
            }

            ViewData["ItemsName"] = new SelectList(_context.Items, "Id", "Name", itemGoods.ItemId).OrderBy(SLI => SLI.Text);
            return(View(itemGoods));
        }
Beispiel #2
0
        public async Task <IActionResult> CreateItemGoods([Bind("Id,Probability,Description,NeedAdditionalUpgrade,GoodsId,ItemId")] ItemGoods itemGoods)
        {
            if (ModelState.IsValid)
            {
                itemGoods.Id = Guid.NewGuid();
                _context.Add(itemGoods);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(EditGoods), new { id = itemGoods.GoodsId }));
            }

            ViewData["ItemsName"] = new SelectList(_context.Items, "Id", "Name", itemGoods.ItemId).OrderBy(SLI => SLI.Text);
            return(View(itemGoods));
        }