Reputation:
This is the error I'm currently getting
I'll add more screenshots of my delete code that it connects to below:
The string id connects it to the specific record that I click delete next to.
Below is the code in the CommonServices.cs:
public bool DeleteEmployeeRecord(new_EmploymentHubCollegues employmentHubCollegue)
{
CrmServiceClient serviceClient = GetCrmServiceClient();
serviceClient.Delete(employmentHubCollegue);
return true;
}
Below is the code in my controller:
public ActionResult DeleteEmployee(string id)
{
ViewBag.Message = "Your application edit page.";
new_EmploymentHubCollegues Delete = _Service.GetCollegue(id);
return View(Delete);
}
[HttpPost]
public ActionResult DeleteEmployee(new_EmploymentHubCollegues Delete)
{
ViewBag.Message = "Your application edit page.";
if (_Service.DeleteEmployeeRecord(Delete) == true)
{
}
return View(Delete);
}
below is the code in my services.cs
bool DeleteEmployeeRecord(new_EmploymentHubCollegues employmentHubCollegue);
The code I have above works when it comes to updating or adding a new record (obviously different variable names etc.). I'm just not sure how to do the delete function. Maybe it doesn't need to be a bool ?
Upvotes: 0
Views: 69
Reputation: 196
you need to fulfill CrmServiceClient.Delete method signature -> it accepts two parameters, not one. First one is entity logical name and second one is the ID of the entity.
I guess that new_EmploymentHugCollegues is early bound entity generated via crmsvcutil.exe, so you can easily modify your method to this:
public bool DeleteEmployeeRecord(new_EmploymentHubCollegues employmentHubCollegue)
{
CrmServiceClient serviceClient = GetCrmServiceClient();
serviceClient.Delete(employmentHubCollegue.LogicalName, employmentHubCollegue.Id);
return true;
}
Upvotes: 1