本文整理汇总了C#中Services.IsEntity方法的典型用法代码示例。如果您正苦于以下问题:C# Services.IsEntity方法的具体用法?C# Services.IsEntity怎么用?C# Services.IsEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Services
的用法示例。
在下文中一共展示了Services.IsEntity方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Before
public void Before(Services.tmp.EntityOperation operation, EntityOperationContext context)
{
if (operation.IsEntity(Payment.ENTITY) && operation is EntityUpdate)
{
var update = operation as EntityUpdate;
if (update.IsCreate())
{
List<int> usersToAttach = new List<int>();
foreach (var attach in update.RelationUpdates.Where(ru => ru.Operation == Services.tmp.RelationOperation.Attach))
{
var em = _domainService.Domain.Entities[attach.Entity];
var customerRel = em.Relations[em.Name, User.ENTITY, Payment.ROLE_CUSTOMER];
if (customerRel != null && customerRel.TypeFor(User.ENTITY) == RelationType.OneToMany)
{
var q = new EntityQuery2(User.ENTITY);
q.WhereRelated(new RelationQuery(em.Name, customerRel.Role, attach.Id.Value));
var cust = _repository.Read(q);
if (cust != null)
usersToAttach.Add(cust.Id);
}
}
foreach (var id in usersToAttach)
{
update.Attach(User.ENTITY, Payment.ROLE_CUSTOMER, id);
}
}
}
}
示例2: Before
public void Before(Services.tmp.EntityOperation operation, EntityOperationContext context)
{
if (operation.IsEntity(NbuLibrary.Core.Domain.File.ENTITY) && operation is EntityUpdate)
{
var update = operation as EntityUpdate;
if (update.IsCreate())
{
var access = update.Attach(NbuLibrary.Core.Domain.User.ENTITY, Roles.Access, _securityService.CurrentUser.Id);
access.Set("Type", FileAccessType.Owner);
}
else
{
var accessUpdates = update.GetMultipleRelationUpdates(User.ENTITY, Roles.Access);
if (accessUpdates != null)
foreach (var ac in accessUpdates)
{
if (ac.Operation == RelationOperation.Detach)
continue;
if (ac.ContainsProperty("Type") && ac.Get<FileAccessType>("Type") == FileAccessType.Token)
ac.Set("Token", Guid.NewGuid());//TODO: token based file access
}
}
}
else if (operation.IsEntity(NbuLibrary.Core.Domain.File.ENTITY) && operation is EntityDelete)
{
var file = _fileService.GetFile(operation.Id.Value);
context.Set<NbuLibrary.Core.Domain.File>(CTXKEY_FILEDELETION, file);
}
}
示例3: Inspect
public InspectionResult Inspect(Services.tmp.EntityOperation operation)
{
if (operation.IsEntity(Payment.ENTITY) && operation is EntityUpdate)
{
var update = operation as EntityUpdate;
if (update.IsCreate() && !update.ContainsProperty("Status"))
return InspectionResult.Allow; //TODO-Finance: Everyone is allowed to create payments
else if (_securityService.HasModulePermission(_securityService.CurrentUser, FinanceModule.Id, Permissions.Approve))
return InspectionResult.Allow;
}
return InspectionResult.None;
}
示例4: After
public void After(Services.tmp.EntityOperation operation, EntityOperationContext context, EntityOperationResult result)
{
if (operation.IsEntity(NbuLibrary.Core.Domain.File.ENTITY)
&& operation is EntityDelete
&& result.Success)
{
var file = context.Get<NbuLibrary.Core.Domain.File>(CTXKEY_FILEDELETION);
if (file != null)
_fileService.DeleteFileContent(Guid.Parse(file.ContentPath));
}
}