public async Task Delete(int technicalStaffId, int participationId)
        {

            var participationCount =
                await
                    _participationTechnicalStaves.CountAsync(
                        pt => pt.TechnicalStaffId == technicalStaffId);
            if (participationCount <= 1)
            {

                _participationTechnicalStaves.Remove(
                    await
                        _participationTechnicalStaves.FirstOrDefaultAsync(
                            pt => pt.TechnicalStaffId == technicalStaffId && pt.ParticipationId == participationId));

                var technicalStaff = new TechnicalStaff()
                {
                    Id = technicalStaffId,
                };

                _technicalStaves.Attach(technicalStaff);
                _technicalStaves.Remove(technicalStaff);
            }
            else
            {
                _participationTechnicalStaves.Remove(
                    await
                        _participationTechnicalStaves.FirstOrDefaultAsync(
                            pt => pt.TechnicalStaffId == technicalStaffId && pt.ParticipationId == participationId));
            }

        }
        public void Edit(TechnicalStaff technicalStaff)
        {
            _technicalStaves.Attach(technicalStaff);

            _dbContext.Entry(technicalStaff).State = EntityState.Modified;

        }
 public void Add(TechnicalStaff technicalStaff, int representativeUserId, int competitionId, int roleId)
 {
     _competitionCommonTechnicalStaffs.Add(new CompetitionCommonTechnicalStaff
     {
         CompetitonId = competitionId,
         RepresentativeUserId = representativeUserId,
         TechnicalStaffRoleId = roleId,
         TechnicalStaff = technicalStaff
     });
 }
        public void Delete(int technicalStaffId)
        {

            var technicalStaff = new TechnicalStaff()
            {
                Id = technicalStaffId,
            };

            _technicalStaffs.Attach(technicalStaff);
            _technicalStaffs.Remove(technicalStaff);
        }
        public void Add(TechnicalStaff technicalStaff, int participationId, int technicalStaffRoleId)
        {
            if (technicalStaff.Id == 0)
            {

                _technicalStaves.Add(technicalStaff);
                _participationTechnicalStaves.Add(new ParticipationTechnicalStaff()
                {
                    ParticipationId = participationId,
                    TechnicalStaffId = technicalStaff.Id,
                    TechnicalStaffRoleId = technicalStaffRoleId,
                });
            }
            else
            {
                _participationTechnicalStaves.Add(new ParticipationTechnicalStaff()
                {
                    ParticipationId = participationId,
                    TechnicalStaffId = technicalStaff.Id,
                    TechnicalStaffRoleId = technicalStaffRoleId,
                });
            }
        }
        public async Task Delete(int technicalStaffId, int[] similarParticipationIds)
        {
            var paricipationsCount = await
                _participationTechnicalStaves.Where(pts => pts.TechnicalStaffId == technicalStaffId).CountAsync();

            foreach (var similarParticipationId in similarParticipationIds)
            {
                _participationTechnicalStaves.Remove(
                    _participationTechnicalStaves.FirstOrDefault(
                        pts => pts.ParticipationId == similarParticipationId && pts.TechnicalStaffId == technicalStaffId));
            }

            if (paricipationsCount == similarParticipationIds.Length)
            {
                var technicalStaff = new TechnicalStaff()
                {
                    Id = technicalStaffId,
                };

                _technicalStaves.Attach(technicalStaff);
                _technicalStaves.Remove(technicalStaff);
            }

        }
        public void EditApproval(TechnicalStaff technicalStaff)
        {
            _technicalStaves.Attach(technicalStaff);

            _dbContext.Entry(technicalStaff).Property(t => t.IsApproved).IsModified = true;
            _dbContext.Entry(technicalStaff).Property(t => t.Error).IsModified = true;
            _dbContext.Entry(technicalStaff).Property(t => t.DormId).IsModified = true;
            _dbContext.Entry(technicalStaff).Property(t => t.DormNumber).IsModified = true;
        }