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"); }
public DetailViewModel(OrderDetail detail) { Detail = detail; _service = new OrderService(); }
public OrderActionService(OrderService _Service) { Service = _Service; }
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"); }
// // 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); } }
// // 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"); }
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"); }