public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,Address,City,Country,Gender")] Customer customer)
        {
            if (id != customer.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(customer);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CustomerExists(customer.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(customer));
        }
Example #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,IssueDate,BookId,CustomerId,NoOfDays,Rate,Amount")] Issue issue)
        {
            if (id != issue.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(issue);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!IssueExists(issue.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BookId"]     = new SelectList(_context.Book, "Id", "Id", issue.BookId);
            ViewData["CustomerId"] = new SelectList(_context.Customer, "Id", "Id", issue.CustomerId);
            return(View(issue));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Abbrivation,IsEnabled")] Category category)
        {
            if (id != category.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(category);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CategoryExists(category.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }
Example #4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Email,Mobileno,ContactPerson,IsEnabled")] Publisher publisher)
        {
            if (id != publisher.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(publisher);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PublisherExists(publisher.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(publisher));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,BookName,BookDescription,CategoryId,PublisherId,AuthorId,Price,PublishYear,InStock")] Book book)
        {
            if (id != book.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(book);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BookExists(book.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AuthorId"]    = new SelectList(_context.Author, "Id", "Id", book.AuthorId);
            ViewData["CategoryId"]  = new SelectList(_context.Category, "Id", "Id", book.CategoryId);
            ViewData["PublisherId"] = new SelectList(_context.Publisher, "Id", "Id", book.PublisherId);
            return(View(book));
        }