Example #1
0
        public ActionResult CreateOrderDetail(int id, CreateOrderDetail orderDetail)
        {
            if (ModelState.IsValid)
            {
                using (MySqlConnection conn = DBUtils.GetConnection())
                {
                    OrderDetails orderdet = new OrderDetails();

                    orderdet.OrderID   = orderDetail.OrderID;
                    orderdet.ProductID = orderDetail.ProductID;
                    orderdet.Quantity  = orderDetail.Quantity;
                    orderdet.UnitPrice = orderDetail.UnitPrice;
                    orderdet.Discount  = 0;

                    OrderDetailsRepository orderRepo = new OrderDetailsRepository(conn);
                    orderRepo.Save(orderdet);
                }

                return(RedirectToAction("OrderDetails", new { id = orderDetail.OrderID }));
            }

            using (MySqlConnection conn = DBUtils.GetConnection())
            {
                DisplayProductRepository product = new DisplayProductRepository(conn);
                orderDetail.ProductList = product.GetAll().ToList <DisplayProduct>();
            }

            return(View(orderDetail));
        }
Example #2
0
        // GET: Order/Create
        public ActionResult CreateOrderDetail(int id)
        {
            CreateOrderDetail order = new CreateOrderDetail();

            order.OrderID = id;
            using (MySqlConnection conn = DBUtils.GetConnection())
            {
                DisplayProductRepository product = new DisplayProductRepository(conn);
                order.ProductList = product.GetAll().ToList <DisplayProduct>();
            }

            return(View(order));
        }
Example #3
0
        public ActionResult EditGameInOrder(CreateOrderDetail orderDetail, string username)
        {
            if (ModelState.IsValid)
            {
                var orderDetailDto = Mapper.Map <OrderDetailDTO>(orderDetail);
                _service.UpdateOrder(username, orderDetailDto, false);
                return(RedirectToAction("Order"));
            }
            var game = _gameService.GetByKey(orderDetail.GameKey);

            orderDetail.Price        = game.Price;
            orderDetail.UnitsInStock = game.UnitsInStock;
            return(PartialView("EditGameInOrder", orderDetail));
        }
Example #4
0
 public ActionResult AddGameToOrder(CreateOrderDetail orderDetail)
 {
     if (ModelState.IsValid)
     {
         _service.AddOrderDetail(orderDetail.GameKey, orderDetail.Quantity, orderDetail.Username, false);
         return(RedirectToAction("Order", "Orders", orderDetail.Username));
     }
     orderDetail.AllGames = new List <GameViewModel>();
     Mapper.Map <IEnumerable <GameViewModel> >(_gameService.GetAll(false))
     .ForEach(
         x =>
         orderDetail.AllGames.Add(new GameViewModel()
     {
         Key          = x.Key,
         Name         = x.Name,
         UnitsInStock = x.UnitsInStock,
         Price        = x.Price
     }));
     return(PartialView("AddGameToOrder", orderDetail));
 }
Example #5
0
        public ActionResult AddGameToOrder(string username)
        {
            var orderDetail = new CreateOrderDetail
            {
                Id       = Guid.NewGuid().ToString(),
                AllGames = new List <GameViewModel>(),
                Username = username,
                Quantity = 1
            };

            Mapper.Map <IEnumerable <GameViewModel> >(_gameService.GetAll(false))
            .ForEach(
                x =>
                orderDetail.AllGames.Add(new GameViewModel()
            {
                Key          = x.Key,
                Name         = x.Name,
                UnitsInStock = x.UnitsInStock,
                Price        = x.Price
            }));
            return(View(orderDetail));
        }