示例#1
0
        private static void AddSecretIdentityUsingSamuraiId()
        {
            var identity = new SecretIdentity {
                SamuraiId = 1,
            };

            businessDbContext.Add(identity);
            businessDbContext.SaveChanges();
        }
示例#2
0
        public async Task <IActionResult> Create([Bind("CustomerId,CustomerName,BirthDate,Gender,IsActive,CreatedDate,UpdatedDate")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(customer));
        }
示例#3
0
        public async Task <IActionResult> Create([Bind("Id,Name")] Samurai samurai)
        {
            if (ModelState.IsValid)
            {
                _context.Add(samurai);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(samurai));
        }
        public async Task <IActionResult> Create([Bind("CategoryId,CategoryName")] Category category)
        {
            if (ModelState.IsValid)
            {
                _context.Add(category);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }
示例#5
0
 private static void JoinBattleAndSamurai()
 {
     using (var context = new BusinessDBContext())
     {
         var sbJoin = new SamuraiBattle {
             SamuraiId = 1, BattleId = 3
         };
         context.Add(sbJoin);
         context.SaveChanges();
     }
 }
        public async Task <IActionResult> Create([Bind("ProductId,ProductName,Rate,Quantity,CategoryId")] Product product)
        {
            if (ModelState.IsValid)
            {
                _context.Add(product);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryId"] = new SelectList(_context.Category, "CategoryId", "CategoryName", product.CategoryId);
            return(View(product));
        }
示例#7
0
        public async Task <IActionResult> Create([Bind("OrderId,OrderDate,CustomerId,TotalAmount")] Order order)
        {
            if (ModelState.IsValid)
            {
                _context.Add(order);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerId"] = new SelectList(_context.Customer, "CustomerId", "CustomerName", order.CustomerId);
            return(View(order));
        }
示例#8
0
        public async Task <IActionResult> Create([Bind("Id,Text,SamuraiId")] Quote quote)
        {
            if (ModelState.IsValid)
            {
                _context.Add(quote);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Details", "Samurais", new { id = quote.SamuraiId }));
            }

            //ViewData["SamuraiId"] = new SelectList(_context.Samurais, "Id", "Id", quote.SamuraiId);
            return(RedirectToAction("Details", "Samurais", new { id = quote.SamuraiId }));
        }
        public async Task <IActionResult> Create([Bind("OrderId,ProductId,Quantity,Rate")] OrderDetail orderDetail)
        {
            if (ModelState.IsValid)
            {
                _context.Add(orderDetail);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["OrderId"]   = new SelectList(_context.Order, "OrderId", "OrderId", orderDetail.OrderId);
            ViewData["ProductId"] = new SelectList(_context.Product, "ProductId", "ProductName", orderDetail.ProductId);
            return(View(orderDetail));
        }