Esempio n. 1
0
 public void PutKlant(int id, Klanten klant)
 {
     klant.KlantId = id;
     if (!repository.Update(klant))
     {
         throw new HttpResponseException(HttpStatusCode.NotFound);
     }
 }
Esempio n. 2
0
        public HttpResponseMessage PostKlant(Klanten item)
        {
            item = repository.Add(item);
            var response = Request.CreateResponse<Klanten>(HttpStatusCode.Created, item);

            string uri = Url.Link("DefaultApi", new { id = item.KlantId });
            response.Headers.Location = new Uri(uri);
            return response;
        }
Esempio n. 3
0
 public void DeleteKlant(int id, Klanten product)
 {
     Klanten item = repository.Get(id);
     if (item == null || !(item is Klanten))
     {
         throw new HttpResponseException(HttpStatusCode.NotFound);
     }
     repository.Remove(id);
 }
 public Klanten Add(Klanten item)
 {
     if (item == null)
     {
         throw new ArgumentNullException("item");
     }
     item.KlantId = _nextId++;
     products.Add(item);
     return item;
 }
        public ActionResult Create(Klanten klanten)
        {
            if (ModelState.IsValid)
            {
                db.Klanten.Add(klanten);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(klanten);
        }
 public bool Update(Klanten item)
 {
     if (item == null)
     {
         throw new ArgumentNullException("item");
     }
     int index = products.FindIndex(p => p.KlantId == item.KlantId);
     if (index == -1)
     {
         return false;
     }
     products.RemoveAt(index);
     products.Add(item);
     return true;
 }
 public ActionResult Edit(Klanten klanten)
 {
     if (ModelState.IsValid)
     {
         db.Entry(klanten).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(klanten);
 }