示例#1
0
        public List <Traject> GetTrajectenbyStations(long beginStationId, long eindStationId)
        {
            try
            {
                string query = "SELECT id, naam, actief FROM GetTrajects" +
                               " WHERE beginPerronId IN ( SELECT Id FROM Perron WHERE stationId = @beginstationid)" +
                               " AND eindPerronId IN ( SELECT Id FROM Perron WHERE = @eindstationid";

                List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >()
                {
                    new KeyValuePair <string, string>("beginstationid", beginStationId.ToString()),
                    new KeyValuePair <string, string>("eindstationid", eindStationId.ToString())
                };
                DataSet        results   = ExecuteSql(query, parameters);
                List <Traject> trajecten = new List <Traject>();
                if (results != null)
                {
                    for (int x = 0; x < results.Tables[0].Rows.Count; x++)
                    {
                        Traject t = DataSetParser.DataSetToTraject(results, x);
                        trajecten.Add(t);
                    }
                }
                return(trajecten);
            }
            catch
            {
                return(null);
            }
        }
示例#2
0
        public bool UpdateTraject(Traject treinreis)
        {
            int index = Trajecten.FindIndex(t => t.Id == treinreis.Id);

            Trajecten[index] = treinreis;
            return(true);
        }
示例#3
0
        public bool UpdateTraject(Traject t)
        {
            string query = "update Traject set [actief] = @actief, @fields where Id = @id";

            string fields = "";
            List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("id", t.Id.ToString()),
                new KeyValuePair <string, string>("actief", t.Actief ? "1" : "0")
            };

            if (t.Naam != null)
            {
                if (!string.IsNullOrWhiteSpace(fields))
                {
                    fields += ",";
                }
                fields += "[naam] = @naam";
                parameters.Add(new KeyValuePair <string, string>("naam", t.Naam));
            }

            query = query.Replace("@fields", fields);

            ExecuteSql(query, parameters);
            return(true);
        }
示例#4
0
        public void AssignIncidentToTraject(Guid trajectId, Employee employee, Incident incident)
        {
            Traject traject = unitOfWork.TrajectRepository.Get(x => x.Id == trajectId, null, "").FirstOrDefault();

            if (traject == null)
            {
                throw new HandledException("Trayecto no existente.");
            }

            incident.Traject = traject;

            unitOfWork.IncidentRepository.Create(incident);
            unitOfWork.IncidentRepository.Save();

            var company = unitOfWork.CompanyRepository.Get(x => x.Employees.Contains(employee), null, "Employees").FirstOrDefault();

            if (company != null)
            {
                var administrators = unitOfWork.AdministratorRepository.Get(x => x.Company.Id == company.Id, null, "").ToList();

                foreach (var admin in administrators)
                {
                    if (admin.FirebaseDeviceToken != null)
                    {
                        firebaseMessagingRestClient.SendNotification(admin.FirebaseDeviceToken, "Incidente reportado.", $"{employee.UserName} ha reportado un incidente a la hora {incident.CreationTime}");
                    }
                }
            }
        }
        public List <Traject> GetTrajecten()
        {
            List <Traject> trajecten = new List <Traject>();

            try
            {
                using (SqlConnection con = dbconn.GetConnString())
                {
                    con.Open();
                    using (SqlCommand cmd = new SqlCommand("SELECT * FROM dbo.Traject", con))
                    {
                        using (SqlDataReader reader = cmd.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                Traject traject = new Traject();
                                traject.TrajectId   = (int)reader["TrajectId"];
                                traject.TrajectNaam = (string)reader["TrajectNaam"];
                                trajecten.Add(traject);
                            }
                        }
                    }
                }
                return(trajecten);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(trajecten);
            }
        }
        public Incident CreateIncident(String Base64Image, String description)
        {
            var location = new Location();

            location.Latitude     = 1;
            location.Longitude    = 1;
            location.LocationTime = DateTime.Now;
            var traject = new Traject();

            traject.Distance        = 1;
            traject.Duration        = 1;
            traject.IsFinished      = true;
            traject.LocationFinal   = location;
            traject.LocationInitial = location;
            traject.StartDate       = DateTime.Now;

            location.Address = "Montevideo";
            var incident = new Incident();

            incident.Location     = location;
            incident.CreationTime = DateTime.Now;
            incident.Base64Image  = Base64Image;
            incident.Description  = description;
            incident.Traject      = traject;

            return(incident);
        }
