public async Task <IActionResult> Create([Bind("Id,CategoryName,Description,IsEnabled")] Category category)
        {
            if (ModelState.IsValid)
            {
                _context.Add(category);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }
示例#2
0
        public async Task <IActionResult> Create([Bind("Id,country_name,is_enabled")] Country country)
        {
            if (ModelState.IsValid)
            {
                _context.Add(country);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(country));
        }
示例#3
0
        public async Task <IActionResult> Create([Bind("Id,CityName,PostalZip,IsEnabled,CountryId")] City city)
        {
            if (ModelState.IsValid)
            {
                _context.Add(city);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CountryId"] = new SelectList(_context.Countries, "Id", "Id", city.CountryId);
            return(View(city));
        }
示例#4
0
        public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,JoinedDate,IsActivated,CityId,Street")] Author author)
        {
            if (ModelState.IsValid)
            {
                _context.Add(author);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CityId"] = new SelectList(_context.Cities, "Id", "Id", author.CityId);
            return(View(author));
        }
示例#5
0
        public async Task <IActionResult> Create([Bind("Id,BookId,Title,Content,ModifiedDate,ModifiedBy,IsEnabled")] Chapter chapter)
        {
            if (ModelState.IsValid)
            {
                _context.Add(chapter);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BookId"] = new SelectList(_context.Books, "Id", "Id", chapter.BookId);
            return(View(chapter));
        }
        public async Task <IActionResult> Create([Bind("Id,BookId,ModifiedDate,ModifiedBy")] BookCover bookCover)
        {
            if (ModelState.IsValid)
            {
                _context.Add(bookCover);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BookId"] = new SelectList(_context.Books, "Id", "Id", bookCover.BookId);
            return(View(bookCover));
        }
示例#7
0
        public async Task <IActionResult> Create([Bind("Id,Title,Description,AuthorId,ModifiedDate,ModifiedBy,IsPublished,CategoryId")] Book book)
        {
            if (ModelState.IsValid)
            {
                _context.Add(book);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AuthorId"]   = new SelectList(_context.Authors, "Id", "Id", book.AuthorId);
            ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Id", book.CategoryId);
            return(View(book));
        }