예제 #1
0
        public ActionResult Create(OrderVM orderVM)
        {
            if (ModelState.IsValid)
            {
                var CustAddress = new customeraddress();
                CustAddress.customer = orderVM.customer;
                CustAddress.address  = orderVM.address;
                if (orderVM.customer.ID == 0)
                {
                    db.customeraddresses.Add(CustAddress);
                    db.SaveChanges();
                }

                order objOrder = orderVM.order;
                objOrder.orderitems = orderVM.orderItems;
                objOrder.OrderNo    = GenerateOrderNo();
                objOrder.AddressID  = CustAddress.address.ID;
                objOrder.CustomerID = CustAddress.customer.ID;
                db.orders.Add(objOrder);
                db.SaveChanges();
                // return RedirectToAction("OrderSuccess", orderVM);
                Session["cart"]  = null;
                Session["count"] = null;
                return(RedirectToAction("Details", "Orders", new { id = objOrder.ID, newOrder = true }));
            }
            return(View(orderVM));
        }
예제 #2
0
 public ActionResult Create(/*[Bind(Include = "ID,CustomerOrganizationName,ContactPersonName,ContactNo,AlternateContactNo,CreatedDate,CreatedBy,ModifiedDate,ModifiedBy")]*/ CustomerVM customerVM)
 {
     if (ModelState.IsValid)
     {
         // db.Customers.Add(customerVM.customer);
         //db.Addresses.Add(customerVM.address);
         var CustAddress = new customeraddress
         {
             customer = customerVM.customer,
             address  = customerVM.address
         };
         //db.Customers.Add(customer);
         db.customeraddresses.Add(CustAddress);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(customerVM));
 }