public async Task JoinToProject(int projectId, string userIdentityLogin) { ProjectEntity project = _context.Projects.Find(projectId); if (project.UserProjects.Count() == project.MaxPeople) { throw new Exception(); } UserEntity user = await _context.Users.FirstOrDefaultAsync(u => u.Login.ToLower() == userIdentityLogin.ToLower()); _context.UserProjects.Add(new UserProjectEntity { Project = project, User = user }); await _context.SaveChangesAsync(); }
public async Task Create(TEntity entity) { _dbSet.Add(entity); await _context.SaveChangesAsync(); }