示例#1
0
 public ActionResult Create([Bind(Include = "Branch_code,Branch_pin,Branch_address,Branch_name")] Branch branch)
 {
     if (ModelState.IsValid)
     {
         db.Branches.Add(branch);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(branch));
 }
示例#2
0
        public ActionResult Create([Bind(Include = "Customer_id,Customer_name,password,Address")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                db.Customers.Add(customer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(customer));
        }
 public ActionResult Create([Bind(Include = "Courier_id,Weight,Courier_type")] Courier courier)
 {
     if (ModelState.IsValid)
     {
         courier.Courier_id = (int)TempData["booking"];
         db.Couriers.Add(courier);
         db.SaveChanges();
         return(RedirectToAction("Index", "Bookings"));
     }
     else
     {
         return(Content("Invalid model"));
     }
 }
示例#4
0
        public ActionResult Create([Bind(Include = "Booking_id,From_add,Amount,Destination,Branch_code,Customer_id,Distance")] Booking booking)
        {
            if (ModelState.IsValid)
            {
                db.Bookings.Add(booking);
                db.SaveChanges();
                TempData["courier_id"] = booking.Booking_id;
                return(RedirectToAction("Create", "Couriers"));
            }

            ViewBag.Branch_code = new SelectList(db.Branches, "Branch_code", "Branch_address", booking.Branch_code);
            ViewBag.Booking_id  = new SelectList(db.Couriers, "Courier_id", "Courier_type", booking.Booking_id);
            ViewBag.Customer_id = new SelectList(db.Customers, "Customer_id", "Customer_name", booking.Customer_id);
            return(View(booking));
        }