Exemple #1
0
        public override void OnLoad(Harmony harmony)
        {
            PUtil.InitLibrary(true);

            POptions popt = new POptions();

            popt.RegisterOptions(this, typeof(ModSettings));

            System.DateTime date = System.DateTime.Now;
            if (ModSettings.Instance.UseOverrideDate)
            {
                try
                {
                    date = new System.DateTime(date.Year, ModSettings.Instance.OverrideMonth, ModSettings.Instance.OverrideDayOfMonth);
                }
                catch
                {
                    Debug.Log("FestiveDecor: Override date in settings file is invalid. Using current date.");
                    date = System.DateTime.Now;
                }
            }

            Registry = RomenHRegistry.Init();

            Festival festival = FestivalManager.GetFestivalForDate(date);

            FestivalManager.SetFestival(festival);

            ModAssets.LoadAssets();

            base.OnLoad(harmony);
        }
Exemple #2
0
        private void AnnulerOnClick(object sender, RoutedEventArgs e)
        {
            Festival festival = festivalGrid.SelectedItem as Festival;

            _ = API.API.Instance.SupprFestivalAsync(festival.IdF);
            Reload();
        }
        public void UpdateFestival(int Id, Festival festival)
        {
            //eerst even checken of he formulier goed is ingevuld
            if (!ModelState.IsValid)
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }

            var festivalInDb = _context.Festivals.SingleOrDefault(f => f.Id == Id);

            if (festivalInDb == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            //(dit kan sneller met de "automapper" tool)
            festivalInDb.Datum        = festival.Datum;
            festivalInDb.Naam         = festival.Naam;
            festivalInDb.NaamDesc     = festival.NaamDesc;
            festivalInDb.Website      = festival.Website;
            festivalInDb.TicketsURL   = festival.TicketsURL;
            festivalInDb.PrijsEarly   = festival.PrijsEarly;
            festivalInDb.PrijsLate    = festival.PrijsLate;
            festivalInDb.KostService  = festival.KostService;
            festivalInDb.KostBetaling = festival.KostBetaling;
            festivalInDb.YoutubeCode  = festival.YoutubeCode;
            festivalInDb.Beschrijving = festival.Beschrijving;
            festivalInDb.Muziek       = festival.Muziek;
            festivalInDb.StartVVK     = festival.StartVVK;
            festivalInDb.Uitverkocht  = festival.Uitverkocht;

            _context.SaveChanges();
        }
 public OrganisateursFestival(Festival festival)
 {
     InitializeComponent();
     this.festival    = festival;
     NomFestival.Text = festival.Nom;
     Reload();
 }
Exemple #5
0
        public void PostFestivalToAPI(FestivalViewModel FestivalViewModel)
        {
            Festival Fesival = new Festival()
            {
                Nom        = FestivalViewModel.FestivalNom,
                Lieu       = FestivalViewModel.FestivalLieu,
                CodePostal = FestivalViewModel.FestivalCodePostal,
                DateDebut  = FestivalViewModel.FestivalDateDebut,
                DateFin    = FestivalViewModel.FestivalDateFin,
                Scenes     = FestivalViewModel.FestivalScenes
            };
            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri("http://localhost:56058/api/festivals");
            client.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/json"));

            Task <HttpResponseMessage> postTask = client.PostAsJsonAsync <Festival>("festivals", Festival);

            postTask.Wait();

            HttpResponseMessage result = postTask.Result;

            //if (result.IsSuccessStatusCode)
            //{
            //    CreationScene creationscene = new CreationScene();
            //    creationscene.Show();
            //}
        }
        public async Task <IActionResult> UpdateFestival(Festival festival)
        {
            foreach (var ucesnik in festival.ucesnici)
            {
                _context.Entry(ucesnik).State = EntityState.Unchanged;
            }
            _context.Entry(festival.pozoriste).State = EntityState.Unchanged;
            _context.Entry(festival.forma).State     = EntityState.Unchanged;
            _context.Entry(festival).State           = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FestivalExists(festival.id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok());
        }
