Exemplo n.º 1
0
        public async Task <IActionResult> Edit(string id, [Bind("Id,Name,Price,Image")] Item item)
        {
            if (id != item.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(item);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ItemExists(item.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(item));
        }
Exemplo n.º 2
0
        public IEnumerable <Item> Put([FromBody] Item item)
        {
            if (item == null)
            {
                return(new List <Item> {
                    new Item()
                    {
                        ItemName = "NotFound."
                    }
                });
            }
            if (!_context.Items.Any(x => x.Id == item.Id))
            {
                return(new List <Item> {
                    new Item()
                    {
                        ItemName = "NotFound."
                    }
                });
            }
            _context.Update(item);
            _context.SaveChanges();

            return(_context.Items.ToList());
        }
        public async Task <IActionResult> Edit(int id, [Bind("IdModel,BitchNameModel,NumberModel,TiTDescriptionModel,ProfilePictureModel")] ListViewModel item)
        {
            if (id != item.IdModel)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(item);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ItemExists(item.IdModel))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(item));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Product,Price")] Items items)
        {
            if (id != items.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(items);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ItemsExists(items.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(items));
        }