public ActionResult AddDriver(driverdetail drdt) { using (DeliveryEntities1 db = new DeliveryEntities1()) if (ModelState.IsValid) { //db.driverdetails.Add(drdt); //db.SaveChanges(); string exist = Convert.ToString((from Data in db.driverdetails where Data.mobileno.Trim().ToLower() == drdt.mobileno.Trim().ToLower() select Data.id).FirstOrDefault()); if (Convert.ToInt32(exist) == 0) { driverdetail Data_Insert = new driverdetail(); //Random r = new Random(); // int rid = r.Next(0, 999999); // // Data_Insert.driverid = drdt.driverid; var guid = Guid.NewGuid(); //Data_Insert.drivername = drdt.drivername; Data_Insert.age = drdt.age; //Data_Insert.mobileno = ord.mobileno; Data_Insert.driverid = guid; Data_Insert.drivername = drdt.drivername; Data_Insert.address = drdt.address; Data_Insert.familyno = drdt.familyno; Data_Insert.mobileno = drdt.mobileno; Data_Insert.vehicleno = drdt.vehicleno; Data_Insert.relation = drdt.relation; Data_Insert.bankname = drdt.bankname; Data_Insert.acno = drdt.acno; Data_Insert.branchname = drdt.branchname; Data_Insert.bgroup = drdt.bgroup; Data_Insert.familyno = drdt.familyno; Data_Insert.licanceno = drdt.licanceno; Data_Insert.ifsccode = drdt.ifsccode; Data_Insert.residenceno = drdt.residenceno; //Data_Insert.postalcode = drdt.postalcode; Data_Insert.isactive = true; db.driverdetails.Add(drdt); db.SaveChanges(); return(RedirectToAction("Dashboard", "Login")); } else { return(RedirectToAction("Dashboard", "Login")); } } return(View()); }
public ActionResult Delete(order_master order) { using (DeliveryEntities1 db = new DeliveryEntities1()) if (ModelState.IsValid) { string exist = Convert.ToString((from Data in db.order_master where Data.mobileno.Trim().ToLower() == order.mobileno.Trim().ToLower() select Data.id).FirstOrDefault()); if (Convert.ToInt32(exist) == 0) { // order_master Data_Insert = new order_master(); // //Random r = new Random(); // // int rid = r.Next(0, 999999); // // Data_Insert.driverid = drdt.driverid; // Data_Insert.mobileno = order.mobileno; // // Data_Insert.pickupperson = ord.pickupperson; // // Data_Insert.mobileno = ord.mobileno; // // Data_Insert.pickupcontact = ord.pickupcontact; // Data_Insert.pickupitem = order.pickupitem; // // Data_Insert.deliverycontact = ord.deliverycontact; // // Data_Insert.pickupaddress = ord.pickupaddress; // // Data_Insert.deliveryaddress = ord.deliveryaddress; // // Data_Insert.pickupmessage1 = ord.pickupmessage1; // // Data_Insert.billingtype = ord.billingtype; // // Data_Insert.billto = ord.billto; // Data_Insert.deliverycharge = order.deliverycharge; // // Data_Insert.pob = ord.pob; // // Data_Insert.tocollect = ord.tocollect; // // Data_Insert.orderdate = ord.orderdate; // Data_Insert.deliverydate = order.deliverydate; // // Data_Insert.pickuparea = ord.pickuparea; // // Data_Insert.deliveryarea = ord.deliveryarea; // // Data_Insert.postalcode = drdt.postalcode; // // Data_Insert.isactive = true; // db.SaveChanges(); // return RedirectToAction("ViewOrder", "Order"); order.isactive = false; db.Entry(order).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("ViewOrder")); } else { return(RedirectToAction("Dashboard", "Login")); } } return(View()); }