public ActionResult EditVehicleVehicle([Bind(Include = "Id,RelationshipTypeId,DateStart,DateEnd,VehicleId,Vehicle2Id")] VehicleVehicleRel vehicleVehicleRel) { if (ModelState.IsValid) { _vehicleRepo.InsertOrUpdateVehicleVehicle(vehicleVehicleRel); _vehicleRepo.Save(); return(RedirectToAction("Details", "Vehicles", new { id = vehicleVehicleRel.VehicleId })); } return(View()); }
public void InsertOrUpdate(VehicleVehicleRel VehicleVehiclerel) { if (VehicleVehiclerel.Id == default(int)) { // New entity context.VehicleVehicleRels.Add(VehicleVehiclerel); } else { // Existing entity context.Entry(VehicleVehiclerel).State = EntityState.Modified; } }
public void InsertOrUpdateVehicleVehicle(VehicleVehicleRel vehicleVehicleRel) { if (vehicleVehicleRel.Id == default(int)) { // New entity _ctx.VehicleVehicleRels.Add(vehicleVehicleRel); } else { // Existing entity _ctx.Entry(vehicleVehicleRel).State = EntityState.Modified; } }
public ActionResult CreateVehicleVehicle(int vehicleId) { var approvalStatusId = _lookupRepo.GetApprovalStatuses().SingleOrDefault(p => p.Name.Equals("New")).Id; var vehicleVehicleRel = new VehicleVehicleRel { VehicleId = vehicleId, ApprovalStatusId = approvalStatusId, DateStart = DateTime.Now, Vehicle2 = new Vehicle() }; ViewBag.PossibleRelationshipTypes = _lookupRepo.GetRelationshipTypes().Where(x => x.ObjectFrom.Equals("Vehicle") && x.ObjectTo.Equals("Vehicle")).OrderBy(x => x.SortOrder); ViewBag.VehicleId = vehicleId; ViewBag.Vehicle2Id = -1; if (Request.IsAjaxRequest()) { return(PartialView("_CreateOrEditVehicleVehicle", vehicleVehicleRel)); } return(View()); }