Ejemplo n.º 1
0
        public IHttpActionResult PutPromotie(int id, Promotie promotie)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != promotie.PromotieID)
            {
                return(BadRequest());
            }

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PromotieExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        private void Promotie_Tapped(object sender, TappedRoutedEventArgs e)
        {
            StackPanel sp       = sender as StackPanel;
            Promotie   promotie = sp.DataContext as Promotie;

            frameOndernemingGegevens.Navigate(typeof(PromotieGegevens), promotie);
        }
Ejemplo n.º 3
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     base.OnNavigatedTo(e);
     _promotie = e.Parameter as Promotie;
     PromotieGegevens.DataContext = _promotie;
     begindatum.Date = _promotie.Begindatum.Date;
     einddatum.Date  = _promotie.Einddatum.Date;
 }
Ejemplo n.º 4
0
        //VERWIJDER PROMOTIE
        public async Task <HttpResponseMessage> verwijderPromotie(Promotie promotie)
        {
            HttpClient client     = new HttpClient();
            int        promotieId = promotie.PromotieID;
            var        res        = await client.DeleteAsync($"http://localhost:57003/api/promoties/{promotieId}");

            return(res);
        }
Ejemplo n.º 5
0
        //VOEG PROMOTIE TOE
        public async Task <HttpResponseMessage> voegPromotieToe(Promotie promotie)
        {
            var        promotieJson = JsonConvert.SerializeObject(promotie);
            HttpClient client       = new HttpClient();
            var        res          = await client.PostAsync("http://localhost:57003/api/promoties/", new StringContent(promotieJson, System.Text.Encoding.UTF8, "application/json"));

            return(res);
        }
Ejemplo n.º 6
0
        //UPDATE PROMOTIE
        public async Task <HttpResponseMessage> UpdatePromotie(Promotie promotie)
        {
            HttpClient client       = new HttpClient();
            int        promotieId   = promotie.PromotieID;
            var        promotieJson = JsonConvert.SerializeObject(promotie);
            var        res          = await client.PutAsync($"http://localhost:57003/api/promoties/{promotieId}", new StringContent(promotieJson, System.Text.Encoding.UTF8, "application/json"));

            return(res);
        }
Ejemplo n.º 7
0
        public IHttpActionResult GetPromotie(int id)
        {
            Promotie promotie = db.Promoties.Find(id);

            if (promotie == null)
            {
                return(NotFound());
            }

            return(Ok(promotie));
        }
Ejemplo n.º 8
0
        public IHttpActionResult PostPromotie(Promotie promotie)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Promoties.Add(promotie);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = promotie.PromotieID }, promotie));
        }
Ejemplo n.º 9
0
        public IHttpActionResult DeletePromotie(int id)
        {
            Promotie promotie = db.Promoties.Find(id);

            if (promotie == null)
            {
                return(NotFound());
            }

            db.Promoties.Remove(promotie);
            db.SaveChanges();

            return(Ok(promotie));
        }
Ejemplo n.º 10
0
        private async void WijzigenGegevensButton_Click(object sender, RoutedEventArgs e)
        {
            if (!naam.Text.Equals("") && !omschrijving.Text.Equals("") && !korting.Text.Equals("") && !(begindatum.Date.DateTime < DateTime.Today) && !(begindatum.Date.DateTime > einddatum.Date.DateTime))
            {
                IEnumerable <Promotie> promoties = await services.getPromoties();

                Promotie p = promoties.FirstOrDefault(pr => pr.Naam.Equals(naam.Text));

                if (p == null || _promotie.Naam == naam.Text)
                {
                    _promotie.Naam         = naam.Text;
                    _promotie.Omschrijving = omschrijving.Text;
                    _promotie.Korting      = korting.Text;
                    _promotie.Begindatum   = begindatum.Date.DateTime;
                    _promotie.Einddatum    = einddatum.Date.DateTime;
                    await services.UpdatePromotie(_promotie);

                    foutmelding.Text   = "";
                    succesMessage.Text = "Promotie aangepast";
                }
                else
                {
                    succesMessage.Text = "";
                    foutmelding.Text   = "Er bestaat al een promotie met deze naam!";
                }
                p = null;
            }
            else if (begindatum.Date.DateTime < DateTime.Today)
            {
                succesMessage.Text = "";
                foutmelding.Text   = "De begindatum moet vandaag of later zijn!";
            }
            else if (begindatum.Date.DateTime > einddatum.Date.DateTime)
            {
                succesMessage.Text = "";
                foutmelding.Text   = "De einddatum mag niet voor de begindatum liggen!";
            }
            else
            {
                succesMessage.Text = "";
                foutmelding.Text   = "Promotie niet aangepast, controleer of u alle gegevens correct hebt ingevuld!!";
            }
        }
