コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("CommentsId,BasketId,CustomersId,Comments,Marks,Reason,ReturnDate")] CommentsAboutWork commentsAboutWork)
        {
            if (id != commentsAboutWork.CommentsId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(commentsAboutWork);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CommentsAboutWorkExists(commentsAboutWork.CommentsId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BasketId"]    = new SelectList(_context.Basket, "BasketId", "BasketId", commentsAboutWork.BasketId);
            ViewData["CustomersId"] = new SelectList(_context.Customers, "CustomersId", "CustomersId", commentsAboutWork.CustomersId);
            return(View(commentsAboutWork));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("CommentsId,BasketId,CustomersId,Comments,Marks,Reason,ReturnDate")] CommentsAboutWork commentsAboutWork)
        {
            if (ModelState.IsValid)
            {
                _context.Add(commentsAboutWork);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BasketId"]    = new SelectList(_context.Basket, "BasketId", "BasketId", commentsAboutWork.BasketId);
            ViewData["CustomersId"] = new SelectList(_context.Customers, "CustomersId", "CustomersId", commentsAboutWork.CustomersId);
            return(View(commentsAboutWork));
        }