public IHttpActionResult PutColumn(int id, Column column)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != column.ColumnId)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #2
0
        //Upsert Columns

        public Column UpsertColumns(Column column, NewColumnDBEntities2 db)
        {
            using (db)
            {
                if (column.ColumnId == default(int))
                {
                    column.ColumnClass       = "col-" + column.ColumnClass;
                    column.ColumnClassMobile = column.ColumnClass;
                    column.ColumnClassTablet = column.ColumnClass;
                    column.ColumnClassLaptop = column.ColumnClass;



                    db.Columns.Add(column);
                }
                else
                {
                    column.ColumnClass       = "col-" + column.ColumnClass;
                    column.ColumnClassMobile = "col-" + column.ColumnClassMobile;
                    column.ColumnClassTablet = "col-" + column.ColumnClassTablet;
                    column.ColumnClassLaptop = "col-" + column.ColumnClassLaptop;



                    db.Entry(column).State = EntityState.Modified;
                }

                db.SaveChanges();
                return(column);
            }
        }
        public Column CreateThreeSizeColumn(int newRowId)
        {
            Column column           = new Column();
            NewColumnDBEntities2 db = new NewColumnDBEntities2();

            using (db)
            {
                if (column.ColumnId == default(int))
                {
                    column.ColumnClass       = "col-3";
                    column.ColumnClassMobile = "col-12";
                    column.ColumnClassLaptop = "col-3";
                    column.ColumnClassTablet = "col-3";
                    column.RowId             = newRowId;
                    db.Columns.Add(column);
                }
                else
                {
                    db.Entry(column).State = EntityState.Modified;
                }

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