Esempio n. 1
0
        public bool setMuseum(DataSetMuseum dataSet)
        {
            bool       result     = false;
            Connection connection = new Connection();

            connection.Open();
            try
            {
                Transaction transaction = connection.BeginTransaction();
                try
                {
                    museum = new Museum();
                    museum.Save(dataSet, connection, transaction);
                    transaction.Commit();
                    result = true;
                }
                catch (Exception ex)
                {
                    ShowError(ex.ToString());
                    transaction.Rollback();
                    result = false;
                }
            }
            finally
            {
                connection.Close();
            }
            return(result);
        }
Esempio n. 2
0
 public Museum GetMuseumById(int id)
 {
     try {
         DbCommand command = connection.CreateCommand();
         var       _id     = AppData.GetParameter("Id", id, DbType.Int32, "Id", command);
         command.Parameters.Add(_id);
         command.CommandText = "SELECT * FROM Museums WHERE Id = @Id";
         DbDataReader reader = command.ExecuteReader();
         Museum       museum = null;
         if (reader.Read())
         {
             museum = new Museum {
                 Id          = Convert.ToInt32(reader["Id"]),
                 Title       = Convert.ToString(reader["Title"]),
                 Adress      = Convert.ToString(reader["Address"]),
                 CityId      = Convert.ToInt32(reader["CityId"]),
                 Description = Convert.ToString(reader["Description"]),
                 Latitude    = Convert.ToSingle(reader["Latitude"]),
                 Login       = Convert.ToString(reader["Login"]),
                 Password    = Convert.ToString(reader["Password"]),
                 Longitude   = Convert.ToSingle(reader["Longitude"]),
                 Phone       = Convert.ToString(reader["Phone"]),
                 PictureSrc  = Convert.ToString(reader["PictureSrc"]),
                 Radius      = Convert.ToSingle(reader["Radius"]),
                 WebSite     = Convert.ToString(reader["WebSite"])
             };
         }
         reader.Close();
         return(museum);
     }
     catch (DbException) {
         return(null);
     }
 }
Esempio n. 3
0
        public DataSetMuseum getMuseum()
        {
            DataSetMuseum result     = new DataSetMuseum();
            Connection    connection = new Connection();

            connection.Open();
            try
            {
                Transaction transaction = connection.BeginTransaction();
                try
                {
                    museum = new Museum();
                    museum.Read(result, connection, transaction);
                    transaction.Commit();
                }
                catch (Exception ex)
                {
                    ShowError(ex.ToString());
                    transaction.Rollback();
                    result = null;
                }
            }
            finally
            {
                connection.Close();
            }
            return(result);
        }
Esempio n. 4
0
 public bool Update(Museum museum)
 {
     try {
         DbCommand command    = connection.CreateCommand();
         var       _id        = AppData.GetParameter("id", museum.Id, DbType.Int32, "Id", command);
         var       _name      = AppData.GetParameter("title", museum.Title, DbType.String, "Title", command);
         var       _address   = AppData.GetParameter("address", museum.Adress, DbType.String, "Adress", command);
         var       _desc      = AppData.GetParameter("description", museum.Description, DbType.String, "Description", command);
         var       _cityName  = AppData.GetParameter("cityName", museum.CityName, DbType.String, "CityName", command);
         var       _phone     = AppData.GetParameter("phone", museum.Phone, DbType.String, "Phone", command);
         var       _website   = AppData.GetParameter("webSite", museum.WebSite, DbType.String, "WebSite", command);
         var       _latitude  = AppData.GetParameter("latitude", museum.Point.Latitude, DbType.Single, "Latitude", command);
         var       _longitude = AppData.GetParameter("longitude", museum.Point.Longitude, DbType.Single, "Longitude", command);
         var       _radius    = AppData.GetParameter("radius", museum.Radius, DbType.Single, "Radius", command);
         command.Parameters.Add(_name);
         command.Parameters.Add(_address);
         command.Parameters.Add(_desc);
         command.Parameters.Add(_phone);
         command.Parameters.Add(_website);
         command.Parameters.Add(_cityName);
         command.Parameters.Add(_id);
         command.Parameters.Add(_latitude);
         command.Parameters.Add(_longitude);
         command.Parameters.Add(_radius);
         command.CommandType = CommandType.StoredProcedure;
         command.CommandText = "UpdateMuseum";
         command.ExecuteNonQuery();
         return(true);
     }
     catch (DbException) {
         return(false);
     }
 }