Exemple #7
0
        private Festival GetFestival(string id)
        {
            List <Festival> festivals = new List <Festival>();

            using (MySqlConnection conn = new MySqlConnection(connectionString))
            {
                conn.Open();
                MySqlCommand cmd = new MySqlCommand("select * from festivals where id = " + id + ";", conn);
                using (var reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        Festival festival = new Festival
                        {
                            Id           = Convert.ToInt32(reader["id"]),
                            Naam         = reader["Naam"].ToString(),
                            Prijs        = Decimal.Parse(reader["prijs"].ToString()),
                            Plaats       = reader["Plaats"].ToString(),
                            Beschrijving = reader["Beschrijving"].ToString(),
                            ImgLogo      = reader["img-logo"].ToString(),
                            ImgDatabase  = reader["Img-database"].ToString(),
                            Date         = DateTime.Parse(reader["datumtijd"].ToString())
                        };
                        festivals.Add(festival);
                    }
                }
            }
            return(festivals[0]);
        }
Exemple #8
0
 public void OnPost()
 {
     if (!Request.HasFormContentType)
     {
         return;
     }
     try
     {
         Festival = Festival.Read(int.Parse(Request.Query["ID"]));
     }
     catch
     {
         Festival = new Festival();
     }
     Festival.EventName    = Request.Form["EventName"];
     Festival.StartDate    = DateTime.Parse(Request.Form["StartDate"]);
     Festival.EndDate      = DateTime.Parse(Request.Form["EndDate"]);
     Festival.Location     = Request.Form["Location"];
     Festival.EntryPrice   = decimal.Parse(Request.Form["EntryPrice"]);
     Festival.YoutubeVideo = Request.Form["YoutubeVideo"];
     Festival.Image        = Request.Form["Image"];
     Festival.Draft        = string.IsNullOrEmpty(Request.Form["Draft"]);
     Festival.OwnerID      = HttpContext.Session.GetInt32("UserID") ?? 0;
     Festival.Write();
     Response.Redirect("./festivals", true);
 }
Exemple #9
0
        public async Task When_Update_Festival_In_Repository_Should_Return_It_Back()
        {
            //Arrange
            const int id       = 100;
            var       festival = new Festival
            {
                Name        = "Test",
                Description = "TestDescription",
                Id          = id
            };
            var updatedFestival = new Festival
            {
                Name        = "Result",
                Description = "ResultDescription",
                Id          = id
            };
            await _repository.AddFestival(festival);

            //Act
            await _service.UpdateFestival(updatedFestival);

            var shouldBeUpdated = await _repository.GetFestivalById(id);

            //Assert
            Assert.AreEqual(shouldBeUpdated.Name, updatedFestival.Name);
        }
        public static Festival GetFestival()
        {
            Festival f = new Festival();

            string sql = "SELECT * FROM festival WHERE FestivalID = 1";

            DbDataReader reader = Database.GetData(sql);

            if (reader.Read())
            {
                f.ID = 1;
                f.Naam = reader["Naam"].ToString();
                f.Startdatum = Convert.ToDateTime(reader["Startdatum"]);
                f.Einddatum = Convert.ToDateTime(reader["Einddatum"]);
                f.Straat_Nr = reader["Straat_Nr"].ToString();
                f.Postcode = reader["Postcode"].ToString();
                f.Gemeente = reader["Gemeente"].ToString();
                f.Image = reader["Image"].ToString();
                f.Organisatie = OrganisatieRepository.GetOrganisatieFromID(Convert.ToInt32(reader["OrganisatieID"]));
                f.Beschrijving = reader["Beschrijving"].ToString();

                reader.Close();

                return f;
            }

            reader.Close();
            return null;
        }
