예제 #1
0
        public async Task <ActionResult> Create(FormCollection collection)
        {
            try
            {
                await manager.CreateOffreAsync(EditerOffre(collection));

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View("Errors/Erreur405"));
            }
        }
예제 #2
0
        static void Stub()
        {
            ManagerBLL bll = new ManagerBLL();

            Console.WriteLine("Debut Stub");
            try
            {
                List <Task> tasks = new List <Task>();

                var statutDispo = new Statut {
                    Libelle = "Dispo"
                };
                var statutPasDispo = new Statut {
                    Libelle = "Pas Dispo"
                };

                // Employes
                var emp1 = new Employe {
                    Nom = "Leon", Prenom = "Thibaud", Anciennete = 1, DateDeNaissance = Convert.ToDateTime("02/02/1996")
                };
                var emp2 = new Employe {
                    Nom = "Berard", Prenom = "Yves", Anciennete = 2, DateDeNaissance = Convert.ToDateTime("10/12/1984")
                };
                var emp3 = new Employe {
                    Nom = "Meunier", Prenom = "Anne", Anciennete = 3, DateDeNaissance = Convert.ToDateTime("11/01/1977")
                };
                tasks.Add(bll.CreateEmployeAsync(emp1));
                tasks.Add(bll.CreateEmployeAsync(emp2));
                tasks.Add(bll.CreateEmployeAsync(emp3));

                // Status
                tasks.Add(bll.CreateStatutAsync(statutDispo));
                tasks.Add(bll.CreateStatutAsync(statutPasDispo));

                Task.WaitAll(tasks.ToArray());
                tasks.Clear();

                // Offres
                var off1 = new Offre {
                    Date = DateTime.Now, Intitule = "Mangaka", Description = "Faire des jolis dessins.", Responsable = "Eiichiro Oda", Salaire = 30000, Statut = statutDispo
                };
                var off2 = new Offre {
                    Date = DateTime.Now, Intitule = "Cuisinier", Description = "Faire des kebabs toute la journée.", Responsable = "M. Amed", Salaire = 15000, Statut = statutDispo
                };
                var off3 = new Offre {
                    Date = DateTime.Now, Intitule = "Fonctionnaire", Description = "De 10h à midi et de 14h à 16h uniquement.", Responsable = "Le gouvernement", Salaire = 100000, Statut = statutDispo
                };
                tasks.Add(bll.CreateOffreAsync(off1));
                tasks.Add(bll.CreateOffreAsync(off2));
                tasks.Add(bll.CreateOffreAsync(off3));

                Task.WaitAll(tasks.ToArray());
                tasks.Clear();

                //Postulations
                tasks.Add(bll.CreatePostulationAsync(off1.Id, emp2.Id));
                tasks.Add(bll.CreatePostulationAsync(off2.Id, emp2.Id));
                tasks.Add(bll.CreatePostulationAsync(off2.Id, emp1.Id));
                tasks.Add(bll.CreatePostulationAsync(off3.Id, emp3.Id));

                Task.WaitAll(tasks.ToArray());
            }
            catch (AggregateException e)
            {
                Console.WriteLine(e.Message);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            Console.WriteLine("Fini");
        }