Example #1
0
        public IHttpActionResult PostSklep(Sklep sklep)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.Sklepy.Add(sklep);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (SklepExists(sklep.Id))
                {
                    return Conflict();
                }
                else
                {
                    throw;
                }
            }

            return CreatedAtRoute("DefaultApi", new { id = sklep.Id }, sklep);
        }
Example #2
0
        public IHttpActionResult PutSklep(string id, Sklep sklep)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

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

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

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

            return StatusCode(HttpStatusCode.NoContent);
        }