public ActionResult Edit(VehicleModel model) { model.OrganizationId = 1; model.CreatedDate = System.DateTime.Now; model.CreatedBy = UserID.ToString(); var repo = new VehicleModelRepository(); bool isexists = repo.IsFieldExists(repo.ConnectionString(), "VehicleModel", "VehicleModelName", model.VehicleModelName, "VehicleModelId", model.VehicleModelId); if (!isexists) { var result = new VehicleModelRepository().UpdateVehicleModel(model); if (result.VehicleModelId > 0) { TempData["Success"] = "Updated Successfully!"; TempData["RefNo"] = result.VehicleModelRefNo; return(RedirectToAction("Create")); } else { TempData["error"] = "Oops!!..Something Went Wrong!!"; TempData["RefNo"] = null; return(View("Create", model)); } } else { TempData["error"] = "This Name Alredy Exists!!"; TempData["RefNo"] = null; return(View("Create", model)); } }
public ActionResult Create(VehicleModel model) { var repo = new VehicleModelRepository(); bool isexists = repo.IsFieldExists(repo.ConnectionString(), "VehicleModel", "VehicleModelName", model.VehicleModelName, null, null); if (!isexists) { var result = new VehicleModelRepository().InsertVehicleModel(model); if (result.VehicleModelId > 0) { TempData["Success"] = "Added Successfully!"; TempData["RefNo"] = result.VehicleModelRefNo; return(RedirectToAction("Create")); } else { TempData["error"] = "Oops!!..Something Went Wrong!!"; TempData["RefNo"] = null; return(View("Create", model)); } } else { TempData["error"] = "This Name Alredy Exists!!"; TempData["RefNo"] = null; return(View("Create", model)); } }