public async Task AddUserToSection(string userId, Guid sectionId) { var item = new SectionUser() { SectionId = sectionId, UserId = userId }; await _context.SectionUsers.AddAsync(item); }
public async Task AddUserToSection(User user, Section section) { var item = new SectionUser() { SectionId = section.Id, UserId = user.Id }; await _context.SectionUsers.AddAsync(item); }
public async Task <ActionResult <SectionUser> > DeleteSectionUser(SectionUser sectionUser) { //var sectionUser = await _context.SectionUsers.FindAsync(id); if (sectionUser.UserId == null || sectionUser.SectionId == 0) { return(NotFound()); } _context.SectionUsers.Remove(sectionUser); await _context.SaveChangesAsync(); return(sectionUser); }
public async Task <ActionResult <SectionUser> > PostSectionUser(SectionUser sectionUser) { _context.SectionUsers.Add(sectionUser); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (SectionUserExists(sectionUser.SectionId)) { return(Conflict()); } else { throw; } } return(CreatedAtAction("GetSectionUser", new { id = sectionUser.SectionId }, sectionUser)); }