Exemple #11
0
        public IActionResult AnnulerConfirmed()
        {
            if (HttpContext.Session.GetInt32("ido") == null)
            {
                return(null);
            }
            Organisateur organisateur = API.Instance.GetOrganisateurAsync((int)HttpContext.Session.GetInt32("ido")).Result;
            Festival     festival     = API.Instance.GetFestivalAsync(organisateur.FestivalId).Result;

            if (festival == null)
            {
                return(null);
            }
            festival.IsCanceled = true;
            var uri = API.Instance.ModifFestivalAsync(festival);

            sendMail = new FestivalAPI.Data.SendMail();
            foreach (var festivalier in festival.Festivaliers)
            {
                string mailSubject = "Festival Annulé:" + festival.Nom;
                string content     = "Le festival " + festival.Nom + " a été annulé. Nous vos prions de contacter le +33 00 00 00 00 00 pour toute demande remboursement <br> <br> :< br >Cordialement <br> <br> A bientôt sur Festi'Normandie.";

                sendMail.ActionSendMail(festivalier.Login, mailSubject, content);
            }

            return(Redirect("Index"));
        }
Exemple #12
0
        public void CreateFestival_FestivalForCreation_CreatesANewFestival()
        {
            //Arrange
            Address addressEntity = new Address
            {
                Street     = "Test Address",
                Number     = "1",
                PostalCode = "28303",
                State      = "Bremen",
                Country    = "Germany"
            };

            Festival festivalEntity = new Festival
            {
                Title       = "Hellfest",
                Description = "",
                StartDate   = DateTimeMock.Object.Now.AddDays(5),
                EndDate     = DateTimeMock.Object.Now.AddDays(8),
                Address     = addressEntity
            };

            //Act
            MedievalFestivalsRepositoryBase.AddFestival(festivalEntity);
            ContextBase.SaveChanges();

            //Assert
            Assert.True(festivalEntity != null);
            Assert.True(festivalEntity.AddressId != 0);
            Assert.Equal(festivalEntity, ContextBase.Festivals.FirstOrDefault(f => f.Title == "Hellfest"));
        }
Exemple #13
0
 public ActionResult Edit([Bind(Include = "FestivalId,Year,BeginningDate,EndDate")] FestivalDTO updateData)
 {
     if (ModelState.IsValid)
     {
         var updateDataFull = new Festival()
         {
             FestivalId    = updateData.FestivalId,
             Year          = updateData.Year,
             BeginningDate = updateData.BeginningDate,
             EndDate       = updateData.EndDate,
             EditedBy      = 1,//GetUserId(),
             EditDate      = DateTime.Now
         };
         using (var context = new AF_Context())
         {
             Festival fes = context.Festivals.Find(updateData.FestivalId);
             context.Entry(fes).CurrentValues.SetValues(updateDataFull);
             context.SaveChanges();
             return(RedirectToAction("Index"));
         }
     }
     //ViewBag.EditedBy = new SelectList(db.Users, "UserId", "Login", play.EditedBy);
     //ViewBag.FestivalId = new SelectList(db.Festivals, "FestivalId", "FestivalId", play.FestivalId);
     return(View(updateData));
 }
Exemple #14
0
        public IActionResult AjoutFestivalier(Festivalier festivalier)
        {
            DateTime today    = DateTime.Now;
            var      days     = (today.Date - festivalier.Birthday.Date).TotalDays;
            Festival festival = API.Instance.GetFestivalAsync(festivalier.FestivalId).Result;

            festivalier.IsPublished = false;
            festival.NbPlacesDispo  = festival.NbPlacesDispo - (festivalier.Nb_ParticipantsDT + festivalier.Nb_ParticipantsPT);

            if (days < 18 * 365)
            {
                ModelState.AddModelError("error", "Vous n'êtes pas majeur!!!");
                return(AjoutFestivalier(festivalier.FestivalId));
            }
            if (festival.NbPlacesDispo < (festivalier.Nb_ParticipantsDT + festivalier.Nb_ParticipantsPT))
            {
                ModelState.AddModelError("error", "Pas assez de  places disponibles ? veuillez en prendre moins!");
                return(AjoutFestivalier(festivalier.FestivalId));
            }
            festivalier.Somme = (festivalier.Nb_ParticipantsPT * festival.Montant + festivalier.Nb_ParticipantsDT * festival.Montant * 0.5) * festivalier.NbJours;

            festivalier.Date_Inscription = DateTime.Now;
            int drapeau = 0;

            IEnumerable <Festivalier> Festivaliers = API.Instance.GetFestivaliersAsync().Result;

            if (festival.NbPlacesDispo > 0)
            {
                foreach (var item in Festivaliers)
                {
                    if (item.Nom == festivalier.Nom)
                    {
                        drapeau++;
                    }
                }

                if (ModelState.IsValid && drapeau == 0)
                {
                    sendMail = new FestivalAPI.Data.SendMail();
                    string mailSubject = "Inscription au festival " + festival.Nom;
                    string content     = "Votre inscripion au festival " + festival.Nom + " a bien été prise en compte vous allez bientôt recevoir un mail de validation de paiement. <br> pour l'instant vous pouvez d'ores et déjà vous connecter sur notre site internet <br> <br> Cordialement <br> <br> A bientôt sur Festi'Normandie.";

                    sendMail.ActionSendMail(festivalier.Login, mailSubject, content);

                    var URI  = API.Instance.AjoutFestivalierAsync(festivalier);
                    var URI2 = API.Instance.ModifFestivalAsync(festival);
                    return(RedirectToAction(nameof(Index)));
                }
                else if (drapeau != 0)
                {
                    return(RedirectToAction(nameof(Index)));
                }
            }
            else
            {
                return(RedirectToAction(nameof(Index)));
            }

            return(View(festivalier));
        }
