Exemplo n.º 1
0
        public IHttpActionResult PutHund(int id, Hund hund)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public ActionResult Create([Bind(Include = "id,Farbe,Staerke,IstWasserfest")] Stift stift)
        {
            if (ModelState.IsValid)
            {
                db.Stifts.Add(stift);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(stift));
        }
Exemplo n.º 3
0
        public ActionResult Create([Bind(Include = "Id,Name,AnzahlFlöhe,Rasse,Nasenlänge")] Hund hund)
        {
            if (ModelState.IsValid)
            {
                db.Hunds.Add(hund);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(hund));
        }