Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pawelgradecki/5e6aede7ea95b2d3fdb46ac936844aab to your computer and use it in GitHub Desktop.
Save pawelgradecki/5e6aede7ea95b2d3fdb46ac936844aab to your computer and use it in GitHub Desktop.
Account plugin early bound
public class CalculateTotalAmountAccountPlugin : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
var context = serviceProvider.GetService(typeof(IPluginExecutionContext)) as IPluginExecutionContext;
var serviceFactory = serviceProvider.GetService(typeof(IOrganizationServiceFactory)) as IOrganizationServiceFactory;
var service = serviceFactory.CreateOrganizationService(context.UserId);
var account = (context.InputParameters["Target"] as Entity).ToEntity<Account>();
account.new_totalsum = account.new_netamount + account.new_margin;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment