Beispiel #1
0
        public IHttpActionResult PutRow(int id, Row row)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != row.RowId)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #2
0
        public Row UpsertRows(Row row, NewRowDBEntities db)
        {
            using (db)
            {
                if (row.RowId == default(int))
                {
                    row.RowClass = "row";
                    db.Rows.Add(row);
                }
                else
                {
                    db.Entry(row).State = EntityState.Modified;
                }

                db.SaveChanges();
                return(row);
            }
        }
        public Row CreateRow(int?newPageId)
        {
            Row row             = new Row();
            NewRowDBEntities db = new NewRowDBEntities();

            using (db)
            {
                if (row.RowId == default(int))
                {
                    row.RowClass = "row";
                    row.PageId   = newPageId;
                    db.Rows.Add(row);
                }
                else
                {
                    db.Entry(row).State = EntityState.Modified;
                }

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