public IHttpActionResult PutTextBox(int id, TextBox textBox)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #2
0
        public TextBox UpsertTextBoxOne(TextBox textBox, TextBoxOneDBEntities db)
        {
            using (db)
            {
                if (textBox.Id == default(int))
                {
                    db.TextBoxes.Add(textBox);
                }
                else
                {
                    db.Entry(textBox).State = EntityState.Modified;
                }

                db.SaveChanges();
                return(textBox);
            }
        }