public void UpdateResource(Ticket ticket, int resourceTypeId, int resourceId, string resourceName, int accountId, string resourceCustomData) { var currentResource = ticket.TicketResources.SingleOrDefault(x => x.ResourceTypeId == resourceTypeId); var currentResourceId = currentResource != null ? currentResource.ResourceId : 0; var newResourceName = resourceName; var oldResourceName = currentResource != null ? currentResource.ResourceName : ""; if (currentResource != null && currentResource.ResourceId != resourceId) { var resourceType = _cacheService.GetResourceTypeById(currentResource.ResourceTypeId); _automationService.NotifyEvent(RuleEventNames.ResourceUpdated, new { currentResource.ResourceTypeId, currentResource.ResourceId, ResourceTypeName = resourceType.Name, OpenTicketCount = GetOpenTicketIds(currentResource.ResourceId).Count() - (ticket.Id > 0 ? 1 : 0) }); } ticket.UpdateResource(resourceTypeId, resourceId, resourceName, accountId, resourceCustomData); if (currentResourceId != resourceId) { var resourceType = _cacheService.GetResourceTypeById(resourceTypeId); _automationService.NotifyEvent(RuleEventNames.TicketResourceChanged, new { Ticket = ticket, ResourceTypeId = resourceTypeId, ResourceId = resourceId, ResourceTypeName = resourceType.Name, OldResourceName = oldResourceName, NewResourceName = newResourceName, OrderCount = ticket.Orders.Count }); } }