public IActionResult Index(Parcels parcel_data) { Customers customer = db.customer.Where(x => x.customer_id == parcel_data.customer_id).FirstOrDefault(); if (customer == null) { ViewBag.msg = "Customer not found"; } else { parcel_data.customer_id = 1; parcel_data.consignee = "sdds"; parcel_data.consignee_address = "sdsds"; parcel_data.destination = "sdsada"; parcel_data.phone = "2232"; parcel_data.weight = 1; parcel_data.cod = 1; db.parcel.Add(parcel_data); db.SaveChanges(); Parcels parcel_latest = db.parcel.Where(x => x.customer_id == parcel_data.customer_id && x.consignee == parcel_data.consignee && x.destination == parcel_data.destination).OrderByDescending(x => x.cid).FirstOrDefault(); Booking_Statuss bs = new Booking_Statuss(); bs.booking_id = parcel_latest.cid; bs.status = 1; bs.date = DateTime.Now; bs.time = DateTime.Now.ToShortTimeString(); db.booking_status.Add(bs); db.SaveChanges(); ViewBag.msg = "Booking Number: " + parcel_latest.cid; } return(View()); }
public IActionResult Index(Booking_Statuss b) { DateTime d = DateTime.Now; b.date = d; b.time = DateTime.Now.ToShortTimeString(); db.booking_status.Add(b); db.SaveChanges(); return(RedirectToAction("Index", "Track", new { id = b.booking_id })); }