//добавление без валидации public async Task <List <Competence> > AddCompetences(ApplicationDbContext db, string[] competences) { var needAdded = await Competence.CreateInDbIfNeed(db, competences); List <CompetenceUser> forAddedRelation = new List <CompetenceUser>(); needAdded.ForEach(x => { forAddedRelation.Add(new CompetenceUser(x.Id, this.Id)); }); db.CompetenceUsers.AddRange(forAddedRelation); await db.SaveChangesAsync(); return(needAdded); }
public async static Task <List <int> > GetActualInTown(ApplicationDbContext db, int townId) { return(await Competence.GetActualQueryEntityInTown(db, townId).Select(x1 => x1.Id).ToListAsync()); }
//получаем сокращенные данные public async static Task <List <CompetenceShort> > GetActualShortEntityInTown(ApplicationDbContext db, int?townId) { return(await Competence.GetActualQueryEntityInTown(db, townId).Select(x1 => new CompetenceShort(x1.Name, x1.Id)).ToListAsync());//Select(x1=>new { x1.Key,Count= x1.Count() }) }