示例#7
0
        public Traject GetTrajectByID(int id)
        {
            Traject traject = new Traject();

            try
            {
                using (SqlConnection con = dbconn.SqlConnectie)
                {
                    con.Open();
                    using (SqlCommand cmd = new SqlCommand("Select * FROM dbo.Traject WHERE TeamID = @id", con))
                    {
                        cmd.Parameters.AddWithValue("@id", id);
                        using (SqlDataReader reader = cmd.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                traject.TrajectId   = (int)reader["TrajectId"];
                                traject.TrajectNaam = reader["TrajectNaam"]?.ToString();
                            }
                        }
                    }
                }
            }
            catch (SqlException fout)
            {
                Debug.WriteLine(fout.Message);
            }

            return(traject);
        }
示例#8
0
        public void MaakVeerbootEenHavenInTraject()
        {
            Haven   haven   = new Haven("Gent");
            Traject traject = new Traject();

            traject.VoegToe(haven);
            schip = new Veerboot("Test", 1.0, 1.0, 1.0, 1, traject);
        }
示例#9
0
        public ActionResult DeleteConfirmed(int id)
        {
            Traject traject = db.Trajects.Find(id);

            db.Trajects.Remove(traject);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#10
0
        public void MaakCruiseschipEenHavenInTraject()
        {
            Haven   haven   = new Haven("Gent");
            Traject traject = new Traject();

            traject.VoegToe(haven);
            schip = new Cruiseschip("Test", 1.0, 1.0, 1.0, 1, traject);
        }
示例#11
0
        public void CreateTraject()
        {
            EmptyLists();

            treinreisRepository = new TrajectRepository(context);
            Traject treinreis = new Traject(5, "naam", DateTime.Today, new Trein(5, "naam", 231, new Positie(1, 32, 42)));

            Assert.Equal(5, treinreisRepository.CreateTraject(treinreis));
        }
示例#12
0
        public Guid CreateTraject(Employee employee, Traject traject)
        {
            traject.LocationInitial.LocationTime = DateTime.Now;
            employee.Trajects.Add(traject);
            unitOfWork.EmployeeRepository.Update(employee);
            unitOfWork.EmployeeRepository.Save();

            return(traject.Id);
        }
示例#13
0
        public void UpdateTraject()
        {
            EmptyLists();

            treinreisRepository = new TrajectRepository(context);
            Traject treinreis = new Traject(1, "naam", DateTime.Today, new Trein(1, "naam", 231, new Positie(1, 32, 42)));

            Assert.True(treinreisRepository.UpdateTraject(treinreis));
        }
示例#14
0
        public void GetTrajectbyId()
        {
            EmptyLists();

            treinreisRepository = new TrajectRepository(context);
            Traject treinreis = new Traject(1, "naam", DateTime.Today, new Trein(1, "naam", 231, new Positie(1, 32, 42)));

            Assert.Equal(treinreis.Id, treinreisRepository.GetTrajectbyId(1).Id);
            Assert.Equal("naam", treinreis.Naam);
        }
示例#15
0
 public ActionResult Edit([Bind(Include = "ID,TrajectName,JamDateTime")] Traject traject)
 {
     if (ModelState.IsValid)
     {
         db.Entry(traject).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(traject));
 }
示例#16
0
        public void UpdateTrajactTest()
        {
            IQueryable <Traject> trajecten = new List <Traject>()
            {
                new Traject()
                {
                    ID                = 1,
                    Titel             = "dotNET cursus 2",
                    Type              = ".NET",
                    Prijs             = 18.45,
                    Cursussen         = new List <Cursus>(),
                    IsBuyable         = false,
                    Beschrijving      = "Some example text some ...",
                    Categorie         = "Cursus",
                    LangeBeschrijving = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
                    FotoURLCard       = "https://52bec9fb483231ac1c712343-jebebgcvzf.stackpathdns.com/wp-content/uploads/2016/05/dotnet.jpg",
                    OrderNumber       = 1
                }
            }.AsQueryable();

            var traject = new Traject()
            {
                ID                = 1,
                Titel             = "dotNET cursus 2",
                Type              = ".NET",
                Cursussen         = new List <Cursus>(),
                Prijs             = 12,
                IsBuyable         = false,
                Beschrijving      = "Some example text some ...",
                Categorie         = "Cursus",
                LangeBeschrijving = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
                FotoURLCard       = "https://52bec9fb483231ac1c712343-jebebgcvzf.stackpathdns.com/wp-content/uploads/2016/05/dotnet.jpg",
                OrderNumber       = 2
            };

            var mockSet = new Mock <DbSet <Traject> >();

            mockSet.As <IQueryable <Traject> >().Setup(m => m.Provider).Returns(trajecten.Provider);
            mockSet.As <IQueryable <Traject> >().Setup(m => m.Expression).Returns(trajecten.Expression);
            mockSet.As <IQueryable <Traject> >().Setup(m => m.ElementType).Returns(trajecten.ElementType);
            mockSet.As <IQueryable <Traject> >().Setup(m => m.GetEnumerator()).Returns(trajecten.GetEnumerator());

            var mockContext = new Mock <DatabaseContext>();

            mockContext.Setup(m => m.Trajecten).Returns(mockSet.Object);

            var mockRepo = new Mock <ITrajectRepository>();

            mockRepo.Setup(m => m.UpdateTraject(It.IsAny <Traject>())).Returns(traject);
            var updatedTraject = mockRepo.Object.UpdateTraject(traject);

            // Assert
            mockRepo.Verify(m => m.UpdateTraject(It.IsAny <Traject>()), Times.Once);
            Assert.AreEqual(updatedTraject.Prijs, 12);
        }
示例#17
0
        private void TrajectList_ItemClick_1(object sender, ItemClickEventArgs e)
        {
            Traject t = (Traject)e.ClickedItem;

            if (t != null)
            {
                this.ViewModel.PickTraject(t);

                Messenger.Default.Send("", "highlight");
            }
        }
示例#18
0
 public IActionResult Create(TrajectDetailViewModel vm)
 {
     if (ModelState.IsValid)
     {
         TrajectViewModelConverter trajectViewModelConverter = new TrajectViewModelConverter();
         Traject t  = trajectViewModelConverter.ViewModelToTraject(vm);
         decimal id = repo.CreateTraject(t);
         return(RedirectToAction("Details", new { id }));
     }
     return(View());
 }
示例#19
0
        public ActionResult Create([Bind(Include = "ID,TrajectName,JamDateTime")] Traject traject)
        {
            if (ModelState.IsValid)
            {
                db.Trajects.Add(traject);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(traject));
        }
示例#20
0
        public void MaakVeerbootTweeHavensInTraject()
        {
            Haven   haven   = new Haven("Gent");
            Haven   haven2  = new Haven("Antwerpen");
            Traject traject = new Traject();

            traject.VoegToe(haven);
            traject.VoegToe(haven2);
            schip = new Veerboot("Test", 1.0, 1.0, 1.0, 1, traject);
            Assert.AreEqual(2, ((Veerboot)schip).Traject.Count);
        }
示例#21
0
        static void Main(string[] args)
        {
            //Sleepboot test = new Sleepboot("Sleepboot", 1.0, 1.0, 1.0);
            //Console.WriteLine(test.Naam);

            //Olietanker test2 = new Olietanker("Olietanker", 1.0, 1.0, 1.0, 1m, 1.0, Olietanker.OlietankerLading.olie);
            //Console.WriteLine(test2.Naam);

            Rederij rederij = new Rederij();
            Vloot   vloot   = new Vloot("Vloot");
            Vloot   vloot1  = new Vloot("Vloot1");
            Vloot   vloot2  = new Vloot("Vloot2");
            Vloot   vloot3  = new Vloot("Vloot3");
            Schip   schip   = new Containerschip("Containerschip", 1.0, 1.0, 19.0, 1, 100m);
            Schip   schip2  = new RoRoschip("RoRoschip", 1.0, 1.0, 15.0, 1, 1, 100m);
            Schip   schip3  = new Olietanker("Olietanker", 1.0, 1.0, 10.0, 100m, 111.0, Olietanker.OlietankerLading.diesel);
            Schip   schip4  = new Gastanker("Gastanker", 1.0, 1.0, 1.0, 100m, 1.0, Gastanker.GastankerLading.amoniak);

            vloot.VoegSchipToe(schip);
            vloot.VoegSchipToe(schip4);
            vloot1.VoegSchipToe(schip2);
            vloot2.VoegSchipToe(schip3);
            rederij.VoegVlootToe(vloot);
            rederij.VoegVlootToe(vloot1);
            rederij.VoegVlootToe(vloot2);
            //SortedDictionary<double, List<Vloot>> tonnages = rederij.GeefTonnagePerVloot();
            double test = rederij.GeefTotaalVolumeTankers();

            Console.WriteLine(test);
            //Console.WriteLine(rederij.GeefTotaleCargowaarde());
            Schip sleepboot1 = new Sleepboot("Sleepboot", 1.0, 1.0, 19.0);
            Schip sleepboot2 = new Sleepboot("Sleepboot2", 1.0, 1.0, 19.0);
            Schip sleepboot3 = new Sleepboot("Sleepboot3", 1.0, 1.0, 19.0);

            vloot.VoegSchipToe(sleepboot1);
            vloot2.VoegSchipToe(sleepboot3);
            vloot1.VoegSchipToe(sleepboot2);
            List <Sleepboot> foo = rederij.GeefBeschikbareSleepboten();

            foreach (Sleepboot s in foo)
            {
                Console.WriteLine(s.Naam);
            }
            Traject traject1 = new Traject();

            traject1.VoegToe(new Haven("Testhaven"));
            traject1.VoegToe(new Haven("Testhaven2"));
            Schip schip5 = new Cruiseschip("Cruisetest", 1.0, 1.0, 1.0, 20, traject1);

            vloot.VoegSchipToe(schip5);
            Console.WriteLine($"Passagiers: {rederij.GeefTotaalAantalPassagiers()}");
        }
示例#22
0
        private static List <Traject> AddSingleTraject(Traject t, List <Traject> current)
        {
            if (t != null)
            {
                current = current.Where(x => x.UniqueId != t.UniqueId).ToList();

                current.Add(t);
            }

            current = current.OrderBy(x => x.From.Name).ToList();

            return(current);
        }
示例#23
0
        public void CalcNextTrajectory()
        {
            List <PointD> current = new List <PointD>(Traject);
            List <PointD> newList = new List <PointD>();

            Traject.Clear();
            foreach (PointD p in current)
            {
                Traject = Trajectory(p);
                newList.AddRange(Traject);
            }
            Traject = newList;
        }
示例#24
0
        public Traject AddTraject(Traject traject)
        {
            var tempList = traject.Cursussen;

            traject.Cursussen = new List <Cursus>();
            foreach (var cursus in tempList)
            {
                traject.Cursussen.Add(_context.Cursussen.Where(a => a.ID == cursus.ID).FirstOrDefault());
            }
            _context.Trajecten.Add(traject);
            traject.OrderNumber = _context.Trajecten.Count() + 1;
            return(traject);
        }
示例#25
0
 public IActionResult Edit(TrajectDetailViewModel vm)
 {
     try
     {
         Traject traject = converter.ViewModelToTraject(vm);
         repo.UpdateTraject(traject);
         return(RedirectToAction("Details", new { traject.Id }));
     }
     catch
     {
         return(View());
     }
 }
示例#26
0
        public void MaakCruiseschipMeerdereHavensInTraject()
        {
            Haven   haven   = new Haven("Gent");
            Haven   haven2  = new Haven("Antwerpen");
            Haven   haven3  = new Haven("Oostende");
            Traject traject = new Traject();

            traject.VoegToe(haven);
            traject.VoegToe(haven2);
            traject.VoegToe(haven3);
            schip = new Cruiseschip("Test", 1.0, 1.0, 1.0, 1, traject);
            Assert.AreEqual(3, ((Cruiseschip)schip).Traject.Count);
        }
示例#27
0
        public void TestTrajectToString()
        {
            Location from    = new Location("Brugge", "8200");
            Location to      = new Location("Brussel", "1000");
            Traject  traject = new Traject(from, to);

            Assert.Equal("Traject from Brugge [8200] to Brussel [1000]", traject.ToString());

            Location gent      = new Location("Gent", "9000");
            Location diksmuide = new Location("Diksmuide", "8600");
            Traject  second    = new Traject(gent, diksmuide);

            Assert.Equal("Traject from Gent [9000] to Diksmuide [8600]", second.ToString());
        }
示例#28
0
        public void MaakVeerboot4HavensInTraject()
        {
            Haven   haven   = new Haven("Gent");
            Haven   haven2  = new Haven("Antwerpen");
            Haven   haven3  = new Haven("Oostende");
            Haven   haven4  = new Haven("Zeebrugge");
            Traject traject = new Traject();

            traject.VoegToe(haven);
            traject.VoegToe(haven2);
            traject.VoegToe(haven3);
            traject.VoegToe(haven4);
            schip = new Veerboot("Test", 1.0, 1.0, 1.0, 1, traject);
        }
示例#29
0
        // GET: Trajects/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Traject traject = db.Trajects.Find(id);

            if (traject == null)
            {
                return(HttpNotFound());
            }
            return(View(traject));
        }
