Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected override bool BeforeSaveEntity(EntityInfo entityInfo)
- {
- // use beforesaveentity for security checks
- var entity = entityInfo.Entity;
- if (entity is tblTransactionImporterDiscounts)
- {
- return !IsSales;
- }
- if (entity is tblTransactions)
- {
- return BeforeSaveTransaction(entity as tblTransactions, entityInfo);
- }
- if (entity is tblEmployees)
- {
- // employee objects can only be changed by admin. basta
- if (!IsAdmin)
- return false;
- // never allow admin to delete himself...
- if (((tblEmployees)entity).IDEmployee == UserId && entityInfo.EntityState == EntityState.Deleted)
- return false;
- if (entityInfo.EntityState == EntityState.Deleted)
- BeforeDeleteEmployees(entity as tblEmployees, entityInfo);
- return true;
- }
- throw new InvalidOperationException("Cannot save entity of unknown type");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement