public ActionResult EditDriver(DSRCManagementSystem.Models.ManageDrivers Values) { DSRCManagementSystem.Models.ConvertByte objcb = new Models.ConvertByte(); var picture = objcb.ConvertToBytes(Values.Pictures); var Doc = objcb.ConvertToBytes(Values.Documents); var UpdateDriver = db.Drivers.Where(o => o.DriverId == Values.DriverId).Select(x => x).FirstOrDefault(); UpdateDriver.DriverId = Values.DriverId; UpdateDriver.First_Name = Values.First_Name; UpdateDriver.Last_Name = Values.Last_Name; UpdateDriver.DOB = Values.DOB; UpdateDriver.Gender = Values.Gender; UpdateDriver.Driver_Licence_No = Values.Driver_Licence_No; UpdateDriver.Driver_Licence_Expire_Date = Values.Driver_Licence_Expire_Date; UpdateDriver.DriverType_Id = Values.DriverType_Id; UpdateDriver.Email_Id = Values.Email_Id; UpdateDriver.Contact_No = Values.Contact_No; UpdateDriver.Blood_Group = Values.Blood_Group; UpdateDriver.Communication_Address = Values.Communication_Address; UpdateDriver.Driver_Batch_No = Values.Driver_Batch_No; UpdateDriver.Document_Proof = Doc; UpdateDriver.Photo = picture; db.SaveChanges(); return(RedirectToAction("Manage", "ManageDrivers")); //return Json("true", JsonRequestBehavior.AllowGet); }
public ActionResult addnew(DSRCManagementSystem.Models.ManageDrivers objmanage) { var DriverName = db.Master_DriverType.ToList(); ViewBag.DriverTypeList = new SelectList(DriverName, "DriverType_Id", "DriverType"); var BloodGroup = db.Master_BloodGroup.ToList(); ViewBag.BloodGroupList = new SelectList(BloodGroup, "BloodGroupID", "BloodGroupName"); var Gender = db.Master_Gender.ToList(); ViewBag.GenderList = new SelectList(Gender, "GenderID", "GenderName"); DSRCManagementSystem.Models.ConvertByte objcb = new Models.ConvertByte(); var picture = objcb.ConvertToBytes(objmanage.Pictures); var Doc = objcb.ConvertToBytes(objmanage.Documents); if (ModelState.IsValid) { var driver = db.Drivers.CreateObject(); driver.First_Name = objmanage.First_Name; driver.Last_Name = objmanage.Last_Name; driver.DOB = objmanage.DOB; driver.Gender = objmanage.Gender; driver.Driver_Licence_No = objmanage.Driver_Licence_No; driver.Driver_Licence_Expire_Date = objmanage.Driver_Licence_Expire_Date; driver.DriverType_Id = objmanage.DriverType_Id; driver.Email_Id = objmanage.Email_Id; driver.Contact_No = objmanage.Contact_No; driver.Blood_Group = objmanage.Blood_Group; driver.Communication_Address = objmanage.Communication_Address; driver.Driver_Batch_No = objmanage.Driver_Batch_No; driver.IsActive = true; driver.Photo = picture; driver.Document_Proof = Doc; db.Drivers.AddObject(driver); db.SaveChanges(); } return(Json("Success", JsonRequestBehavior.AllowGet)); //return RedirectToAction("Manage", "ManageDrivers"); }