示例#1
0
        public async Task <IActionResult> Create([Bind("ID,LastName,MiddleName,FirstName,Gender,Address,Mobile")] User user)
        {
            if (ModelState.IsValid)
            {
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(user));
        }
示例#2
0
        public async Task <IActionResult> Create([Bind("ID,Name,Description,Typr,Brand,Price,Image,Rating")] Mobile mobile)
        {
            if (ModelState.IsValid)
            {
                _context.Add(mobile);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(mobile));
        }
示例#3
0
        public async Task <IActionResult> Create([Bind("ID,UserID,MobileID,OrderDate")] Order order)
        {
            if (ModelState.IsValid)
            {
                _context.Add(order);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MobileID"] = new SelectList(_context.Mobile, "ID", "ID", order.MobileID);
            ViewData["UserID"]   = new SelectList(_context.Set <User>(), "ID", "ID", order.UserID);
            return(View(order));
        }
示例#4
0
 public async Task SaveAsync()
 {
     await _context.SaveChangesAsync();
 }