コード例 #1
0
        public async Task <IActionResult> CreateBookListing(CreateListingInputDto input, CancellationToken cancellationToken)
        {
            var mapped = _mapper.Map <ListingEntity>(input);

            _dbContext.Add(mapped);
            await _dbContext.SaveChangesAsync(cancellationToken);

            return(Ok(mapped.Id.ToResultModel()));
        }
コード例 #2
0
        public bool Post(EmailRegister model)
        {
            var result = _dbContext.Add(model).Entity;

            if (result != null)
            {
                return(true);
            }
            return(false);
        }
コード例 #3
0
        public async Task <IActionResult> Create([Bind("BrandId,Name")] Brand brand)
        {
            if (ModelState.IsValid)
            {
                _context.Add(brand);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(brand));
        }
コード例 #4
0
        public async Task <IActionResult> Create([Bind("Id,Name,Image")] Author author)
        {
            if (ModelState.IsValid)
            {
                _context.Add(author);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(author));
        }
コード例 #5
0
        public async Task <IActionResult> Create([Bind("LanguageId,Name")] Language language)
        {
            if (ModelState.IsValid)
            {
                _context.Add(language);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(language));
        }
コード例 #6
0
        public async Task <IActionResult> Create([Bind("Id,CommentString,BookId")] Comment comment)
        {
            if (ModelState.IsValid)
            {
                _context.Add(comment);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Create)));
            }
            ViewData["BookId"] = new SelectList(_context.Books, "Id", "Name", comment.BookId);
            return(View(comment));
        }
コード例 #7
0
        public async Task <IActionResult> Create([Bind("Id,AddressTitle,AddressDetails,UserId")] Address address)
        {
            if (ModelState.IsValid)
            {
                _context.Add(address);
                await _context.SaveChangesAsync();

                return(Redirect("/Cart/PaymentDetail"));
            }
            ViewData["UserId"] = new SelectList(_context.Users, "Id", "Email", address.UserId);
            return(View(address));
        }
コード例 #8
0
        public async Task <IActionResult> Create([Bind("Id,FullName,CartNo,Month,Year,CVV,UserId")] CreditCart creditCart)
        {
            if (ModelState.IsValid)
            {
                _context.Add(creditCart);
                await _context.SaveChangesAsync();

                return(Redirect("/Cart/PaymentDetail"));
            }
            ViewData["UserId"] = new SelectList(_context.Users, "Id", "Email", creditCart.UserId);
            return(View(creditCart));
        }
コード例 #9
0
        public async Task <IActionResult> Create([Bind("BookId,GenreId")] GenreBook genreBook)
        {
            if (ModelState.IsValid)
            {
                _context.Add(genreBook);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BookId"]  = new SelectList(_context.Books, "BookId", "Name", genreBook.BookId);
            ViewData["GenreId"] = new SelectList(_context.Genres, "GenreId", "Name", genreBook.GenreId);
            return(View(genreBook));
        }
コード例 #10
0
 public bool Create(Section item)
 {
     try
     {
         _context.Add(item);
         _context.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
        public async Task <IActionResult> Create([Bind("BookId,AuthorId")] AuthorBook authorBook)
        {
            if (ModelState.IsValid)
            {
                _context.Add(authorBook);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AuthorId"] = new SelectList(_context.Authors, "AuthorId", "LastName", authorBook.AuthorId);
            ViewData["BookId"]   = new SelectList(_context.Books, "BookId", "Name", authorBook.BookId);
            return(View(authorBook));
        }
コード例 #12
0
        public async Task <IActionResult> Create([Bind("Id,Name,LastName,Email,UserName,Password,PhoneNumber,RoleId,GenderId")] User user)
        {
            if (ModelState.IsValid)
            {
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(Redirect("/Account/Login"));
            }
            ViewData["GenderId"] = new SelectList(_context.Set <Gender>(), "Id", "Id", user.GenderId);
            ViewData["RoleId"]   = new SelectList(_context.Set <Role>(), "Id", "Id", user.RoleId);
            return(View(user));
        }
コード例 #13
0
        public async Task <IActionResult> Create([Bind("Id,Name,Image,Price,Content,PageNumber,Point,Rating,ReleaseDate,DiscountRate,SoldNumber,CategoryId,PublisherId,AuthorId")] Book book)
        {
            if (ModelState.IsValid)
            {
                _context.Add(book);
                await _context.SaveChangesAsync();

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