Esempio n. 5
0
        public Museum GetMuseumByLogin(string login)
        {
            DbCommand command = connection.CreateCommand();
            var       _login  = AppData.GetParameter("Login", login, DbType.String, "Login", command);

            command.Parameters.Add(_login);
            command.CommandText = "SELECT * FROM Museums WHERE Login = @Login";
            var    reader = command.ExecuteReader();
            Museum museum = new Museum();

            if (reader.Read())
            {
                museum.Id          = Convert.ToInt32(reader["Id"]);
                museum.Title       = Convert.ToString(reader["Title"]);
                museum.Adress      = Convert.ToString(reader["Address"]);
                museum.CityId      = Convert.ToInt32(reader["CityId"]);
                museum.Description = Convert.ToString(reader["Description"]);
                museum.Latitude    = Convert.ToSingle(reader["Latitude"]);
                museum.Login       = Convert.ToString(reader["Login"]);
                museum.Password    = Convert.ToString(reader["Password"]);
                museum.Longitude   = Convert.ToSingle(reader["Longitude"]);
                museum.Phone       = Convert.ToString(reader["Phone"]);
                museum.PictureSrc  = Convert.ToString(reader["PictureSrc"]);
                museum.Radius      = Convert.ToSingle(reader["Radius"]);
                museum.WebSite     = Convert.ToString(reader["WebSite"]);
                return(museum);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 6
0
 public IList <Museum> GetMuseums()
 {
     try {
         DbCommand command = connection.CreateCommand();
         command.CommandText = "SELECT * FROM Museums";
         DbDataReader   reader  = command.ExecuteReader();
         IList <Museum> museums = new List <Museum>();
         while (reader.Read())
         {
             Museum museum = new Museum {
                 Id          = Convert.ToInt32(reader["Id"]),
                 Title       = Convert.ToString(reader["Title"]),
                 Adress      = Convert.ToString(reader["Adress"]),
                 CityId      = Convert.ToInt32(reader["CityId"]),
                 Description = Convert.ToString(reader["Description"]),
                 Latitude    = Convert.ToSingle(reader["Latitude"]),
                 Login       = Convert.ToString(reader["Login"]),
                 Password    = Convert.ToString(reader["Password"]),
                 Longitude   = Convert.ToSingle(reader["Longitude"]),
                 Phone       = Convert.ToString(reader["Phone"]),
                 PictureSrc  = Convert.ToString(reader["PictureSrc"]),
                 Radius      = Convert.ToSingle(reader["Radius"]),
                 WebSite     = Convert.ToString(reader["WebSite"])
             };
             museums.Add(museum);
         }
         reader.Close();
         return(museums);
     }
     catch (DbException) {
         return(null);
     }
 }
 public HttpResponseMessage Post([FromBody] Museum museum)
 {
     try
     {
         using (var db = new dbTourismEventAppEntities())
         {
             var entity = db.Museum.FirstOrDefault(cat => cat.MuseumID == museum.MuseumID);
             if (entity == null)
             {
                 db.Museum.Add(museum);
                 db.SaveChanges();
                 var response = Request.CreateResponse(HttpStatusCode.Created, museum);
                 response.Headers.Location = new Uri(Url.Link("GetMuseumByID", new { id = museum.MuseumID }));
                 return(response);
             }
             else
             {
                 return(Request.CreateErrorResponse(HttpStatusCode.Conflict, "The Museum name is already exist"));
             }
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message));
     }
 }
Esempio n. 8
0
        public ActionResult AddToUserList(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Museum museum = db.museums.Find(id);

            if (museum == null)
            {
                return(HttpNotFound());
            }

            UserManager <ApplicationUser> UserManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(db));
            ApplicationUser currentUser = UserManager.FindById(User.Identity.GetUserId());

            UserList newlist = new UserList();

            newlist.Title          = museum.Title;
            newlist.Description    = museum.Description;
            newlist.Link           = museum.Link;
            newlist.Location       = museum.Location;
            newlist.ListCategoryId = 1;  //have to use # be sure to confirm the numbers in List Categories.
            newlist.UserName       = currentUser;
            db.UserLists.Add(newlist);
            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
Esempio n. 9
0
        public EmbedBuilder maakGroteEmbedMuseum(string naam)
        {
            EmbedBuilder em = new EmbedBuilder();
            Museum       m  = repo.getByName(naam);

            em.Title = m.Naam;
            em.WithThumbnailUrl(m.AfbeeldingUrl);
            em.Description = m.Description;

            em.WithUrl(m.Url);

            Accesability a = m.Accesability;

            em.WithColor(Color.DarkPurple);

            em.AddField("Aantal liften", a.liften, true);
            em.AddField("Aantal aangepaste toiletten", a.aangepasteToilleten, true);

            em.AddField("Icons", "♿ 🅿️", false);

            EmbedFooterBuilder efb = new EmbedFooterBuilder();

            efb.WithText("Mogelijk gemaakt door Linked Open Data Gent");

            em.WithFooter(efb);

            return(em);
        }
Esempio n. 10
0
 public Quest CreateQuest(Quest quest, Prize prize, Museum museum)
 {
     try {
         DbCommand command           = connection.CreateCommand();
         var       _questTitle       = AppData.GetParameter("QuestTitle", quest.Title, System.Data.DbType.String, "Title", command);
         var       _questDescription = AppData.GetParameter("QuestDescription", quest.Description, System.Data.DbType.String, "Description", command);
         var       _questDifficult   = AppData.GetParameter("QuestDifficult", quest.Difficult, System.Data.DbType.Int32, "Difficult", command);
         var       _questPictureSrc  = AppData.GetParameter("QuestPictureSrc", quest.PictureSrc, System.Data.DbType.String, "PictureSrc", command);
         var       _questPoint       = AppData.GetParameter("QuestPoints", quest.Point, System.Data.DbType.Int32, "Points", command);
         var       _MuseumId         = AppData.GetParameter("MuseumId", museum.Id, System.Data.DbType.Int32, "MuseumId", command);
         var       _PrizeId          = AppData.GetParameter("PrizeId", prize.Id, System.Data.DbType.Int32, "PrizeId", command);
         command.Parameters.Add(_questTitle);
         command.Parameters.Add(_MuseumId);
         command.Parameters.Add(_PrizeId);
         command.Parameters.Add(_questDescription);
         command.Parameters.Add(_questDifficult);
         command.Parameters.Add(_questPictureSrc);
         command.Parameters.Add(_questPoint);
         command.CommandText = "INSERT INTO Quests (Title, Description, Difficult, PictureSrc, Points, MuseumId, PrizeId) " +
                               "VALUES (@QuestTitle, @QuestDescription, @QuestDifficult, @QuestPictureSrc, @QuestPoints, @MuseumId, @PrizeId)";
         command.ExecuteNonQuery();
         quest.Id = AppData.GetLastId("Quests", this.connection);
         return(quest);
     }
     catch (DbException) {
         return(null);
     }
 }
Esempio n. 11
0
        private Museum getMuseum(StreamReader sr)
        {
            var museumName   = "\t\tNAME = ";
            var openingHours = "\t\tOPENING_HOURS = ";
            var closingHours = "\t\tCLOSING_TIME = ";

            var museum = new Museum();

            var s = sr.ReadLine();

            while (!string.Equals(s, "\t}"))
            {
                if (s.Contains(museumName))
                {
                    museum.Name = s.Substring(museumName.Length);
                }

                if (s.Contains(openingHours))
                {
                    museum.OpeningHours = s.Substring(openingHours.Length);
                }

                if (s.Contains(closingHours))
                {
                    museum.OpeningHours = s.Substring(closingHours.Length);
                }

                s = sr.ReadLine();
            }

            return(museum);
        }
Esempio n. 12
0
        public MuseumEditViewModel Update(MuseumEditViewModel Museum)
        {
            Museum _Museum = MuseumRepo.Update(Museum.toModel());

            unitOfWork.commit();
            return(_Museum.toEditViewModel());
        }
Esempio n. 13
0
        public void UpdateMuseum(Museum museum)
        {
            Museum dbMuseum = ctx.MUSEA.SingleOrDefault(m => m.MuseumID == museum.MuseumID);

            if (dbMuseum != null)
            {
                dbMuseum.Naam         = museum.Naam;
                dbMuseum.LocatieID    = museum.LocatieID;
                dbMuseum.Omschrijving = museum.Omschrijving;
                dbMuseum.Maandag      = museum.Maandag;
                dbMuseum.Dinsdag      = museum.Dinsdag;
                dbMuseum.Woensdag     = museum.Woensdag;
                dbMuseum.Donderdag    = museum.Donderdag;
                dbMuseum.Vrijdag      = museum.Vrijdag;
                dbMuseum.Zaterdag     = museum.Vrijdag;
                dbMuseum.Zondag       = museum.Zondag;
                dbMuseum.Kids         = museum.Kids;
                dbMuseum.Adults       = museum.Adults;
                dbMuseum.Telefoon     = museum.Telefoon;
                dbMuseum.Website      = museum.Website;

                Afbeelding dbAfbeelding = ctx.AFBEELDINGEN.SingleOrDefault(a => a.MuseumID == museum.MuseumID && a.Type == "museumbanner");
                if (dbAfbeelding != null)
                {
                    dbAfbeelding.Link = museum.MuseumAfbeelding.Link;
                }
                Afbeelding dbOverview = ctx.AFBEELDINGEN.SingleOrDefault(a => a.MuseumID == museum.MuseumID && a.Type == "museumoverview");
                if (dbOverview != null)
                {
                    dbOverview.Link = museum.OverviewAfbeelding.Link;
                }
                Locatie dbLocatie = ctx.LOCATIES.SingleOrDefault(l => l.LocatieID == museum.LocatieID);
                ctx.SaveChanges();
            }
        }
 public MuseumViewModel(
     Museum model,
     IScreen hostScreen)
 {
     this.model      = model;
     this.hostScreen = hostScreen;
 }
Esempio n. 15
0
        public static bool LoadMuseum(Museum museum)
        {
            using var ofd = new OpenFileDialog
                  {
                      Filter   = "New Horizons Museum (*.nhm)|*.nhm|All files (*.*)|*.*",
                      FileName = "museum.nhm",
                  };
            if (ofd.ShowDialog() != DialogResult.OK)
            {
                return(false);
            }

            var       file         = ofd.FileName;
            var       fi           = new FileInfo(file);
            const int expectLength = Museum.SIZE;

            if (fi.Length != expectLength)
            {
                WinFormsUtil.Error(MessageStrings.MsgCanceling, string.Format(MessageStrings.MsgDataSizeMismatchImport, fi.Length, expectLength));
                return(false);
            }

            var data = File.ReadAllBytes(file);

            data.CopyTo(museum.Data);
            return(true);
        }
Esempio n. 16
0
        public async Task <ServiceResult> RegisterMuseumAsync(MuseumRegistrationModel model)
        {
            var museum = new Museum
            {
                Name = model.MuseumName,
            };

            await museumRepository.CreateAsync(museum);

            var user = new ApplicationUser
            {
                UserName = model.Username,
                Email    = model.Email,
                Museum   = museum,
            };

            var identityResult = await userManager.CreateAsync(user, model.Password);

            if (identityResult.Succeeded)
            {
                await emailConfirmationService.SendConfirmationEmailAsync(user, "");

                return(ServiceResult <ApplicationUser> .Success(user));
            }

            var serviceErrors = identityResult.Errors.Select(error => new ServiceError {
                Code = error.Code, Description = error.Description
            });

            return(ServiceResult.Failed(serviceErrors.ToArray()));
        }
Esempio n. 17
0
        private void müzeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Museum muze = new Museum();

            this.Hide();
            muze.Show();
        }