Exemple #15
0
 public ActionResult Edit(int?id)
 {
     if (id == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     using (var context = new AF_Context())
     {
         Festival fes = context.Festivals.Find(id);
         if (fes == null)
         {
             return(HttpNotFound());
         }
         var newFestivalDto = new FestivalDTO()
         {
             FestivalId    = fes.FestivalId,
             Year          = fes.Year,
             BeginningDate = fes.BeginningDate,
             EndDate       = fes.EndDate,
         };
         //ViewBag.EditedBy = new SelectList(db.Users, "UserId", "Login", play.EditedBy);
         //ViewBag.FestivalId = new SelectList(db.Festivals, "FestivalId", "FestivalId", play.FestivalId);
         return(View(newFestivalDto));
     }
 }
Exemple #16
0
        // functie die alle festivals ophaalt voor overzicht
        private List <Festival> GetFestivals()
        {
            List <Festival> festivals = new List <Festival>();

            using (MySqlConnection conn = new MySqlConnection(connectionString))
            {
                conn.Open();
                MySqlCommand cmd = new MySqlCommand($"select * from festival", conn);

                using (var reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        Festival f = new Festival
                        {
                            id       = Convert.ToInt32(reader["id"]),
                            naam     = reader["naam"].ToString(),
                            plaats   = reader["plaats"].ToString(),
                            image    = reader["image"].ToString(),
                            start_dt = DateTime.Parse(reader["start_dt"].ToString()),
                            eind_dt  = DateTime.Parse(reader["eind_dt"].ToString())
                        };
                        festivals.Add(f);
                    }
                }
            }

            return(festivals);
        }
Exemple #17
0
        public IEnumerable <object> Get(string request)
        {
            try
            {
                if (request == null)
                {
                    throw new HttpResponseException(Request.CreateResponse(System.Net.HttpStatusCode.NotFound));
                }
                Festival.SingleFestival = Festival.GetFestival();

                Festival.SingleFestival.ComputeLineUps();
                switch (request.ToLower())
                {
                case "bands":
                    return(Festival.SingleFestival.Bands);

                case "optredens":
                    return(Festival.SingleFestival.Optredens);

                case "stages":
                    return(Festival.SingleFestival.Stages);

                case "genres":
                    return(Festival.SingleFestival.Genres);

                default: throw new HttpResponseException(Request.CreateResponse(System.Net.HttpStatusCode.NotFound));
                }
            }
            catch (Exception ex)
            {
                throw new HttpResponseException(Request.CreateResponse(System.Net.HttpStatusCode.NotFound));
            }
        }
