• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Models.Order类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中MvcMusicStore.Models.Order的典型用法代码示例。如果您正苦于以下问题:C# Order类的具体用法?C# Order怎么用?C# Order使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Order类属于MvcMusicStore.Models命名空间,在下文中一共展示了Order类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: AddressAndPayment

        public ActionResult AddressAndPayment(FormCollection values)
        {
            var order = new Order();
            TryUpdateModel(order);

            string promoCode = values["PromoCode"];
            if (!String.IsNullOrEmpty(promoCode) && !string.Equals(promoCode, PromoCode, StringComparison.OrdinalIgnoreCase))
            {
                ModelState.AddModelError("", "Promo code is not valid.");
                //Invalid - redisplay with errors
                return View(order);
            }

            string userName = User.Identity.Name;
            var cart = ShoppingCart.GetCart(this.HttpContext);

            order.Username = userName;
            order.OrderDate = DateTime.Now;

            //Save Order
            _entities.Orders.Add(order);
            _entities.SaveChanges();

            //Process the order
            cart.CreateOrder(order);

            return RedirectToAction("Complete",
                   new { id = order.OrderId });
        }
开发者ID:dvonlehman,项目名称:Verde,代码行数:29,代码来源:CheckoutController.cs


示例2: CreateOrder

        public int CreateOrder(Order order)
        {
            decimal orderTotal = 0;

            var cartItems = GetCartItems();
            //add order details for each item in cart
            foreach (var item in cartItems)
            {
                var orderDetail = new OrderDetail
                {
                    AlbumId = item.AlbumId,
                    OrderId = order.OrderId,
                    UnitPrice = item.Album.Price,
                    Quantity = item.Count
                };
                //set the order total of the shopping cart
                orderTotal += (item.Count * item.Album.Price);

                storeDB.OrderDetails.Add(orderDetail);
            }
            // set the order's total to the orderTotal count
            order.Total = orderTotal;

            //save the order and finish up
            storeDB.SaveChanges();
            EmptyCart();
            return order.OrderId;
        }
开发者ID:ryangallen,项目名称:musicstore,代码行数:28,代码来源:ShoppingCart.cs


示例3: AddressAndPayment

        public ActionResult AddressAndPayment(FormCollection values)
        {
            var order = new Order();
            TryUpdateModel(order);

            try
            {
                if (string.Equals(values["PromoCode"], PromoCode,
                    StringComparison.OrdinalIgnoreCase) == false)
                {
                    return View(order);
                }
                else
                {
                    order.Username = User.Identity.Name;
                    order.OrderDate = DateTime.Now;

                    //Save Order
                    storeContext.Session.Save(order);

                    //Process the order
                    var cart = ShoppingCart.GetCart(this.HttpContext, storeContext);
                    cart.CreateOrder(order);

                    return RedirectToAction("Complete",
                        new { id = order.OrderId });
                }

            }
            catch
            {
                //Invalid - redisplay with errors
                return View(order);
            }
        }
开发者ID:kmckelvin,项目名称:NH3-MusicStore,代码行数:35,代码来源:CheckoutController.cs


示例4: CreateOrder

        public int CreateOrder(Order order)
        {
            decimal orderTotal = 0;

            foreach (var item in GetCartItems())
            {
                var orderDetail = new OrderDetail
                {
                    AlbumId = item.AlbumId,
                    OrderId = order.OrderId,
                    UnitPrice = item.Album.Price,
                    Quantity = item.Count
                };

                orderTotal += (item.Count * item.Album.Price);

                storeDB.OrderDetails.Add(orderDetail);
            }

            order.Total = orderTotal;

            storeDB.SaveChanges();

            EmptyCart();

            return order.OrderId;
        }
开发者ID:BLoe,项目名称:MvcMusicStore,代码行数:27,代码来源:ShoppingCart.cs


示例5: CreateOrder

        public int CreateOrder(Order order)
        {
            using (var tx = storeContext.Session.BeginTransaction())
            {
                var cartItems = GetCartItems();

                //Iterate the items in the cart, adding Order Details for each
                foreach (var cartItem in cartItems)
                {
                    var orderDetail = new OrderDetail
                                          {
                                              Album = cartItem.Album,
                                              Order = order,
                                              UnitPrice = cartItem.Album.Price
                                          };

                    order.OrderDetails.Add(orderDetail);
                }

                //Save the order
                storeContext.Session.Save(order);
                tx.Commit();
            }

            //Empty the shopping cart
            EmptyCart();

            //Return the OrderId as a confirmation number
            return order.OrderId;
        }
开发者ID:kmckelvin,项目名称:NH3-MusicStore,代码行数:30,代码来源:ShoppingCart.cs


