예제 #1
0
 public void GetAllJounrey()
 {
     using (EFJourneyMapper mapper = new EFJourneyMapper(CONNECTION_STRING))
     {
         Assert.AreNotEqual(0, mapper.GetAll().Count);
     }
 }
예제 #2
0
 public void GetOneJourneyByID()
 {
     using (EFJourneyMapper mapper = new EFJourneyMapper(CONNECTION_STRING))
     {
         Assert.AreEqual(journeyClassic1.Description, mapper.FindBy(1).Description);
     }
 }
예제 #3
0
 public void AddJourneyWithoutDriverUpDateTime()
 {
     using (EFJourneyMapper mapper = new EFJourneyMapper(CONNECTION_STRING))
     {
         mapper.AddorUpdate(journeyWithoutDriverUpDateTime);
     }
 }
예제 #4
0
 public void AddEmptyJourney()
 {
     using (EFJourneyMapper mapper = new EFJourneyMapper(CONNECTION_STRING))
     {
         mapper.AddorUpdate(journeyEmpty);
     }
 }
예제 #5
0
 public void AddJourneyWithoutFreeSeat()
 {
     using (EFJourneyMapper mapper = new EFJourneyMapper(CONNECTION_STRING))
     {
         Assert.AreNotEqual(0, mapper.AddorUpdate(journeyWithoutFreeSeat));
     }
 }
예제 #6
0
 public void AddJourneyWithoutSartingAddress()
 {
     using (EFJourneyMapper mapper = new EFJourneyMapper(CONNECTION_STRING))
     {
         mapper.AddorUpdate(journeyWithoutStartingAddress);
     }
 }
예제 #7
0
 public void AddJourneyWithoutDescription()
 {
     using (EFJourneyMapper mapper = new EFJourneyMapper(CONNECTION_STRING))
     {
         mapper.AddorUpdate(journeyWithoutDescription);
     }
 }
예제 #8
0
 public void AddJourneyClassic()
 {
     using (EFJourneyMapper mapper = new EFJourneyMapper(CONNECTION_STRING))
     {
         journeyClassic1 = mapper.AddorUpdate(journeyClassic1);
         Assert.AreNotEqual(0, journeyClassic1.ID);
     }
 }
예제 #9
0
        public void DeleteJourney()
        {
            using (EFJourneyMapper mapper = new EFJourneyMapper(CONNECTION_STRING))
            {
                mapper.Delete(2);

                Expression <Func <Journey, bool> > expression = j => j.ID == 2;
                Assert.AreEqual(0, mapper.FindBy(expression).Count);
            }
        }
예제 #10
0
        public void UpdateJourney()
        {
            using (EFJourneyMapper mapper = new EFJourneyMapper(CONNECTION_STRING))
            {
                journeyClassic4 = mapper.AddorUpdate(journeyClassic4);

                journeyClassic4.Description = "coucou";
                journeyClassic4             = mapper.AddorUpdate(journeyClassic4);

                Assert.AreEqual("coucou", mapper.FindBy(journeyClassic4.ID).Description);
            }
        }
예제 #11
0
        public void AddJounreys()
        {
            List <Journey> journeys = new List <Journey>
            {
                journeyClassic2, journeyClassic3
            };

            using (EFJourneyMapper mapper = new EFJourneyMapper(CONNECTION_STRING))
            {
                Assert.AreNotEqual(0, mapper.AddorUpdate(journeys).First().ID);
            }
        }
예제 #12
0
        public void GetOneJourneyBysearch()
        {
            Journey journey = journeyClassic4;

            journey.ID       = 0;
            journey.FreeSeat = 10;
            using (EFJourneyMapper mapper = new EFJourneyMapper(CONNECTION_STRING))
            {
                journey = mapper.AddorUpdate(journey);

                Expression <Func <Journey, bool> > expression = j => j.Description == journey.Description && j.Driver == journey.Driver;
                Assert.AreEqual(journey.ID, mapper.FindBy(expression).First().ID);
            }
        }
예제 #13
0
        public void UpdateJourneyAddPassenger()
        {
            journeyClassic4.ID          = 0;
            journeyClassic4.Description = "trajet 5";
            journeyClassic4.Driver      = users[1];
            using (EFJourneyMapper mapper = new EFJourneyMapper(CONNECTION_STRING))
            {
                journeyClassic4 = mapper.AddorUpdate(journeyClassic4);

                journeyClassic4.Passengers.Add(users[0]);
                mapper.AddorUpdate(journeyClassic4);

                Assert.AreEqual(users[0].Login, mapper.FindBy(journeyClassic4.ID).Passengers.First().Login);
            }
        }
 public ActionResult AddJourney(Journey journey)
 {
     if (ModelState.IsValid)
     {
         using (EFJourneyMapper mapper = new EFJourneyMapper("WebProject2017-DBb"))
         {
             try
             {
                 journey.Driver = (User)Session["User"];
                 journey        = mapper.AddorUpdate(journey);
                 return(RedirectToAction("Profil", "Users"));
             }
             catch (Exception ex)
             {
                 ViewBag.MessageErreur = ex.Message;
             }
         }
     }
     return(View(journey));
 }
        // GET: Journey
        public ActionResult SearchJourney()
        {
            SearchJourneyViewModel model = new SearchJourneyViewModel();

            model.Result = new List <Journey>();
            using (EFJourneyMapper mapper = new EFJourneyMapper("WebProject2017-DBb"))
            {
                model.Result = mapper.GetAll();
            }
            model.JourneysUser = new List <Journey>();
            if (((User)Session["User"]) != null)
            {
                foreach (Journey j in model.Result)
                {
                    if (j.Driver.ID == ((User)Session["User"]).ID)
                    {
                        model.JourneysUser.Add(j);
                    }
                }
            }
            return(View(model));
        }