Exemple #18
0
        public async Task <IActionResult> Create([Bind("Id,ImagePath,ImageText,Title,SubTitle,Duration,Code,Price,AboutTourText,AboutTourNumber,TourImage,TourName,TourInformation,TourVideo,TourCheckIn,TourText,TourTime,TourAdditional,TourSecondAdditional,Number,SecondNumber,Email,SiteAddress,Address,EventId")] Festival festival, IFormFile TourImage)
        {
            CustomDateTimeFile customDateTimeFile = new CustomDateTimeFile();
            string             fileName           = customDateTimeFile.GetFileName(TourImage.FileName);

            if (ModelState.IsValid)
            {
                festival.TourImage = fileName;
                if (_IsAcceptedFormat(TourImage.ContentType))
                {
                    string path = Path.Combine(hostingEnvironment.WebRootPath, "images", fileName);
                    byte[] data = new byte[TourImage.Length];

                    using (FileStream fileStream = new FileStream(path, FileMode.Create))
                    {
                        await TourImage.CopyToAsync(fileStream);
                    }
                }
                await _context.AddAsync(festival);

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EventId"] = new SelectList(_context.Events, "Id", "Id", festival.EventId);
            return(View(festival));
        }
Exemple #19
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,ImagePath,ImageText,Title,SubTitle,Duration,Code,Price,AboutTourText,AboutTourNumber,TourImage,TourName,TourInformation,TourVideo,TourCheckIn,TourText,TourTime,TourAdditional,TourSecondAdditional,Number,SecondNumber,Email,SiteAddress,Address,EventId")] Festival festival)
        {
            if (id != festival.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(festival);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FestivalExists(festival.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EventId"] = new SelectList(_context.Events, "Id", "Id", festival.EventId);
            return(View(festival));
        }
Exemple #20
0
        private List <Festival> GetFestivals()
        {
            List <Festival> festivals = new List <Festival>();

            using (MySqlConnection conn = new MySqlConnection(connectionString))
            {
                conn.Open();
                MySqlCommand cmd = new MySqlCommand("select * from Festival", conn);

                using (var reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        Festival f = new Festival
                        {
                            Id           = Convert.ToInt32(reader["Id"]),
                            Naam         = reader["Naam"].ToString(),
                            Omschrijving = reader["Omschrijving"].ToString(),
                            Datum        = DateTime.Parse(reader["Datum"].ToString())
                        };
                        festivals.Add(f);
                    }
                }
            }

            return(Festivals);
        }
        //zet data neer van de database voor een festival
        private Festival GetFestival(string id)
        {
            List <Festival> festivals = new List <Festival>();

            using (MySqlConnection conn = new MySqlConnection(connectionString))
            {
                conn.Open();
                MySqlCommand cmd = new MySqlCommand($"select * from festival where id = {id}", conn);

                using (var reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        Festival f = new Festival
                        {
                            Id           = Convert.ToInt32(reader["Id"]),
                            Naam         = reader["Naam"].ToString(),
                            Beschrijving = reader["Beschrijving"].ToString(),
                            Afbeelding   = reader["Afbeelding"].ToString(),
                            Prijs        = reader["Prijs"].ToString(),
                        };
                        festivals.Add(f);
                    }
                }
            }

            return(festivals[0]);
        }
        public ShowFestivalWindow(Festival fest)
        {
            this.selectedFestival = fest;
            InitializeComponent();
            this.Title = "Festival: " + fest.Name;
            this.LabelAlcohol.Content    = fest.AlcoholServing;
            this.LabelDate.Content       = fest.Date;
            this.LabelDesription.Content = fest.Description;
            this.LabelHandicap.Content   = fest.HandicapAccessible == true ? "Yes" : "No";
            this.LabelID.Content         = fest.Id;
            this.LabelName.Content       = fest.Name;
            this.LabelSite.Content       = fest.Indoors == true ? "indoors" : "outdoors";
            this.LabelSmoking.Content    = fest.SmokingAllowed == true ? "Yes" : "No";
            this.LabelType.Content       = fest.Type;
            this.ImageIcon.Source        = new BitmapImage(new Uri(fest.IconPath));
            this.ImageIcon.MaxHeight     = 50;
            this.ImageIcon.MaxWidth      = 60;
            this.LabelPrice.Content      = fest.PriceCategory;

            foreach (Tag t in fest.Tags)
            {
                Label newTagLabel = new Label
                {
                    Content    = t.Id,
                    Foreground = new SolidColorBrush(t.Color)
                };
                this.SPTags.Children.Add(newTagLabel);
            }
        }
Exemple #23
0
        public async Task <ActionResult <Festival> > PostFestival(Festival festival)
        {
            _context.Festival.Add(festival);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetFestival", new { id = festival.IdF }, festival));
        }
Exemple #24
0
        public async Task <IHttpActionResult> PostFestival([FromBody] Festival festival)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Festivals.Add(festival);
            await db.SaveChangesAsync();

            //db.Entry(artiste).Reference(x => x.Programmations).Load();

            var dto = new FestivalDTO()
            {
                Id            = festival.Id,
                Description   = festival.Description,
                DateFin       = festival.DateFin,
                Nom           = festival.Nom,
                DateDebut     = festival.DateDebut,
                Lieu          = festival.Lieu,
                CodePostal    = festival.CodePostal,
                UserId        = festival.UserId,
                Prix          = festival.Prix,
                IsInscription = festival.IsInscription,
                IsPublication = festival.IsPublication
            };

            return(CreatedAtRoute("DefaultApi", new { id = festival.Id }, dto));
        }
