public ActionResult CreateVehicleComment(int vehicleId) { var comment = new VehicleComment() { VehicleId = vehicleId }; return(PartialView("_CreateOrEditVehicleComment", comment)); }
public ActionResult EditVehicleComment(VehicleComment vehiclecomment) { if (ModelState.IsValid) { _commentRepo.InsertOrUpdateVehicleComments(vehiclecomment); _commentRepo.Save(); return(new HttpStatusCodeResult(HttpStatusCode.OK)); } return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); }
public void InsertOrUpdateVehicleComments(VehicleComment vehiclecomment) { if (vehiclecomment.Id == default(int)) { // New entity context.VehicleComments.Add(vehiclecomment); } else { // Existing entity context.Entry(vehiclecomment).State = EntityState.Modified; } }