public ActionResult Create(VehicleType_Model MyModel) { if (string.IsNullOrEmpty(MyModel.ID) || Convert.ToInt32(MyModel.ID) == 0) { if (MyTravel_Repository.ManageEntity(MyModel, "Post")) { TempData["Notification"] = Notification_Component.SetNotification((int)Notification_Component.Result.Success, "Data Inserted Successfully!"); } else { TempData["Notification"] = Notification_Component.SetNotification((int)Notification_Component.Result.Info, "Data not Inserted!"); } } else { if (MyTravel_Repository.ManageEntity(MyModel, "Put")) { TempData["Notification"] = Notification_Component.SetNotification((int)Notification_Component.Result.Success, "Data Updated Successfully!"); } else { TempData["Notification"] = Notification_Component.SetNotification((int)Notification_Component.Result.Info, "Data not Updated!"); } } return(RedirectToAction("Index")); }
public bool ManageEntity(VehicleType_Model MyModel, string Action) { bool MyResult = false; try { using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString)) { DynamicParameters MyDynamicParameters = new DynamicParameters(); MyDynamicParameters.Add("@ID", MyModel.ID); MyDynamicParameters.Add("@vName", MyModel.vName); MyDynamicParameters.Add("@Action", Action); MyResult = con.Execute("ProcManageVehicleType", MyDynamicParameters, commandType: CommandType.StoredProcedure) > 0 ? true : false; } } catch (Exception Exc) { Error_Component.ManageError(new Error_DTO { vAction_Type = "Repository", vController = "User_Repository", vAction = "GetEntity_List", vError_Message = Exc.Message, vError_Line = "", vInput_Values = "", vRemarks = "" }); } return(MyResult); }
public ActionResult Edit(string id) { VehicleType_Model MyModel = MyTravel_Repository.GetEntity_List().Where(var => var.ID == id).FirstOrDefault(); MyModel.VehicleTypeList = MyTravel_Repository.GetEntity_List(); return(View("Index", MyModel)); }
// GET: VehicleType public ActionResult Index() { VehicleType_Model MyModel = new VehicleType_Model(); MyModel.VehicleTypeList = MyTravel_Repository.GetEntity_List(); return(View(MyModel)); }