Exemple #25
0
        public void GetFestivalFull_FestivalId_ReturnsAFestivalWithAddress()
        {
            //Arrange
            ContextBase.Addresses.AddRange(
                new Address
            {
                Street     = "Test Address",
                Number     = "1",
                PostalCode = "28303",
                State      = "Bremen",
                Country    = "Germany"
            });

            ContextBase.SaveChanges();

            ContextBase.Festivals.AddRange(
                new Festival
            {
                Id          = 14,
                Title       = "Hellfest",
                Description = "",
                StartDate   = DateTimeMock.Object.Now.AddDays(5),
                EndDate     = DateTimeMock.Object.Now.AddDays(8),
                AddressId   = ContextBase.Addresses.First(a => a.Street == "Test Address").Id
            });

            ContextBase.SaveChanges();

            //Act
            Festival festivalFromRepository = MedievalFestivalsRepositoryBase.GetFestivalFull(14);

            //Assert
            Assert.True(festivalFromRepository.Address != null);
        }
        private List <Festival> GetFestivals()
        {
            List <Festival> festivals = new List <Festival>();

            using (MySqlConnection conn = new MySqlConnection(connectionString))
            {
                conn.Open();
                MySqlCommand cmd = new MySqlCommand("select * from festival", conn);

                using (var reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        Festival p = new Festival
                        {
                            Id           = Convert.ToInt32(reader["Id"]),
                            Naam         = reader["Naam"].ToString(),
                            Beschrijving = reader["Beschrijving"].ToString(),
                            Start_dt     = DateTime.Parse(reader["start_dt"].ToString()),
                            Eind_dt      = DateTime.Parse(reader["eind_dt"].ToString()),
                            Plaatje      = reader["Plaatje"].ToString(),
                        };
                        festivals.Add(p);
                    }
                }
            }

            return(festivals);
        }
Exemple #27
0
        public async Task <IHttpActionResult> PutFestival(int id, Festival festival)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != festival.Id)
            {
                return(BadRequest());
            }

            db.Entry(festival).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FestivalExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #28
0
        public async void UpdateFestivalWithTooLongNameShouldThrowError(string name)
        {
            Festival festival = await _dbMock.Object.Festivals.FirstAsync(f => f.Id == 1);

            festival.FestivalName = name;
            await Assert.ThrowsAsync <InvalidDataException>(() => _festivalService.UpdateFestival(festival));
        }
        private Festival GetFestival(string id)
        {
            List <Festival> festivals = new List <Festival>();

            using (MySqlConnection conn = new MySqlConnection(connectionString))
            {
                conn.Open();
                MySqlCommand cmd = new MySqlCommand($"select * from ticket where id = {id}", conn);

                using (var reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        Festival p = new Festival
                        {
                            Id              = Convert.ToInt32(reader["id"]),
                            Naam            = reader["Naam"].ToString(),
                            Start_dt        = DateTime.Parse(reader["start_dt"].ToString()),
                            Eind_dt         = DateTime.Parse(reader["eind_dt"].ToString()),
                            Beschrijving    = reader["beschrijving"].ToString(),
                            Prijs           = reader["prijs"].ToString(),
                            Plaatje         = reader["Plaatje"].ToString(),
                            Beschikbaarheid = Convert.ToInt32(reader["Beschikbaarheid"]),
                        };
                        festivals.Add(p);
                    }
                }
            }
            return(festivals[0]);
        }