示例6: CreateOrder

        public int CreateOrder(Order order)
        {
            decimal orderTotal = 0;

            var cartItems = GetCartItems();

            //Iterate the items in the cart, adding Order Details for each
            foreach (var cartItem in cartItems)
            {
                var orderDetails = new OrderDetail
                {
                    AlbumId = cartItem.AlbumId,
                    OrderId = order.OrderId,
                    UnitPrice = cartItem.Album.Price
                };

                storeDB.OrderDetails.AddObject(orderDetails);

                orderTotal += (cartItem.Count * cartItem.Album.Price);
            }

            //Save the order
            storeDB.SaveChanges();

            //Empty the shopping cart
            EmptyCart();

            //Return the OrderId as a confirmation number
            return order.OrderId;
        }
开发者ID:ravikp,项目名称:Blog,代码行数:30,代码来源:ShoppingCart.cs


示例7: AddressAndPayment

        public ActionResult AddressAndPayment(FormCollection values)
        {
            var order = new Order();

            TryUpdateModel(order);

            try 
            {
                if (string.Equals(values["PromoCode"], PromoCode, StringComparison.OrdinalIgnoreCase) == false)
                {
                    return View(order);
                }
                else
                {
                    order.Username = User.Identity.Name;
                    order.OrderDate = DateTime.Now;

                    storeDB.Orders.Add(order);
                    storeDB.SaveChanges();

                    var cart = ShoppingCart.GetCart(this.HttpContext);
                    cart.CreateOrder(order);

                    return RedirectToAction("Complete", new  { id = order.OrderId });
                }
            
            }
            catch
            {
                return View(order);
            }
        }
开发者ID:oromar,项目名称:learning.net,代码行数:32,代码来源:CheckoutController.cs


