Beispiel #1
0
        public static ChangeTracker UpdateData(this ChangeTracker changeTracker, ISessionApp appSession)
        {
            foreach (var entry in changeTracker.Entries().Where(entry => entry.Entity is EntityBase && entry.State != EntityState.Unchanged))
            {
                var date = DateTime.UtcNow.RemoverMilisSegundos();

                entry.Property("IdUsuarioAlteracao").CurrentValue = appSession.GetUserId();
                entry.Property("DataAlteracao").CurrentValue      = date;

                if (entry.State == EntityState.Added)
                {
                    entry.Property("IdUsuarioInclusao").CurrentValue = appSession.GetUserId();
                    entry.Property("DataInclusao").CurrentValue      = date;
                }
                else if (entry.State == EntityState.Modified)
                {
                    entry.Property("IdUsuarioInclusao").IsModified = false;
                    entry.Property("DataInclusao").IsModified      = false;

                    entry.Property("IdUsuarioAlteracao").CurrentValue = appSession.GetUserId();
                    entry.Property("DataAlteracao").CurrentValue      = DateTime.UtcNow.RemoverMilisSegundos();
                }
            }

            return(changeTracker);
        }
 public ProdutoController(ISessionApp appSession,
                          INotificationService notificador,
                          IMapper mapper,
                          IProdutoService produtoService,
                          IProdutoRepository produtoRepository) : base(notificador, appSession)
 {
     _produtoRepository = produtoRepository;
     _produtoService    = produtoService;
     _mapper            = mapper;
 }
 public AuthenticationController(ISessionApp appSession,
                                 INotificationService notificador,
                                 IMapper mapper,
                                 IAuthenticationFacade authenticationFacade,
                                 IAuthenticationService authenticationService) : base(notificador, appSession)
 {
     _mapper = mapper;
     _authenticationFacade  = authenticationFacade;
     _authenticationService = authenticationService;
 }
Beispiel #4
0
        protected MainController(INotificationService notificador,
                                 ISessionApp appSession)
        {
            _notificador = notificador;
            _appSession  = appSession;

            if (appSession.IsAuthenticated())
            {
                UsuarioId          = appSession.GetUserId();
                UsuarioAutenticado = true;
            }
        }
 public GeekStoreDbContext(DbContextOptions <GeekStoreDbContext> options, ISessionApp appSession) : base(options)
 {
     _appSession = appSession;
 }