Exemple #30
0
        private List <Festival> GetFestivals()
        {
            List <Festival> festivals = new List <Festival>();

            using (MySqlConnection conn = new MySqlConnection(connectionString))
            {
                conn.Open();
                MySqlCommand cmd = new MySqlCommand($"select * from festival", conn);

                using (var reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        Festival p = new Festival
                        {
                            Id              = Convert.ToInt32(reader["ID"]),
                            Naam            = reader["naam"].ToString(),
                            Beschrijving    = reader["beschrijving"].ToString(),
                            Datum           = reader["datum"].ToString(),
                            Tijd            = reader["tijd"].ToString(),
                            Img             = reader["Img"].ToString(),
                            Prijs           = Convert.ToDecimal(reader["Prijs"]),
                            Artiesten       = reader["artiesten"].ToString(),
                            Minimumleeftijd = reader["minimumleeftijd"].ToString(),
                        };
                        festivals.Add(p);
                    }
                }
            }
            return(festivals);
        }
        public IActionResult NarFestivali()
        {
            ViewBag.Setting = _toursDbContext.Settings.First();
            Festival model = _toursDbContext.Festivals.FirstOrDefault();

            return(View(model));
        }
        public Achievement(Festival festival, Discipline discipline, Pupil pupil)
        {
            if (festival == null)
                throw new ArgumentNullException(nameof(festival));
            if (discipline == null)
                throw new ArgumentNullException(nameof(discipline));
            if (pupil == null)
                throw new ArgumentNullException(nameof(pupil));

            Festival = festival;
            Discipline = discipline;
            Pupil = pupil;
        }
        //Constructor
        public LInstellingenVM()
        {
            Festivals = Festival.GetFestivals();
            Stages = Stage.GetStages();
            Genres = Genre.GetGenres();
            FestivalData = new Festival();
            //eind en begin datum zetten indien er al een in de database aanwezig is
            SelectedStartDate = Festival.GetStartDate();
            SelectedEndDate = Festival.GetEndDate();
            FullDate = Convert.ToDateTime(SelectedStartDate).ToShortDateString() + "    -    " + Convert.ToDateTime(SelectedEndDate).ToShortDateString();

            NewStage = new Stage();
            NewGenre = new Genre();
        }
        internal static void SaveFestival(Festival f)
        {
            OrganisatieRepository.SaveOrganisatie(f.Organisatie);

            string sql = "UPDATE festival SET Naam = @Naam, OrganisatieID = @OrganisatieID, Startdatum = @Startdatum, Einddatum = @Einddatum, Straat_Nr = @Straat_Nr, Postcode = @Postcode, Gemeente = @Gemeente, Image = @Image, Beschrijving = @Beschrijving";
            DbParameter par1 = Database.AddParameter("@Naam", f.Naam);
            DbParameter par2 = Database.AddParameter("@OrganisatieID", f.Organisatie.ID);
            DbParameter par3 = Database.AddParameter("@Startdatum", f.Startdatum);
            DbParameter par4 = Database.AddParameter("@Einddatum", f.Einddatum);
            DbParameter par5 = Database.AddParameter("@Straat_Nr", f.Straat_Nr);
            DbParameter par6 = Database.AddParameter("@Postcode", f.Postcode);
            DbParameter par7 = Database.AddParameter("@Gemeente", f.Gemeente);
            DbParameter par8 = Database.AddParameter("@Image", f.Image);
            DbParameter par9 = Database.AddParameter("@Beschrijving", f.Beschrijving);

            Database.ModifyData(sql, par1, par2, par3, par4, par5, par6, par7, par8, par9);
        }
        public static Festival GetFestival()
        {
            try
            {
                // Get data
                DbDataReader reader = Database.GetData("SELECT * FROM festival");
                foreach (DbDataRecord record in reader)
                {
                    // Create new Festival
                    Festival festival = new Festival();

                    // Get ID
                    if (DBNull.Value.Equals(record["ID"])) festival.ID = -1;
                    else festival.ID = Convert.ToInt32(record["ID"]);

                    // Get Name
                    if (DBNull.Value.Equals(record["Name"])) festival.Name = "";
                    else festival.Name = record["Name"].ToString();

                    // Get Street
                    if (DBNull.Value.Equals(record["Street"])) festival.Street = "";
                    else festival.Street = record["Street"].ToString();

                    // Get City
                    if (DBNull.Value.Equals(record["City"])) festival.City = "";
                    else festival.City = record["City"].ToString();

                    reader.Close();
                    return festival;
                }
            }

            // Fail
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return null;
        }
        public static Achievement GetAchievement(SportsFestivalManagerContext connection, Festival festival, Discipline discipline, Pupil pupil)
        {
            var achievement = connection.Achievements.FirstOrDefault(x => x.FestivalId == festival.Id && x.DisciplineId == discipline.Id && x.PupilId == pupil.Id);

            if (achievement == null)
                connection.Achievements.Add(achievement = new Achievement(festival, discipline, pupil));

            return achievement;
        }
