public Result <ServiceResponse> EditTenant(EditTenantRequest request) { return(this.UseConnection("Default", connection => { request.CheckNotNull(); var perminsion = Dependency.Resolve <IPermissionService>(); var grantor = new TransientGrantingPermissionService(perminsion); grantor.GrantAll(); try { var user = (UserDefinition)Serenity.Authorization.UserDefinition; var tenant = new TenantRow(); tenant.TenantId = user.TenantId; if (request.TenantName.IsEmptyOrNull()) { throw new ArgumentNullException("name"); } tenant.TenantName = request.TenantName; tenant.TenantWebSite = request.TenantWebSite; if (!request.TenantImage.IsNullOrEmpty()) { tenant.TenantImage = request.TenantImage; } tenant.OverrideUsersEmailSignature = request.OverrideUsersEmailSignature; tenant.TenantEmailSignature = request.TenantEmailSignature; var saveRequest = new SaveRequest <TenantRow>() { Entity = tenant }; var uow = new UnitOfWork(connection); new TenantRepository().Update(uow, saveRequest); uow.Commit(); UserRetrieveService.RemoveCachedUser(user.UserId, user.Username); } finally { grantor.UndoGrant(); } return new ServiceResponse(); })); }
public RetrieveResponse <MyRow> Retrieve(IDbConnection connection, RetrieveRequest request) { if (request.EntityId.ToString() == Authorization.UserId) { var perminsion = Dependency.Resolve <IPermissionService>(); var grantor = new TransientGrantingPermissionService(perminsion); grantor.GrantAll(); try { return(new MyRepository().Retrieve(connection, request)); } finally { grantor.UndoGrant(); } } return(new MyRepository().Retrieve(connection, request)); }