Esempio n. 18
0
        /// <summary>
        /// Find the closest museum near the user
        /// </summary>
        /// @author Gabriele Ursini
        private async Task findClosestMuseumAsync(positionWrapper position)
        {
            if (latestPosition == null)
            {
                latestPosition = position;
            }
            else
            {
                if (position.getDistance(latestPosition.position) >= DISTANCE_BEFORE_RECOMPUTATION)
                {
                    latestPosition = position;
                }
                else
                {
                    return;
                }
            }

            var museumRequest = await PersistanceStorage.PersistanceStorage.Instance.getClosestMuseumAsync(new PersistanceStorage.PersistanceStorage.requestWrapper()
            {
                lat = latestPosition.position.Latitude,
                lon = latestPosition.position.Longitude,
            });

            current = museumRequest.getMuseum();
            if (current != null)
            {
                System.System.Instance.vibrate();
                pageStack.Children.Add(museum_view = new view_Museum(this.current));
            }
        }
Esempio n. 19
0
 private async Task CreateSampleUsers(Museum museum)
 {
     await CreateSampleUser("Madam", "Director", museum, Roles.DIRECTOR);
     await CreateSampleUser("Mister", "Administrator", museum, Roles.ADMINISTRATOR);
     await CreateSampleUser("Guy", "Contributor", museum, Roles.CONTRIBUTOR);
     await CreateSampleUser("Justa", "Member", museum);
 }
