/// <summary>
 /// allows for the placing of new orders from the customer profile
 /// </summary>
 /// <param name="newOrder"></param>
 /// <returns></returns>
 public ActionResult PlaceOrder(OrderCRVM newOrder)
 {
     if (ModelState.IsValid)
     {
         newOrder.CustomerId = _partsBL.GetCustomerByNumber(newOrder.CustomerNumber).Id;
         newOrder.LocaitonId = _partsBL.GetLocationByName(newOrder.LocationName).Id;
         Product p = new Product();
         p = _partsBL.GetProductByName(newOrder.ProductName);
         newOrder.Total     = p.Price * newOrder.Quantitiy;
         newOrder.ProductId = p.Id;
         try
         {
             _partsBL.AddOrder(_mapper.cast2Order(newOrder));
             return(RedirectToAction(nameof(Index)));
         }
         catch
         {
             return(View());
         }
     }
     else
     {
         return(View());
     }
 }
Beispiel #2
0
        public void CreateOrder()
        {
            double  total;
            Order   newOrder = new Order();
            Product P        = new Product();

            // Item newItem = new Item();

            Console.WriteLine("Enter Location Name");
            currentLocation = SearchForLocation(Console.ReadLine());
            // while(true)
            // {
            //     if (currentLocation.Id == null)
            //     {

            //         break;
            //     }
            // }
            newOrder.Location = currentLocation;

            //while(true ){
            Console.WriteLine("Add product would you like to order[0 to exit]");
            SearchForProduct();
            Console.WriteLine("How many would you like");
            I.Quantity    = (int.Parse(Console.ReadLine()));
            newOrder.Item = I;
            // }
            total = I.Product.Price * I.Quantity;
            // I.LFK = currentLocation.Id;

            // Console.WriteLine("Enter Order total");
            newOrder.Total       = total;
            newOrder.Customer    = currentCustomer;
            newOrder.Customer.Id = currentCustomer.Id;
            newOrder.CFK         = currentCustomer.Id;

            //Console.WriteLine($"q={I.Quantity}\tPFK={I.PFK}\tOID={I.OID}");
            _storeBL.AddOrder(newOrder);
            Console.WriteLine(newOrder.ToString());

            // I.OID = (int)newOrder.Id;
            //_storeBL.AddIO(I);
        }