void IGroupRepository.Delete(int id) { tGroup user = Find(id); if (user != null && user.IDGroup > 0) { context.tGroups.DeleteOnSubmit(user); } context.SubmitChanges(); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } tGroup = await _context.tGroup.SingleOrDefaultAsync(m => m.group_id == id); if (tGroup == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } tGroup = await _context.tGroup.FindAsync(id); if (tGroup != null) { _context.tGroup.Remove(tGroup); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public void InsertOrUpdate(tGroup user) { if (user.IDGroup == default(int)) { // New entity context.tGroups.InsertOnSubmit(user); } else { // Existing entity tGroup userToUpdate = Find(user.IDGroup); if (userToUpdate != null && userToUpdate.IDGroup > 0) { userToUpdate.Name = user.Name; userToUpdate.IDGroup = user.IDGroup; } } context.SubmitChanges(); }