示例8: Edit

 public ActionResult Edit(Order order)
 {
     if (ModelState.IsValid)
     {
         db.Entry(order).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(order);
 }
开发者ID:o2platform,项目名称:Demo_ASPNET_MVCMusicStore,代码行数:10,代码来源:OrdersController.cs


示例9: Create

        public ActionResult Create(Order order)
        {
            if (ModelState.IsValid)
            {
                db.Orders.Add(order);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(order);
        }
开发者ID:o2platform,项目名称:Demo_ASPNET_MVCMusicStore,代码行数:11,代码来源:OrdersController.cs


示例10: AddressAndPaymentAsync

        public void AddressAndPaymentAsync(FormCollection values)
        {
            AsyncManager.OutstandingOperations.Increment();
            var worker = new BackgroundWorker();
            var order = new Order();
            bool success = true;

            TryUpdateModel(order);

            string promoCode = values["PromoCode"];
            if (!String.IsNullOrEmpty(promoCode) && !string.Equals(promoCode, PromoCode, StringComparison.OrdinalIgnoreCase))
            {
                ModelState.AddModelError("", "Promo code is not valid.");
                success = false;
            }

            string userName = User.Identity.Name;
            var cart = ShoppingCart.GetCart(this.HttpContext);

            worker.DoWork += (sender, args) =>
            {
                if (!success)
                    return;

                try
                {
                    order.Username = userName;
                    order.OrderDate = DateTime.Now;

                    //Save Order
                    _entities.Orders.Add(order);
                    _entities.SaveChanges();

                    //Process the order
                    cart.CreateOrder(order);
                    success = true;
                }
                catch
                {
                    success = false;
                }
            };

            worker.RunWorkerCompleted += (o, e) =>
            {
                AsyncManager.Parameters["order"] = order;
                AsyncManager.Parameters["success"] = success;
                AsyncManager.OutstandingOperations.Decrement();
            };

            worker.RunWorkerAsync(null);
        }
开发者ID:xuanvu,项目名称:Verde,代码行数:52,代码来源:CheckoutController.cs


示例11: CreateOrder

 public void CreateOrder(Order order)
 {
     order.Lines = new List<Order.OrderLine>(
         Lines.Select(line => new Order.OrderLine
         {
             Album = new Order.OrderLine.OrderAlbum
             {
                 Id = line.Album.Id,
                 Title = line.Album.Title
             },
             Price = line.Price,
             Quantity = line.Quantity
         }));
     Lines.Clear();
 }
开发者ID:Rationalle,项目名称:ravendb,代码行数:15,代码来源:ShoppingCart.cs


示例12: AddressAndPayment

        public ActionResult AddressAndPayment(FormCollection values)
        {
            var order = new Order();
            TryUpdateModel(order);

            try
            {
                if (string.Equals(values["PromoCode"], PromoCode,
                    StringComparison.OrdinalIgnoreCase) == false)
                {
                    return View(order);
                }
                else
                {
                    order.Username = User.Identity.Name;
                    order.OrderDate = DateTime.Now;

                    //Save Order
                    storeDB.Orders.Add(order);
                    storeDB.SaveChanges();

                    //Process the order
                    var cart = ShoppingCart.GetCart(this.HttpContext);
                    cart.CreateOrder(order);

                    //Add SMS notification here
                    if (order.SendSmsNotifications)
                    {
                        var client = new TwilioRestClient(Credentials.AccountSid, Credentials.AuthToken);
                        client.SendSmsMessage(
                                ConfigurationManager.AppSettings["PhoneNumber"],
                                order.Phone,
                                string.Format("Thank you for ordering.  You can check the status anytime by replying to this with the text 'status {0}'", order.OrderId)
                            );
                    }

                    return RedirectToAction("Complete",
                        new { id = order.OrderId });
                }

            }
            catch
            {
                //Invalid - redisplay with errors
                return View(order);
            }
        }
开发者ID:devinrader,项目名称:TwilioMvcMusicStore,代码行数:47,代码来源:CheckoutController.cs


示例13: CreateShippingInfo

        public static Order CreateShippingInfo()
        {
            var shippingInfo = new Order
            {
                FirstName = "Homer",
                LastName = "Simpson",
                Address = "742 Evergreen Terrace",
                City = "Springfield",
                State = "Kentucky",
                PostalCode = "123456",
                Country = "United States",
                Phone = "2341231241",
                Email = "[email protected]"
            };

            return shippingInfo;
        }
开发者ID:ScotLowery2,项目名称:maintainable-automated-ui-tests,代码行数:17,代码来源:StronglyTypedPageObjectTest.cs


示例14: AddressAndPayment

        public ActionResult AddressAndPayment(FormCollection values)
        {
            var order = new Order();

            try
            {
                // Updat the model
                UpdateModel(order);

                if (string.Equals(values["PromoCode"],
                    PromoCode,
                    StringComparison.OrdinalIgnoreCase) == false)
                {
                    return View(order);
                }
                else
                {
                    if (ModelState.IsValid)
                    {
                        // Promo Code supplied
                        order.Username = User.Identity.Name;
                        order.OrderDate = DateTime.Now;

                        // Save Order
                        storeDB.Orders.Add(order);
                        storeDB.SaveChanges();

                        // Process the order
                        var cart = ShoppingCart.GetCart(this);
                        cart.CreateOrder(order);

                        return RedirectToAction("Complete", new { id = order.OrderId });
                    }
                    else
                    {
                        throw new Exception("Model State is not valid!");
                    }
                }
            }
            catch
            {
                // Invalid -- redisplay with errors
                return View(order);
            }
        }
开发者ID:luiseduardohdbackup,项目名称:dotnet-1,代码行数:45,代码来源:CheckoutController.cs


示例15: Create

        public ActionResult Create(FormCollection values)
        {
            var order = new Order();
            TryUpdateModel(order);

                if (string.Equals(values["PromoCode"], PromoCode,
                    StringComparison.OrdinalIgnoreCase) == false)
                {
                    return View(order);
                }
                else
                {
                    order.Username = User.Identity.Name;
                    order.OrderDate = DateTime.Now;

                    //Save Order
                    db.Orders.Add(order);

                    //Process the order
                    var cart = ShoppingCart.GetCart(db, this.HttpContext);
                    cart.CreateOrder(order);

                    //add a note
                    order.Notes = new List<OrderNote>();
                    order.Transactions = new List<Transaction>();
                    order.Notes.Add(new OrderNote { Note = "Preparing Order", CreatedOn = DateTime.Now});

                    //auth the charge...
                    order.Transactions.Add(new Transaction { Processor = "coupon", Authorization = PromoCode, Amount = cart.GetTotal(), CreatedOn = DateTime.Now, Discount = 0, OrderId = order.OrderId });
                    order.Notes.Add(new OrderNote { Note = "Transaction Authorized by Coupon: " + PromoCode, CreatedOn = DateTime.Now});

                    //send a thank you note via email
                    order.Notes.Add(new OrderNote { Note = "Thank You Invoice Email Sent", CreatedOn = DateTime.Now});

                    //set the status as paid. Simplistic, but will work for now
                    order.Status = "paid";
                    //flush it since we need the new id
                    db.SaveChanges();
                    //save it down
                    return RedirectToAction("Details",
                        new { id = order.OrderId });
                }
        }
开发者ID:YogirajA,项目名称:mvcmusic,代码行数:43,代码来源:OrdersController.cs


示例16: AddressAndPayment

        public async Task<ActionResult> AddressAndPayment(FormCollection values)
        {
            var order = new Order();
            TryUpdateModel(order);

            if (ModelState.IsValid 
                && string.Equals(values["PromoCode"], PromoCode, StringComparison.OrdinalIgnoreCase))
            {
                order.Username = User.Identity.Name;
                order.OrderDate = DateTime.Now;

                _storeContext.Orders.Add(order);

                await ShoppingCart.GetCart(_storeContext, this).CreateOrder(order);

                await _storeContext.SaveChangesAsync();

                return RedirectToAction("Complete", new { id = order.OrderId });
            }

            return View(order);
        }
开发者ID:kaushalp,项目名称:MusicStore,代码行数:22,代码来源:CheckoutController.cs


示例17: AddressAndPayment

        public ActionResult AddressAndPayment(FormCollection values)
        {
            var order = new Order();
            TryUpdateModel(order);

            try
            {
                if (string.Equals(values["PromoCode"], PromoCode, 
                    StringComparison.OrdinalIgnoreCase) == false)
                {
                    return View(order);
                }

                order.Username = User.Identity.Name;
                order.OrderDate = DateTime.Now;

                //Process the order
                var cart = ShoppingCartFinder.FindShoppingCart();
                cart.CreateOrder(order);

                var soldAlbums = session.Load<Album>(order.Lines.Select(x=>x.Album.Id).ToArray());
                foreach (var soldAlbum in soldAlbums)
                {
                    soldAlbum.CountSold++;
                }

                session.Store(order);
                session.SaveChanges();

                return RedirectToAction("Complete", 
                                        new { id = order.Id });
            }
            catch
            {
                //Invalid - redisplay with errors
                return View(order);
            }
        }
开发者ID:JPT123,项目名称:ravendb,代码行数:38,代码来源:CheckoutController.cs


示例18: CreateOrder

        private void CreateOrder(Order order, List<Cart> cartItems)
        {
            decimal orderTotal = 0;

            foreach (var item in cartItems)
            {
                var album = storeDB.Albums.Find(item.AlbumId);

                var orderDetail = new OrderDetail
                {
                    AlbumId = item.AlbumId,
                    OrderId = order.OrderId,
                    UnitPrice = album.Price,
                    Quantity = item.Count,
                };

                orderTotal += (item.Count * album.Price);

                storeDB.OrderDetails.Add(orderDetail);
            }

            order.Total = orderTotal;
        }
开发者ID:pumaatlarge,项目名称:BookStore,代码行数:23,代码来源:CheckoutApiController.cs


示例19: CreateOrder

        public int CreateOrder(Order order)
        {
            //decimal orderTotal = 0;

            //var cartItems = GetCartItems();

            //// Iterate over the items in the cart, adding the order details for each
            //foreach (var item in cartItems)
            //{
            //    var orderDetail = new OrderDetail
            //    {
            //        AlbumId = item.AlbumId,
            //        OrderId = order.OrderId,
            //        UnitPrice = item.Album.Price,
            //        Quantity = item.Count
            //    };

            //    // Set the order total of the shopping cart
            //    orderTotal += (item.Count * item.Album.Price);

            //    storeDB.OrderDetails.Add(orderDetail);

            //}

            //// Set the order's total to the orderTotal count
            //order.Total = orderTotal;

            //// Save the order
            //storeDB.SaveChanges();

            //// Empty the shopping cart
            //EmptyCart();

            //// Return the OrderId as the confirmation number
            //return order.OrderId;
            return 0;
        }
开发者ID:eiu165,项目名称:crossfit,代码行数:37,代码来源:ShoppingCart.cs


示例20: CreateOrder

        public int CreateOrder(Order order)
        {
            decimal orderTotal = 0;

            var cartItems = GetCartItems();

            // Iterate over the items in the cart, adding the order details for each
            foreach (var item in cartItems)
            {
                var album = _db.Albums.Find(item.AlbumId);
                
                var orderDetail = new OrderDetail
                {
                    Sku = album.Title.ToLower().Replace(" ","-"),
                    Name = album.Title,
                    Discount =0,
                    UnitPrice = album.Price,
                    Quantity = item.Count,
                    
                };

                // Set the order total of the shopping cart
                orderTotal += (orderDetail.LineTotal);

                _db.OrderDetails.Add(orderDetail);

            }

            // Set the order's total to the orderTotal count
            order.Total = orderTotal;

            // Empty the shopping cart
            EmptyCart();

            // Return the OrderId as the confirmation number
            return order.OrderId;
        }
开发者ID:alanmacgowan,项目名称:mvcmusic,代码行数:37,代码来源:ShoppingCart.cs



注:本文中的MvcMusicStore.Models.Order类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# MxitTestApp.UserSession类代码示例发布时间:2022-05-26
下一篇:
C# WorldEditor.WorldEditor类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap