public async Task <IdentityResult> CreateAsync(Role role, CancellationToken cancellationToken) { db.Add(role); await db.SaveChangesAsync(cancellationToken); return(await Task.FromResult(IdentityResult.Success)); }
public async Task <IdentityResult> CreateAsync(Employee employee, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); if (employee == null) { throw new ArgumentNullException(nameof(employee)); } db.Add(employee); await db.SaveChangesAsync(cancellationToken); return(await Task.FromResult(IdentityResult.Success)); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(Employee).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeeExists(Employee.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Employees.Add(Employee); await _context.SaveChangesAsync(); return(RedirectToPage("/Admin/Index")); }
public async Task <IActionResult> OnPostAsync(string id) { if (id == null) { return(NotFound()); } Employee = await _context.Employees.FindAsync(id); if (Employee != null) { _context.Employees.Remove(Employee); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }