Example #1
0
 public ProfileService(Bread2BunContext bread2BunContext, IMapper mapper, UserResolverService userResolverService, UserManager <StoreUser> userManager)
 {
     this.context             = bread2BunContext;
     this.mapper              = mapper;
     this.userResolverService = userResolverService;
     this.userManager         = userManager;
 }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CategoryService" /> class.
 /// </summary>
 /// <param name="mapper">The mapper.</param>
 /// <param name="dataContext"></param>
 /// <param name="userResolver"></param>
 /// <exception cref="ArgumentException">Invalid user</exception>
 public CategoryService(IMapper mapper,
                        AppDbContext dataContext,
                        UserResolverService userResolver)
     : base(mapper, dataContext, userResolver)
 {
     this.dataContext = dataContext;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AccountTypeViewModelValidator" /> class.
 /// </summary>
 /// <param name="dbContext">The database context.</param>
 /// <param name="userResolver">The user resolver.</param>
 public AccountTypeViewModelValidator(AppDbContext dbContext, UserResolverService userResolver)
     : base(dbContext, userResolver, 50)
 {
     RuleFor(c => c.Icon)
     .NotEmpty()
     .MaximumLength(50);
 }
Example #4
0
 public ChatHub(IChatService chatService, AllConnectedUsers allConnectedUsers, ISecurityService securityService, UserResolverService userResolverService)
 {
     this.chatService         = chatService;
     this.allConnectedUsers   = allConnectedUsers;
     this.securityService     = securityService;
     this.userResolverService = userResolverService;
 }
Example #5
0
        public async Task <Unit> Handle(RemoveVaultCommand request, CancellationToken cancellationToken)
        {
            if (!VaultService.ValidateVaultPassword(request.VaultId, request.MasterPassword))
            {
                throw new Exception("Podano nie poprawne hasło");
            }
            var vault = await(from v in PmContext.Vaults
                              where v.Username == UserResolverService.GetUsername() && v.Id == request.VaultId
                              select v).FirstOrDefaultAsync();

            if (vault == null)
            {
                throw new Exception();
            }
            var entries = await(from en in PmContext.Entries
                                where en.VaultId == vault.Id
                                select en
                                ).ToListAsync();

            using var trans = PmContext.Database.BeginTransaction();

            PmContext.Entries.RemoveRange(entries);
            PmContext.Vaults.Remove(vault);
            PmContext.SaveChanges();
            await trans.CommitAsync();

            return(Unit.Value);
        }
Example #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TransactionService"/> class.
 /// </summary>
 /// <param name="mapper">The mapper.</param>
 /// <param name="dataContext">The database context</param>
 /// <param name="userResolver">The user resolver service</param>
 public TransactionService(IMapper mapper,
                           AppDbContext dataContext,
                           UserResolverService userResolver)
     : base(mapper, dataContext, userResolver)
 {
     this.mapper      = mapper;
     this.dataContext = dataContext;
 }
Example #7
0
 public TransactionManager(IContextProviderFactory contextProvider, UserResolverService userService, MongoDBManager _mongoManager
                           , AuditLogRepository _auditLogRepository)
 {
     //Context = context;
     Context            = contextProvider.dbContext;
     auditLogRepository = _auditLogRepository;
     mongoManager       = _mongoManager;
     currentUserId      = userService.GetCurrentUser();
 }
Example #8
0
 public QueryHandler(
     PetShelterDbContext petShelterDbContext,
     UserResolverService userResolverService,
     IMapper mapper)
 {
     _petShelterDbContext = petShelterDbContext;
     _user   = userResolverService.GetUser();
     _mapper = mapper;
 }
Example #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SubCategoryViewModelValidator" /> class.
 /// </summary>
 /// <param name="dbContext">The database context.</param>
 /// <param name="userResolver">The user resolver.</param>
 public SubCategoryViewModelValidator(AppDbContext dbContext, UserResolverService userResolver)
     : base(dbContext, userResolver, 50)
 {
     RuleFor(c => c.CategoryId)
     .Cascade(CascadeMode.Stop)
     .NotEmpty()
     .MustAsync(CheckCategory)
     .WithMessage(c => "Invalid Parent category");
 }
Example #10
0
 public CommandHandler(
     PetShelterDbContext petShelterDbContext,
     ImageSaver imageSaver,
     UserResolverService userResolverService)
 {
     _petShelterDbContext = petShelterDbContext;
     _imageSaver          = imageSaver;
     _user = userResolverService.GetUser();
 }
Example #11
0
            public ApplicationDbContext CreateDbContext(string[] args)
            {
                var builder = new DbContextOptionsBuilder <ApplicationDbContext>();
                var modelBuilderUtilities = new ModelBuilderUtilities();
                var userResolverService   = new UserResolverService(_context);

                builder.UseSqlServer(@"Server = (localdb)\mssqllocaldb; Database = Enterprisei2; Trusted_Connection = True; ConnectRetryCount = 0",
                                     optionsBuilder => optionsBuilder.MigrationsAssembly(typeof(ApplicationDbContext).GetTypeInfo().Assembly.GetName().Name));

                return(new ApplicationDbContext(builder.Options, modelBuilderUtilities, userResolverService));
            }
Example #12
0
 public CreateBookingHandler(
     IMapper mapper,
     IBookingsService bookingsService,
     UserResolverService userResolverService,
     IPropertiesService propertiesService)
 {
     _mapper              = mapper;
     _bookingsService     = bookingsService;
     _userResolverService = userResolverService;
     _propertiesService   = propertiesService;
 }
 public HomeController(DatabaseContext dbContext, UserResolverService manager,
                       IHostingEnvironment hostingEnvironment, IMapper mapper)
 {
     _db = dbContext;
     _hostingEnvironment = hostingEnvironment;
     _manager            = manager;
     _mapper             = mapper;
     languagesRepository = new Repository <SpokenLanguage>(_db, _manager);
     wordRepository      = new Repository <Word>(_db, _manager);
     groupRepository     = new Repository <Group>(_db, _manager);
 }
Example #14
0
 public BookingsListController(IBookingsService bookingsService,
                               IPropertyImagesService propertyImagesService,
                               ICitiesService citiesService,
                               UserResolverService userResolverService,
                               IPropertiesService propertiesService)
 {
     _bookingsService       = bookingsService;
     _propertyImagesService = propertyImagesService;
     _citiesService         = citiesService;
     _userResolverService   = userResolverService;
     _propertiesService     = propertiesService;
 }
Example #15
0
 public AnimalsService(IMapper mapper,
                       ILoggerManager logger,
                       PetSpotDbContext context,
                       UserResolverService userResolverService,
                       ILocationRepository locationRepository)
 {
     this.mapper              = mapper;
     this.logger              = logger;
     this.context             = context;
     this.userResolverService = userResolverService;
     this.locationRepository  = locationRepository;
 }
Example #16
0
 public HotelRepository(HotelAppContext hotelAppContext,
                        UserResolverService userResolverService,
                        UserManager <User> userManager,
                        IMapper mapper,
                        ILogger <HotelRepository> logger)
 {
     _hotelAppContext     = hotelAppContext;
     _userResolverService = userResolverService;
     _userManager         = userManager;
     _mapper = mapper;
     _logger = logger;
 }
 public SecurityService(Bread2BunContext bread2BunContext,
                        IMapper mapper, UserManager <StoreUser> userManager,
                        SignInManager <StoreUser> signInManager, IConfiguration configuration,
                        UserResolverService userResolverService
                        )
 {
     this.bread2BunContext    = bread2BunContext;
     this.mapper              = mapper;
     this.userManager         = userManager;
     this.signInManager       = signInManager;
     this.configuration       = configuration;
     this.userResolverService = userResolverService;
 }
Example #18
0
 public ReservationRepository(HotelAppContext hotelAppContext,
                              IMapper mapper,
                              UserResolverService userResolverService,
                              UserManager <User> userManager,
                              ISort <Reservation> sort,
                              ILogger <ReservationRepository> logger)
 {
     _hotelAppContext     = hotelAppContext;
     _mapper              = mapper;
     _userResolverService = userResolverService;
     _userManager         = userManager;
     _sort   = sort;
     _logger = logger;
 }
Example #19
0
 public AppointmentsController(
     IMediator mediator,
     PetShelterDbContext petshelterDbContext,
     IBackgroundTaskQueue queue,
     IServiceScopeFactory serviceScopeFactory,
     UserResolverService userResolverService,
     IAuthorizationService authorizationService)
 {
     _mediator            = mediator;
     _petShelterDbContext = petshelterDbContext;
     Queue = queue;
     _serviceScopeFactory  = serviceScopeFactory;
     _userResolverService  = userResolverService;
     _authorizationService = authorizationService;
 }
Example #20
0
        public async Task <Unit> Handle(CreateVaultCommand request, CancellationToken cancellationToken)
        {
            var vault = new Vault()
            {
                MasterSalt     = Encryptor.GenerateSalt(),
                MasterPassword = "",
                Name           = request.Name,
                Username       = UserResolverService.GetUsername()
            };

            vault.MasterPassword = CryptoService.HashString(request.MasterPassword, vault.MasterSalt);
            PmContext.Add(vault);
            await PmContext.SaveChangesAsync();

            return(Unit.Value);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="AccountViewModelValidator" /> class.
        /// </summary>
        /// <param name="dbContext">The database context.</param>
        /// <param name="userResolver">The user resolver.</param>
        public AccountViewModelValidator(AppDbContext dbContext, UserResolverService userResolver)
        : base(dbContext, userResolver, 50)
        {
            RuleFor(c => c.IsActive)
                .NotNull();

            RuleFor(c => c.IncludeInBalance)
             .NotNull();

            RuleFor(c => c.PaymentDate)
                .InclusiveBetween(1, 31)
                .When(c => c.PaymentDate.HasValue);

            RuleFor(c => c.AccountTypeId)
                .Cascade(CascadeMode.Stop)
                .NotEmpty()
                .MustAsync(CheckAccountType)
                .WithMessage(c => "Invalid Account Type");
        }
Example #22
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NameValidator{TModel, TViewModel}" /> class.
        /// </summary>
        /// <param name="dbContext">The database context.</param>
        /// <param name="userResolver">The user resolver service</param>
        /// <param name="maxLength">The maximum length.</param>
        protected NameValidator(AppDbContext dbContext, UserResolverService userResolver, int maxLength)
        {
            DbContext    = dbContext;
            UserResolver = userResolver;

            RuleFor(c => c.IsDeleted)
            .Must(c => c == false)
            .WithMessage("Delete shouldn't be set to true");

            RuleFor(c => c.Name)
            .Cascade(CascadeMode.Stop)
            .NotEmpty()
            .MaximumLength(maxLength)
            .DependentRules(() =>
            {
                RuleFor(c => c)
                .MustAsync(CheckName)
                .OverridePropertyName(c => c.Name)
                .WithMessage(c => $"Record with the name {c.Name} already exists");
            });
        }
Example #23
0
 public ApplicationDbContext(DbContextOptions <ApplicationDbContext> options, UserResolverService userService) : base(options)
 {
     _userService = userService;
 }
Example #24
0
        public Repository(DatabaseContext dbContext, UserResolverService manager)
        {
            _dbContext = dbContext;

            _objectSet = _dbContext.Set <T>();
        }
Example #25
0
 public ChatService(Bread2BunContext bread2BunContext, UserResolverService userResolverService)
 {
     this.bread2BunContext    = bread2BunContext;
     this.userResolverService = userResolverService;
 }
 public CreateEntryCommandHandler(PasswordManagerContext context, UserResolverService userResolverService, IVaultService vaultService) : base(context)
 {
     UserResolverService = userResolverService;
     VaultService        = vaultService;
 }
 public WavesDbContext(DbContextOptions <WavesDbContext> options, UserResolverService userService = null) : base(options)
 {
     _userService = userService;
 }
Example #28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AppDbContext" /> class.
 /// </summary>
 /// <param name="options">The options for this context.</param>
 /// <param name="userResolver">The user resolver.</param>
 public AppDbContext(DbContextOptions options, UserResolverService userResolver)
     : base(options)
 {
     this.userResolver = userResolver;
 }
Example #29
0
 public ReviewService(Bread2BunContext bread2BunContext, IMapper mapper, UserResolverService userResolverService)
 {
     this.context             = bread2BunContext;
     this.mapper              = mapper;
     this.userResolverService = userResolverService;
 }
Example #30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="IndexController" /> class.
 /// </summary>
 /// <param name="userService">The user service.</param>
 /// <param name="userResolver">The user resolver.</param>
 public IndexController(IUserService userService, UserResolverService userResolver)
 {
     this.userService  = userService;
     this.userResolver = userResolver;
 }