/// <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 SearchForProduct()
        {
            Console.WriteLine("Enter item Name");
            Product foundProduct = _storeBL.GetProductByName(Console.ReadLine());

            if (foundProduct == null)
            {
                Console.WriteLine("no such Product exists try again");
            }
            I.Product = foundProduct;
            I.PFK     = foundProduct.Id;
            Console.WriteLine(foundProduct.ToString());
        }
Beispiel #3
0
 // GET: ProductController/Delete/5
 public ActionResult Delete(string name)
 {
     _partsBL.DeleteProduct(_partsBL.GetProductByName(name));
     return(RedirectToAction(nameof(Index)));
 }