Esempio n. 1
0
        public IHttpActionResult PutGebeurtenis(int id, Gebeurtenis gebeurtenis)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != gebeurtenis.GebeurtenisId)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Beschrijving,Datum,Project_Id")] Gebeurtenis gebeurtenis)
        {
            if (id != gebeurtenis.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(gebeurtenis);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GebeurtenisExists(gebeurtenis.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Project_Id"] = new SelectList(_context.Project, "Id", "Naam", gebeurtenis.Project_Id);
            return(View(gebeurtenis));
        }
Esempio n. 3
0
        public IHttpActionResult GetGebeurtenis(int id)
        {
            Gebeurtenis gebeurtenis = db.Gebeurtenis.Find(id);

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

            return(Ok(gebeurtenis));
        }
Esempio n. 4
0
        public IHttpActionResult PostGebeurtenis(Gebeurtenis gebeurtenis)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Gebeurtenis.Add(gebeurtenis);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = gebeurtenis.GebeurtenisId }, gebeurtenis));
        }
Esempio n. 5
0
        private async void RemoveClick(object sender, RoutedEventArgs e)
        {
            Button      b  = (Button)sender;
            Gebeurtenis rG = (Gebeurtenis)b.DataContext;

            gebeurtenissen.Remove(rG);
            HttpClient client     = new HttpClient();
            var        jsonString = JsonConvert.SerializeObject(rG);
            var        result     = await client.DeleteAsync("http://localhost:1227/api/gebeurtenis/" + rG.GebeurtenisId);

            var status = result.StatusCode;
        }
Esempio n. 6
0
        public GebeurtenisAdmin()
        {
            g = new Gebeurtenis();

            g.Campus = new Campus {
                Name = "SChoonmeersen", Adres = new Adres {
                    City = "Gent", Street = "Voskeslaan", StreetNumber = 12
                }
            };
            this.InitializeComponent();
            sp.DataContext = g;
        }
Esempio n. 7
0
        public IHttpActionResult DeleteGebeurtenis(int id)
        {
            Gebeurtenis gebeurtenis = db.Gebeurtenis.Find(id);

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

            db.Gebeurtenis.Remove(gebeurtenis);
            db.SaveChanges();

            return(Ok(gebeurtenis));
        }
        public async Task <IActionResult> Create([Bind("Id,Beschrijving,Datum,Project_Id")] Gebeurtenis gebeurtenis)
        {
            int project_id = new int();

            if (TempData.ContainsKey("project"))
            {
                //If so access it here
                project_id = Convert.ToInt32(TempData["project"]);
            }

            if (ModelState.IsValid)
            {
                gebeurtenis.Project_Id = project_id;

                _context.Add(gebeurtenis);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Project_Id"] = new SelectList(_context.Project, "Id", "Naam", gebeurtenis.Project_Id);
            return(View(gebeurtenis));
        }