Exemple #1
0
        public void SaveItems(IEnumerable <ShoppingCartItem> items)
        {
            //run this in a transaction
            var cmds = new List <DbCommand>();

            foreach (var item in this.OrderItems)
            {
                cmds.Add(item.GetDeleteCommand());
            }

            //now add in these items
            foreach (var item in items)
            {
                var newItem = new OrderItem();
                newItem.SKU            = item.Product.SKU;
                newItem.OrderID        = this.OrderID;
                newItem.Quantity       = item.Quantity;
                newItem.DateAdded      = item.DateAdded;
                newItem.Discount       = item.Discount;
                newItem.DiscountReason = item.DiscountReason;
                cmds.Add(newItem.GetInsertCommand());
            }

            var db = new KonaDB();

            db.ExecuteTransaction(cmds);
        }
Exemple #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 });

        }
Exemple #3
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 }));
        }
Exemple #4
0
        public void SaveWidgetOrder()
        {
            var    commands = new List <DbCommand>();
            KonaDB db       = new KonaDB();

            if (Request.Form["widgetid"] != null)
            {
                //pull out all widgetid's
                var ids       = Request.Form.GetValues("widgetid").Where(x => !String.IsNullOrEmpty(x)).ToArray();
                int listOrder = 0;
                foreach (var id in ids)
                {
                    var widgetID = new Guid(id);
                    //subsonic style...
                    commands.Add(db.Update <Widget>().Set(x => x.ListOrder == listOrder).Where(x => x.WidgetID == widgetID).GetCommand().ToDbCommand());
                    listOrder++;
                }
            }
            //transaction :)
            db.ExecuteTransaction(commands);
        }
Exemple #5
0
        public void SaveItems(IEnumerable<ShoppingCartItem> items) {

            //run this in a transaction
            var cmds = new List<DbCommand>();
            foreach (var item in this.OrderItems) {
                cmds.Add(item.GetDeleteCommand());
            }

            //now add in these items
            foreach (var item in items) {
                var newItem = new OrderItem();
                newItem.SKU = item.Product.SKU;
                newItem.OrderID = this.OrderID;
                newItem.Quantity = item.Quantity;
                newItem.DateAdded = item.DateAdded;
                newItem.Discount = item.Discount;
                newItem.DiscountReason = item.DiscountReason;
                cmds.Add(newItem.GetInsertCommand());
            }

            var db = new KonaDB();
            db.ExecuteTransaction(cmds);

        }
Exemple #6
0
        public void SaveWidgetOrder() {

            var commands = new List<DbCommand>();
            KonaDB db = new KonaDB();

            if (Request.Form["widgetid"] != null) {
                //pull out all widgetid's
                var ids = Request.Form.GetValues("widgetid").Where(x => !String.IsNullOrEmpty(x)).ToArray();
                int listOrder = 0;
                foreach (var id in ids) {
                    var widgetID = new Guid(id);
                    //subsonic style...
                    commands.Add(db.Update<Widget>().Set(x => x.ListOrder == listOrder).Where(x=>x.WidgetID==widgetID).GetCommand().ToDbCommand());
                    listOrder++;
                }
            }
            //transaction :)
            db.ExecuteTransaction(commands);

        }