示例#1
0
        public ActionResult Create(FormCollection form)
        {
            Widget newWidget = new Widget();

            UpdateModel <Widget>(newWidget);

            //the category ID should be sent in as "categoryid"
            string categoryID = form["CategoryID"];

            var widgetCommand = newWidget.GetInsertCommand();

            //save the category too
            Categories_Widget map = new Categories_Widget();
            int catid             = 0;

            int.TryParse(categoryID, out catid);
            map.CategoryID = catid;
            map.WidgetID   = newWidget.WidgetID;

            var mapCommand = map.GetInsertCommand();

            KonaDB db = new KonaDB();

            db.ExecuteTransaction(new List <DbCommand>()
            {
                widgetCommand, mapCommand
            });

            //return a json result with the ID
            return(Json(new { ID = newWidget.WidgetID, Zone = newWidget.Zone }));
        }
示例#2
0
        public ActionResult Create(FormCollection form)
        {

            Widget newWidget = new Widget();
            UpdateModel<Widget>(newWidget);

            //the category ID should be sent in as "categoryid"
            string categoryID = form["CategoryID"];
 
            var widgetCommand = newWidget.GetInsertCommand();

            //save the category too
            Categories_Widget map = new Categories_Widget();
            int catid = 0;
            int.TryParse(categoryID, out catid);
            map.CategoryID = catid;
            map.WidgetID = newWidget.WidgetID;

            var mapCommand = map.GetInsertCommand();

            KonaDB db = new KonaDB();
            db.ExecuteTransaction(new List<DbCommand>() { widgetCommand, mapCommand });

            //return a json result with the ID
            return Json(new { ID = newWidget.WidgetID, Zone = newWidget.Zone });

        }
示例#3
0
        public void Delete(string id)
        {
            Guid widgetID = new Guid(id);

            //delete associations
            Categories_Widget.Delete(x => x.WidgetID == widgetID);

            //delete the widget
            Widget.Delete(widgetID);
        }