Beispiel #1
0
        public IHttpActionResult PutProsumer(int id, DAB4.Modeller.Prosumer prosumer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #2
0
        public IHttpActionResult GetProsumer(int id)
        {
            DAB4.Modeller.Prosumer prosumer = db.Prosumere.Find(id);
            if (prosumer == null)
            {
                return(NotFound());
            }

            return(Ok(prosumer));
        }
Beispiel #3
0
        public IHttpActionResult PostProsumer(DAB4.Modeller.Prosumer prosumer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Prosumere.Add(prosumer);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = prosumer.Id }, prosumer));
        }
Beispiel #4
0
        public IHttpActionResult DeleteProsumer(int id)
        {
            DAB4.Modeller.Prosumer prosumer = db.Prosumere.Find(id);
            if (prosumer == null)
            {
                return(NotFound());
            }

            db.Prosumere.Remove(prosumer);
            db.SaveChanges();

            return(Ok(prosumer));
        }