Ejemplo n.º 11
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            Type check = ((App)Application.Current).huidigeGebruiker.GetType();

            if (check == typeof(Ondernemer))
            {
                VisualStateManager.GoToState(this, "zakelijk", false);
            }
            else
            {
                VisualStateManager.GoToState(this, "nietzakelijk", false);
            }

            services  = new Services();
            _promotie = (Promotie)e.Parameter;
            promotieGrid.DataContext = _promotie;
            onderneming.DataContext  = _promotie.Onderneming;
        }
Ejemplo n.º 12
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            if ((!naam.Text.Equals("") && !omschrijving.Text.Equals("") && begindatum.Date != null && cmbOndernemingen.SelectedItem != null && !korting.Text.Equals("")) && !(begindatum.Date.DateTime < DateTime.Today) && !(begindatum.Date.DateTime > einddatum.Date.DateTime))
            {
                IEnumerable <Promotie> promoties = await services.getPromoties();

                Promotie p = promoties.FirstOrDefault(pr => pr.Naam.Equals(naam.Text));

                if (p == null)
                {
                    Onderneming onderneming = cmbOndernemingen.SelectedItem as Onderneming;

                    Promotie promotie = new Promotie {
                        Naam = naam.Text, Omschrijving = omschrijving.Text, Begindatum = begindatum.Date.DateTime, Einddatum = einddatum.Date.DateTime, OndernemingID = onderneming.OndernemingID, Korting = korting.Text
                    };
                    await services.voegPromotieToe(promotie);

                    new NotificatieViewModel("Promoties", String.Format("Promotie {0} aangemaakt!", naam.Text));
                    framePromotieAanmaken.Navigate(typeof(OverzichtPromoties));
                }
                else
                {
                    foutmelding.Text = "Er bestaat al een promotie met deze naam!";
                }
                p = null;
            }
            else if (begindatum.Date.DateTime < DateTime.Today)
            {
                foutmelding.Text = "De begindatum moet vandaag of later zijn!";
            }
            else if (begindatum.Date.DateTime > einddatum.Date.DateTime)
            {
                foutmelding.Text = "De einddatum mag niet voor de begindatum liggen!";
            }
            else
            {
                foutmelding.Text = "Vul alle gegevens correct in!";
            }
        }
Ejemplo n.º 13
0
        private async void voegPromotieToe()
        {
            DateTime Start = new DateTime(this.StartDatum.Year, this.StartDatum.Month, this.StartDatum.Day, this.StartUur.Hours, 0, 0);
            DateTime Eind  = new DateTime(this.EindDatum.Year, this.EindDatum.Month, this.EindDatum.Day, this.EindUur.Hours, 0, 0);
            //start.AddYears(this.StartDatum.Year);
            //start.AddMonths(this.StartDatum.Month);
            //start.AddDays(this.StartDatum.Day);
            //start.AddHours(this.StartUur.Hours);
            //Eind.AddYears(this.EindDatum.Year);
            //Eind.AddMonths(this.EindDatum.Month);
            //Eind.AddDays(this.EindDatum.Day);
            //Eind.AddHours(this.EindUur.Hours);



            var        CreatedEvent = new Promotie(this.Naam, Start, Eind, this.Kortingsbon, this.mp.LoggedInOnderneming.OndernemingID);
            HttpClient client       = new HttpClient();
            var        json         = await client.PostAsJsonAsync(new Uri("http://localhost:52974/api/promoties"), CreatedEvent);

            var ond = await client.GetStringAsync(new Uri("http://localhost:52974/api/ondernemings/" + mp.LoggedInOnderneming.OndernemingID));

            mp.LoggedInOnderneming = JsonConvert.DeserializeObject <Onderneming>(ond);
            mp.CurrentData         = new PromotieViewModel(this.mp);
        }
Ejemplo n.º 14
0
        public PromotieImageViewModel(Promotie promotie)
        {
//            this.mp = mp;
            this.Promotie   = promotie;
            DownloadCommand = new RelayCommand((d) => Download());
        }