Esempio n. 20
0
        private async Task CreateSampleUser(
            string firstName,
            string lastName,
            Museum museum,
            string role = null)
        {
            var user = new ApplicationUser
            {
                UserName       = $"{firstName} {lastName}",
                Email          = $"{firstName}.{lastName}@museum.com",
                EmailConfirmed = true,
                Museum         = museum,
            };

            var userResult = await userManager.CreateAsync(user, "password");

            if (!userResult.Succeeded)
            {
                throw new InvalidOperationException($"Failed to build user {firstName} {lastName}.");
            }

            if (role != null)
            {
                var roleResult = await userManager.AddToRoleAsync(user, role);

                if (!roleResult.Succeeded)
                {
                    throw new InvalidOperationException($"Failed to add user {firstName} {lastName} to role {role}.");
                }
            }
        }
Esempio n. 21
0
        private void pictureBox3_Click(object sender, EventArgs e)
        {
            Museum yeni = new Museum();

            yeni.Show();
            this.Hide();
        }
Esempio n. 22
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Country,Director")] Museum museum)
        {
            if (id != museum.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(museum);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MuseumExists(museum.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(museum));
        }
Esempio n. 23
0
        public void DeleteMuseum(int museumid)
        {
            Museum dbMuseum = ctx.MUSEA.SingleOrDefault(m => m.MuseumID == museumid);
            //Locatie dbLocatie = ctx.LOCATIES.SingleOrDefault(m => m.LocatieID == dbMuseum.LocatieID);
            //if (dbLocatie != null) //On delete Cascade betekent dat dit niet meer hoeft
            //    ctx.Entry(dbLocatie).State = EntityState.Deleted;

            IEnumerable <Afbeelding> dbAfbeeldingen = (from a in ctx.AFBEELDINGEN
                                                       where a.MuseumID == museumid
                                                       select a).ToList();

            if (dbAfbeeldingen != null && dbAfbeeldingen.Any())
            {
                foreach (Afbeelding dbAfbeelding in dbAfbeeldingen)
                {
                    ctx.Entry(dbAfbeelding).State = EntityState.Deleted;
                }
            }


            if (dbMuseum != null)
            {
                ctx.Entry(dbMuseum).State = EntityState.Deleted;
            }


            ctx.SaveChanges();
        }
Esempio n. 24
0
        /// <summary>
        /// Create a new visit in the persistance storage
        /// </summary>
        /// @Author Gabriele Ursini
        /// <returns>
        /// A wrapper containing the response
        /// </returns>
        public async Task <visitWrapper> postVisitBeginAsync(Museum museum)
        {
            var url     = URLREST + "/postVisitStart/" + museum.ID;
            var request = await requestData(url);

            if (request.IsSuccessStatusCode)
            {
                try
                {
                    var response = await request.Content.ReadAsStringAsync();

                    return(JsonConvert.DeserializeObject <visitWrapper>(response));
                }
                catch (Exception e)
                {
                    return(new visitWrapper()
                    {
                        message = e.Message,
                        code = "500"
                    });
                }
            }

            return(new visitWrapper()
            {
                message = request.ReasonPhrase,
                code = "500"
            });
        }
Esempio n. 25
0
        public async Task <IActionResult> Edit(int id, [Bind("IdMuseum,MuseumName,CityId")] Museum museum)
        {
            if (id != museum.IdMuseum)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(museum);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MuseumExists(museum.IdMuseum))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CityId"] = new SelectList(_context.City, "IdCity", "CityName", museum.CityId);
            return(View(museum));
        }
