Example #1
0
        public async Task <IHttpActionResult> PutHarAdresse(long id, HarAdresse harAdresse)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != harAdresse.AdresseId)
            {
                return(BadRequest());
            }

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

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!HarAdresseExists(id))
                {
                    return(NotFound());
                }
                throw;
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #2
0
        public async Task <IHttpActionResult> PostHarAdresse(HarAdresse harAdresse)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.HarAdresses.Add(harAdresse);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (HarAdresseExists(harAdresse.AdresseId))
                {
                    return(Conflict());
                }
                throw;
            }

            return(CreatedAtRoute("DefaultApi", new { id = harAdresse.AdresseId }, harAdresse));
        }