Exemplo n.º 1
0
        public async Task Delete(DatabaseContext contexte, int id)
        {
            var entite = new QueryOffre().GetById(contexte, id);

            contexte.Offres.Remove(entite);
            await contexte.SaveChangesAsync();
        }
Exemplo n.º 2
0
        public KeyValuePair <Offre, IEnumerable <Employe> > GetOffreAvecEmployes(int id)
        {
            using (var contexte = new DatabaseContext())
            {
                var offre    = new QueryOffre().GetById(contexte, id);
                var idsToGet = new QueryPostulation()
                               .GetAllWith(contexte, item => Equals(item.OffreId, offre.Id))
                               .Select(item => item.EmployeId)
                               .Distinct();
                var emps = new QueryEmploye().GetAllWith(contexte, item => idsToGet.Contains(item.Id));

                return(new KeyValuePair <Offre, IEnumerable <Employe> >(offre, emps));
            }
        }
Exemplo n.º 3
0
        public Offre GetOffre(int id)
        {
            using (var contexte = new DatabaseContext()){
                var entite = new QueryOffre().GetById(contexte, id);

                if (entite != null)
                {
                    return(entite);
                }
                else
                {
                    throw new EntityNotFoundException($"{id}");
                }
            }
        }
Exemplo n.º 4
0
        public IDictionary <Offre, IEnumerable <Employe> > GetAllOffresAvecEmployes()
        {
            var retour = new Dictionary <Offre, IEnumerable <Employe> >();

            using (var contexte = new DatabaseContext())
            {
                var offres = new QueryOffre().GetAll(contexte);

                Parallel.ForEach(offres, offre => {
                    var idsToGet = new QueryPostulation()
                                   .GetAllWith(contexte, item => Equals(item.OffreId, offre.Id))
                                   .Select(item => item.EmployeId)
                                   .Distinct();

                    var emps = new QueryEmploye().GetAllWith(contexte, item => idsToGet.Contains(item.Id));

                    retour.Add(offre, emps);
                });
            }

            return(retour);
        }