Exemple #37
0
        /// <summary>
        /// Creates a new card based on how many cards have already been made.
        /// </summary>
        /// <param name="card">
        /// The name of the card to be created.
        /// </param>
        /// <returns>
        /// The new created card.
        /// </returns>
        public static Card CreateCard(CardName card)
        {
            Contract.Requires(card != CardName.Backside & card != CardName.Empty);

            Contract.Ensures(Contract.Result<Card>().Name == card);

            Card c;
            switch (card)
            {
                case CardName.Copper:
                    c = new Copper();
                    break;
                case CardName.Silver:
                    c = new Silver();
                    break;
                case CardName.Gold:
                    c = new Gold();
                    break;
                case CardName.Curse:
                    c = new Curse();
                    break;
                case CardName.Estate:
                    c = new Estate();
                    break;
                case CardName.Duchy:
                    c = new Duchy();
                    break;
                case CardName.Province:
                    c = new Province();
                    break;
                case CardName.Gardens:
                    c = new Gardens();
                    break;
                case CardName.Cellar:
                    c = new Cellar();
                    break;
                case CardName.Chapel:
                    c = new Chapel();
                    break;
                case CardName.Chancellor:
                    c = new Chancellor();
                    break;
                case CardName.Village:
                    c = new Village();
                    break;
                case CardName.Woodcutter:
                    c = new Woodcutter();
                    break;
                case CardName.Workshop:
                    c = new Workshop();
                    break;
                case CardName.Feast:
                    c = new Feast();
                    break;
                case CardName.Moneylender:
                    c = new Moneylender();
                    break;
                case CardName.Remodel:
                    c = new Remodel();
                    break;
                case CardName.Smithy:
                    c = new Smithy();
                    break;
                case CardName.ThroneRoom:
                    c = new ThroneRoom();
                    break;
                case CardName.CouncilRoom:
                    c = new CouncilRoom();
                    break;
                case CardName.Festival:
                    c = new Festival();
                    break;
                case CardName.Laboratory:
                    c = new Laboratory();
                    break;
                case CardName.Library:
                    c = new Library();
                    break;
                case CardName.Market:
                    c = new Market();
                    break;
                case CardName.Mine:
                    c = new Mine();
                    break;
                case CardName.Adventurer:
                    c = new Adventurer();
                    break;
                case CardName.Bureaucrat:
                    c = new Bureaucrat();
                    break;
                case CardName.Militia:
                    c = new Militia();
                    break;
                case CardName.Spy:
                    c = new Spy();
                    break;
                case CardName.Thief:
                    c = new Thief();
                    break;
                case CardName.Witch:
                    c = new Witch();
                    break;
                case CardName.Moat:
                    c = new Moat();
                    break;
                default:
                    throw new NotImplementedException("Tried to create a card that was not implemented when CardFactory was last updated.");
            }

            c.Initialize(card, CardsMade[card]);
            CardsMade[card] += 1;
            createdCards.Add(c, true);
            return c;
        }