Ejemplo n.º 1
0
        public ActionResult AddOrder(OrdersAddViewModel order)
        {
            using (var rdbc = new RavenDbConnection(_rdcm))
            {
                var orderService = new OrderService(rdbc);
                var clientService = new ClientService(rdbc);
                var client = clientService.GetClient(order.ClientId);

                var newOrder = new Order
                {
                    ClientId = client.Id,
                    ClientFirstName = client.FirstName,
                    ClientLastName = client.LastName,
                    ClientCountry = client.Country,
                    Payments = new List<Payment>
                    {
                        new Payment
                        {
                            Amount = order.PaymentAmount,
                            Id = order.PaymentId
                        }
                    },
                    Products = new List<Product>
                    {
                        new Product
                        {
                            Name = order.ProductName,
                            Price = order.ProductPrice
                        }
                    },
                    TimeOfOrder = DateTime.Now
                };
                orderService.AddOrder(newOrder);
            }
            return RedirectToAction("Index", "Home");
        }
Ejemplo n.º 2
0
 public DetailViewModel(OrderDetail detail)
 {
     Detail = detail;
     _service = new OrderService();
 }
 public OrderActionService(OrderService _Service)
 {
     Service = _Service;
 }
Ejemplo n.º 4
0
 public ActionResult AddPayment(AddPaymentViewModel newPayment)
 {
     using (var rdbc = new RavenDbConnection(_rdcm))
     {
         var orderService = new OrderService(rdbc);
         orderService.AddPayment(newPayment.OrderId, newPayment.PaymentId, newPayment.PaymentAmount);
     }
     return RedirectToAction("Index", "Orders");
 }
Ejemplo n.º 5
0
        //
        // GET: /Orders/
        public ActionResult Index(int pageNumber = 1, int itemsPerPage = 10)
        {
            if (pageNumber < 1) pageNumber = 1;
            if (itemsPerPage < 1) itemsPerPage = 1;

            using (var rdbc = new RavenDbConnection(_rdcm))
            {
                var orderService = new OrderService(rdbc);
                var orders = orderService.GetOrders(pageNumber, itemsPerPage);
                var viewModel = new OrdersHomeViewModel
                {
                    CurrentPage = pageNumber,
                    ItemsPerPage = itemsPerPage,
                    Orders = orders.ToList()
                };
                return View(viewModel);
            }
        }
Ejemplo n.º 6
0
 //
 // GET: /Orders/DeleteOrder?orderId=1
 public ActionResult DeleteOrder(string orderId)
 {
     using (var rdbc = new RavenDbConnection(_rdcm))
     {
         var orderService = new OrderService(rdbc);
         orderService.DeleteOrder(orderId);
     }
     return RedirectToAction("Index");
 }
Ejemplo n.º 7
0
 public ActionResult AddProduct(AddProductViewModel newProduct)
 {
     using (var rdbc = new RavenDbConnection(_rdcm))
     {
         var orderService = new OrderService(rdbc);
         orderService.AddProduct(newProduct.OrderId, newProduct.ProductName, newProduct.ProductPrice);
     }
     return RedirectToAction("Index", "Orders");
 }