public async Task <bool> CreateAsync(Role role) { _dbContext.Add(role); await _dbContext.SaveChangesAsync(); return(true); }
public async Task <IActionResult> Create([Bind("Id,Name")] Role role) { if (ModelState.IsValid) { _context.Add(role); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(role)); }
public async Task <IActionResult> Create([Bind("Id,FullName,Password,Email,Phone,RoleId")] User user) { if (ModelState.IsValid) { _context.Add(user); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["RoleId"] = new SelectList(_context.Roles, "Id", "Id", user.RoleId); return(View(user)); }
public async Task <IActionResult> Create([Bind("Id,Name,Price,Status,Image,CategoryId")] Product product) { if (ModelState.IsValid) { _context.Add(product); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Id", product.CategoryId); return(View(product)); }