Esempio n. 26
0
        public ActionResult DeleteConfirmed(int id)
        {
            Museum museum = db.Museums.Find(id);

            db.Museums.Remove(museum);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 27
0
        public async Task <Exhibit> NewExhibit(Exhibit toAdd, Guid museumId)
        {
            Museum museum = await _museumRepository.Get(museumId);

            Exhibit createdExhibit = await museum.AddExhibit(toAdd);

            return(createdExhibit);
        }
Esempio n. 28
0
    // Start is called before the first frame update
    void Start()
    {
        Museum t = new Museum(0, "test", new List <string>());

        Debug.Log(t.Get());
        Museum m = MuseumController.Load(MuseumController.Default);

        Debug.Log(m.Get());
    }
Esempio n. 29
0
        public IActionResult GetMuseum(int museumid)
        {
            Museum displayMuseum = dbContext.Museums
                                   .Include(mus => mus.AddedBy)
                                   .Include(mus => mus.FossilsOwned)
                                   .FirstOrDefault(mus => mus.MuseumID == museumid);

            return(View("MuseumDisplay", displayMuseum));
        }
Esempio n. 30
0
        public void Setup(Museum item)
        {
            SetStyles();

            LabelName.Text     = item.Name;
            LabelAddress1.Text = item.Address1;
            LabelAddress2.Text = item.Address2;
            LabelAddress3.Text = item.Address3;
        }