Base solution for your next web application

Activities of "reddogaw"

Hi,

I need to locate all users that have a specific permission (either via their role or directly) in order to send them a targeted notification.

Can you think of any easy way to achieve this?

Thanks!

To answer my own question... I just spotted the UnitOfWorkManager.Begin() overload that allows us to pass in a UnitOfWorkOptions instance which could then be extended with my own properties...

However, it's important to note that the operation must mark itself with the [UnitOfWork] attribute set to IsDisabled = true.

public class ExtendedUnitOfWorkOptions : UnitOfWorkOptions
    {
        public ExtendedUnitOfWorkOptions()
        {
            UpdateLastModified = true;
        }

        public bool UpdateLastModified { get; set; }
    }

Then in my DbContext I can override SetModificationAuditProperties() function:

protected override void SetModificationAuditProperties(DbEntityEntry entry, long? userId)
        {
            var isEnabled = true;
            if (CurrentUnitOfWorkProvider != null && CurrentUnitOfWorkProvider.Current != null)
            {
                var uow = CurrentUnitOfWorkProvider.Current;
                if (uow.Options is ExtendedUnitOfWorkOptions)
                {
                    isEnabled = (uow.Options as ExtendedUnitOfWorkOptions).UpdateLastModified;
                }
            }

            if (isEnabled)
            {
                base.SetModificationAuditProperties(entry, userId);
            }
        }

Which can be consumed within my special operation like:

[UnitOfWork(IsDisabled = true)]
        public virtual async Task SignOffIncident(IdInput input)
        {
            using (var unitOfWork = UnitOfWorkManager.Begin(new ExtendedUnitOfWorkOptions() { UpdateLastModified = false }))
            {
                var incident = await _incidentManager.FindByIdAsync(input.Id);
                incident.SignOffTime = Clock.Now;
                incident.SignOffUserId = AbpSession.GetUserId();
                await _incidentManager.UpdateAsync(incident);

                unitOfWork.Complete();
            }
        }

I have a particular service operation that needs to update an entity but NOT update the LastModificationTime & User fields.

Any ideas on how this might be best achieved?

I had considered possibly overriding the "SetModificationAuditProperties" in my DB Context and detecting the context of the operation (presumably via the current Unit Of Work somehow). My operation would then need to explicity use a different unit of work manager. Would that be possible? If so, how do I replace the Current UoW?

Hi,

I'm just getting started with Boilerplate, so apologies for my naivety.

My stored entity has a number of properties whose values are driven by a list of values. I want this list of values to be configurable via the database and I want them to support localization.

For example, a "person" has a "hair colour" which must be one of a number of values (e.g. blonde, brown, black, red).

How do I model the persisted "person" entity to store the value?

From my reading, I think that I could create a new localization source for each of these lists of data. This will enable me to use GetAllStrings for the localization source. However, then what should I store into my database? Maybe, the localization source/key combo?

Also, I think a drawback of that approach is that the "GetAllStrings" operation from LocalizedSource that are not explicitly orderable as they are set up more as a dictionary style.

Can you advise if there is an "in the box" (or at least an "on the path") approach to this...

Showing 1 to 4 of 4 entries