示例#30
0
        public Traject UpdateTraject(Traject traject)
        {
            var existingTraject     = _context.Trajecten.FirstOrDefault(a => a.ID == traject.ID);
            var existingOrderNumber = existingTraject.OrderNumber;

            if (existingTraject == null)
            {
                return(null);
            }
            var tempList = traject.Cursussen;

            existingTraject.Cursussen = new List <Cursus>();
            foreach (var cursus in tempList)
            {
                existingTraject.Cursussen.Add(_context.Cursussen.Where(a => a.ID == cursus.ID).FirstOrDefault());
            }
            existingTraject.Beschrijving      = traject.Beschrijving;
            existingTraject.Categorie         = traject.Categorie;
            existingTraject.FotoURLCard       = traject.FotoURLCard;
            existingTraject.LangeBeschrijving = traject.LangeBeschrijving;
            existingTraject.Prijs             = traject.Prijs;
            existingTraject.Titel             = traject.Titel;
            existingTraject.Type = traject.Type;
            if (existingTraject.OrderNumber != traject.OrderNumber)
            {
                IQueryable <Product> query = _context.Trajecten;
                foreach (Traject _traject in query)
                {
                    if (_traject == existingTraject)
                    {
                        existingTraject.OrderNumber = traject.OrderNumber;
                    }
                    else if (traject.OrderNumber > existingOrderNumber)
                    {
                        if (_traject.OrderNumber <= traject.OrderNumber && _traject.OrderNumber > existingOrderNumber)
                        {
                            _traject.OrderNumber--;
                        }
                    }
                    else if (traject.OrderNumber < existingOrderNumber)
                    {
                        if (_traject.OrderNumber >= traject.OrderNumber && _traject.OrderNumber < existingOrderNumber)
                        {
                            _traject.OrderNumber++;
                        }
                    }
                }
            }
            return(traject);
        }