public void Process(ISemanticProcessor proc, IMembrane membrane, Login login)
        {
            IDbContextService  db  = proc.ServiceManager.Get <IDbContextService>();
            List <UserAccount> uas = db.Context.Query <UserAccount>(r => r.Email == login.Email);

            if (uas.Count == 1)
            {
                if (PasswordHash.ValidatePassword(login.Password, uas[0].PasswordHash))
                {
                    if (uas[0].Registered)
                    {
                        proc.ServiceManager.Get <IWebSessionService>().Authenticate(login.Context);
                        JsonResponse(proc, login, "{'state': 'OK'}");
                        IWebSessionService session = proc.ServiceManager.Get <IWebSessionService>();
                        session.SetSessionObject(login.Context, "OneTimeAlert", "Welcome Back " + uas[0].FirstName + "!");
                        session.SetSessionObject(login.Context, "UserName", uas[0].FullName);
                        session.SetSessionObject(login.Context, "UserAccount", uas[0]);
                        session.SetSessionObject(login.Context, "RoleMask", uas[0].RoleMask);
                    }
                    else
                    {
                        JsonResponse(proc, login, "{'state': 'RegisterFirst'}");
                    }
                }
                else
                {
                    JsonResponse(proc, login, "{'state': 'BadAccount'}");
                }
            }
            else
            {
                JsonResponse(proc, login, "{'state': 'NotFound'}");
            }
        }
 /// <summary>
 /// Create questionnaire interaction service.
 /// </summary>
 public QuestionnaireInteractionService(IDbContextService dbContextService)
 {
     context       = dbContextService.GetDbContextInstance();
     _qRepository  = RepositoryFactory.GetQuestionnaireRepository(context);
     _cqRepository = RepositoryFactory.GetCompletedQuestionnaireRepository(context);
     _saRepository = RepositoryFactory.GetSelectedAnswerRepository(context);
 }
 public CultureApiController(
     IGenericCrudService <CultureDto, Culture> genService,
     IDbContextService dbContext)
 {
     _genService = genService;
     _dbContext  = dbContext;
 }
        public void Process(ISemanticProcessor proc, IMembrane membrane, ForgotPassword forgotPassword)
        {
            IDbContextService  db  = proc.ServiceManager.Get <IDbContextService>();
            List <UserAccount> uas = db.Context.Query <UserAccount>(r => r.Email == forgotPassword.Email);

            if (uas.Count == 1)
            {
                uas[0].PasswordRecoveryToken = Guid.NewGuid().ToString();
                db.Context.Update(uas[0]);

                string website = proc.ServiceManager.Get <IConfigService>().GetValue("website");

                // Email the registrant.
                proc.ServiceManager.Get <ISemanticProcessor>().ProcessInstance <EmailClientMembrane, Email>(email =>
                {
                    email.AddTo(forgotPassword.Email);
                    email.Subject = "ByteStruck Password Recovery";
                    email.Body    = File.ReadAllText("passwordRecoveryEmail.html").Replace("{link}", website + "/account/recoverPassword?token=" + uas[0].PasswordRecoveryToken);
                });

                JsonResponse(proc, forgotPassword, "{'state': 'OK'}");
            }
            else
            {
                JsonResponse(proc, forgotPassword, "{'state': 'NotFound'}");
            }
        }
Example #5
0
        public UserInfoViewModel(IDbContextService dbContext) : base(dbContext)
        {
            //Show all user data
            //Edit button

            //Service that gets cars of the user
        }
Example #6
0
        public ProductMailerQueueJob(IProductMailQueueService productMailQueueService, IDbContextService dbContextService)
        {
            logger = LogManager.GetLogger(GetType());

            _productMailQueueService = productMailQueueService;
            _dbContextService        = dbContextService;
        }
Example #7
0
 public ContentApiController(
     IGenericCrudService <ContentblockDto, Contentblock> genService,
     IDbContextService dbContext)
 {
     _genService = genService;
     _dbContext  = dbContext;
 }
 public AttributeApiController(IAttributeService attributeService,
                               IDbContextService dbContext, MapperConfiguration mapConfig)
 {
     _attributeService = attributeService;
     _dbContext        = dbContext;
     _mapper           = mapConfig.CreateMapper();
 }
 public ArticleApiController(
     IGenericCrudService <ArticleDto, Article> genService,
     IDbContextService dbContext)
 {
     _genService = genService;
     _dbContext  = dbContext;
 }
Example #10
0
        public ESDeleteIndexProductJob(IIndexingProductService indexingProductService, IDbContextService dbContextService)
        {
            logger = LogManager.GetLogger(GetType());

            _indexingProductService = indexingProductService;
            _dbContextService       = dbContextService;
        }
Example #11
0
        public PeopleOnlineQueueJob(IPeopleOnlineService peopleOnlineService, IDbContextService dbContextService)
        {
            logger = LogManager.GetLogger(GetType());

            _peopleOnlineService = peopleOnlineService;
            _dbContextService    = dbContextService;
        }
Example #12
0
 public EntityUpdateHandler(DecodedDto dtoInfo, DecodedEntityClass entityInfo, IWrappedConfigAndMapper configAndMapper, DbContext context, IDbContextService createNewDBContext)
 {
     _dtoInfo            = dtoInfo ?? throw new ArgumentNullException(nameof(dtoInfo));
     _entityInfo         = entityInfo ?? throw new ArgumentNullException(nameof(entityInfo));
     _configAndMapper    = configAndMapper ?? throw new ArgumentNullException(nameof(configAndMapper));
     _context            = context ?? throw new ArgumentNullException(nameof(context));
     _createNewDBContext = createNewDBContext ?? null;
 }
        public ProductWorkflowJob(IWorkflowService workflowService, IDbContextService dbContextService, IProductService productService)
        {
            logger = LogManager.GetLogger(GetType());

            _workflowService  = workflowService;
            _dbContextService = dbContextService;
            _productService   = productService;
        }
Example #14
0
 public ModelTable(ModelMgr modelMgr, IDbContextService db, DataTable backingTable, List <IEntity> modelCollection)
 {
     this.modelMgr = modelMgr;
     this.db       = db;
     dt            = backingTable;
     items         = modelCollection;
     WireUpEvents(dt);
 }
        public BattleController(UserManager <User> usermanager, IMapper mapper, IRobotDataService robotDataService, ICreepDataService creepDataService, IDbContextService dbContextService)
        {
            this.userManager = usermanager;

            this.Mapper           = mapper;
            this.robotDataService = robotDataService;
            this.creepDataService = creepDataService;
            this.dbContextService = dbContextService;
        }
Example #16
0
        public StoreController(UserManager <User> userManager, IWeaponDataService weaponDataService, IArmorDataService armorDataService, IDbContextService dbContextService, IMapper mapper)
        {
            this.userManager = userManager;

            this.Mapper            = mapper;
            this.weaponDataService = weaponDataService;
            this.armorDataService  = armorDataService;
            this.dbContextService  = dbContextService;
        }
Example #17
0
        private static void InitializeDatabaseContext()
        {
            SqlConnection     connection = new SqlConnection(serviceManager.Get <IAppConfigService>().GetConnectionString("db"));
            SiteDataContext   context    = new SiteDataContext(connection);
            IDbContextService db         = serviceManager.Get <IDbContextService>();

            db.InitializeContext(context);
            db.CreateDatabaseAndTablesIfNotExists();
        }
 public RepairCenterController(UserManager <User> userManager, IMapper mapper, IDbContextService dbContextService, IRobotDataService robotDataService, IArmorDataService armorDataService, IWeaponDataService weaponDataService, IUserDataService userDataService)
 {
     this.userManager       = userManager;
     this.userDataService   = userDataService;
     this.weaponDataService = weaponDataService;
     this.armorDataService  = armorDataService;
     this.robotDataService  = robotDataService;
     this.dbContextService  = dbContextService;
     this.Mapper            = mapper;
 }
Example #19
0
 public MainDashboardViewModel(IDbContextService dbContext) : base(dbContext)
 {
     //Left Collapsing panel
     //Users
     //----Add
     //Cars
     //----Add
     //Delete should be in Info, after selecting
     //User should be able to add new cars in a new window in info panel
     Content = UserDirectoryViewModel = new UserDirectoryViewModel(dbContext);
     UserDirectoryViewModel.SelectedUserChangedCommand.Subscribe(SelectedUserChanged);
 }
Example #20
0
        public UserDirectoryViewModel(IDbContextService dbContext) : base(dbContext)
        {
            //Load Users
            var query = dbContext.GetAllEntities <Users>();

            Users        = new ObservableCollection <Users>(query);
            SelectedUser = Users.First();

            //Get the user and use it as a command, will be observed by the main view
            SelectedUserChangedCommand = ReactiveCommand.Create <Users, Users>(x => x);
            var SelectedUserChanged_ = this.WhenAnyValue(x => x.SelectedUser).InvokeCommand(SelectedUserChangedCommand);
        }
Example #21
0
 public HomeController(IDutyRepository dutyRepository,
                       ICategoryRepository categoryRepository,
                       IDbContextService dbContextService,
                       ICurrentWeekService currentWeekService,
                       IAmmountOfDoneDutiesArchiveRepository ammountOfDoneDutiesArchiveRepository,
                       IOverdueDutyRepository overdueDutyRepository)
 {
     _overdueDutyRepository = overdueDutyRepository;
     _dutyRepository        = dutyRepository;
     _dbContextService      = dbContextService;
     _categoryRepository    = categoryRepository;
     _currentWeekService    = currentWeekService;
     _ammountOfDoneDutiesArchiveRepository = ammountOfDoneDutiesArchiveRepository;
 }
        public void Process(ISemanticProcessor proc, IMembrane membrane, RegistrationToken token)
        {
            IDbContextService  db  = proc.ServiceManager.Get <IDbContextService>();
            List <UserAccount> uas = db.Context.Query <UserAccount>(r => r.RegistrationToken == token.Token);
            bool validated         = uas.Count == 1;

            proc.ServiceManager.Get <IWebSessionService>().SetSessionObject(token.Context, "TokenValidated", validated);

            if (validated)
            {
                uas[0].RegistrationToken = null;
                uas[0].Registered        = true;
                db.Context.Update(uas[0]);
            }

            // Continue processing the get request to display the /account/finishRegistration page.
            proc.ProcessInstance <WebServerMembrane, UnhandledContext>(c => c.Context = token.Context);
        }
        public void Process(ISemanticProcessor proc, IMembrane membrane, ForgotPasswordToken token)
        {
            IDbContextService  db  = proc.ServiceManager.Get <IDbContextService>();
            List <UserAccount> uas = db.Context.Query <UserAccount>(r => r.PasswordRecoveryToken == token.Token);
            bool validated         = uas.Count == 1;

            if (validated)
            {
                proc.ServiceManager.Get <IWebSessionService>().SetSessionObject(token.Context, "UserPasswordRecoveryId", uas[0].Id);
                uas[0].PasswordRecoveryToken = null;
                db.Context.Update(uas[0]);
            }
            else
            {
                proc.ServiceManager.Get <IWebSessionService>().SetSessionObject(token.Context, "UserPasswordRecoveryId", null);
            }

            // Continue processing the get request to display the /account/passwordRecovery page.
            proc.ProcessInstance <WebServerMembrane, UnhandledContext>(c => c.Context = token.Context);
        }
        public void Process(ISemanticProcessor proc, IMembrane membrane, NewPassword token)
        {
            int?id = proc.ServiceManager.Get <IWebSessionService>().GetSessionObject <int?>(token.Context, "UserPasswordRecoveryId");

            if (id != null)
            {
                IDbContextService  db  = proc.ServiceManager.Get <IDbContextService>();
                List <UserAccount> uas = db.Context.Query <UserAccount>(r => r.Id == (int)id);

                if (uas.Count == 1)
                {
                    uas[0].PasswordHash          = PasswordHash.CreateHash(token.Password);
                    uas[0].PasswordRecoveryToken = null;
                    db.Context.Update(uas[0]);
                    proc.ServiceManager.Get <IWebSessionService>().SetSessionObject(token.Context, "OneTimeAlert", "Your password has been reset.  Please login.");
                    proc.ServiceManager.Get <IWebSessionService>().SetSessionObject(token.Context, "UserPasswordRecoveryId", null);
                    JsonResponse(proc, token, "{'state': 'OK'}");
                }
            }
        }
        public void Process(ISemanticProcessor proc, IMembrane membrane, UpdateAccountInfo acctInfo)
        {
            IWebSessionService session = proc.ServiceManager.Get <IWebSessionService>();
            UserAccount        ua      = session.GetSessionObject <UserAccount>(acctInfo.Context, "UserAccount");

            ua.FirstName = acctInfo.FirstName;
            ua.LastName  = acctInfo.LastName;
            ua.Email     = acctInfo.Email;
            session.SetSessionObject(acctInfo.Context, "UserName", ua.FullName);

            if (!String.IsNullOrEmpty(acctInfo.Password))
            {
                ua.PasswordHash = PasswordHash.CreateHash(acctInfo.Password);
            }

            IDbContextService db = proc.ServiceManager.Get <IDbContextService>();

            db.Context.Update(ua);
            proc.ServiceManager.Get <IWebSessionService>().SetSessionObject(acctInfo.Context, "OneTimeAlert", "Your account information has been updated.");
            JsonResponse(proc, acctInfo, "{'state': 'OK'}");
        }
        public ParticipateBusinessService(IBlockTradeService blockTradeService,
                                          ICommonMessageService commonMessageService,
                                          ILimitOrderService limitOrderService,
                                          ILedgerLocalDbFullDomainRepository <Transactions> transRepository,
                                          ILedgerLocalDbFullDomainRepository <Tokenprice> tokenpriceRepository,
                                          IAccountService accountService,
                                          IDbContextService dbContextService,
                                          ILedgerLocalDbFullDomainUnitOfWork unitOfWork,
                                          ILogger <ParticipateBusinessService> logger)
        {
            _accountService       = accountService;
            _blockTradeService    = blockTradeService;
            _commonMessageService = commonMessageService;
            _tokenpriceRepository = tokenpriceRepository;
            _transRepository      = transRepository;
            _unitOfWork           = unitOfWork;

            _dbContextService = dbContextService;

            _limitOrderService = limitOrderService;

            _logger = logger;
        }
        public void Process(ISemanticProcessor proc, IMembrane membrane, Register register)
        {
            IDbContextService db = proc.ServiceManager.Get <IDbContextService>();

            if (db.RecordExists <UserAccount>(r => r.Email == register.Email))
            {
                JsonResponse(proc, register, "{'state': 'UserExists'}");
            }
            else
            {
                UserAccount ua = new UserAccount()
                {
                    FirstName         = register.FirstName,
                    LastName          = register.LastName,
                    Email             = register.Email,
                    PasswordHash      = PasswordHash.CreateHash(register.Password),
                    RegistrationToken = Guid.NewGuid().ToString(),
                    RoleMask          = 1,
                };

                string website = proc.ServiceManager.Get <IConfigService>().GetValue("website");

                // Email the registrant.
                proc.ServiceManager.Get <ISemanticProcessor>().ProcessInstance <EmailClientMembrane, Email>(email =>
                {
                    email.AddTo(register.Email);
                    email.Subject = "ByteStruck Registration";
                    email.Body    = File.ReadAllText("registrationEmail.html").Replace("{link}", website + "/account/finishRegistration?token=" + ua.RegistrationToken);
                });

                // Insert the record as unregistered, with the registration token.
                db.Context.Insert(ua);

                JsonResponse(proc, register, "{'state': 'OK'}");
            }
        }
 public SportingEventTicketController(IDbContextService dbContextService) : base(dbContextService)
 {
 }
Example #29
0
 /// <summary>
 /// CrudServices needs the correct DbContext and the AutoMapper config
 /// </summary>
 /// <param name="context"></param>
 /// <param name="configAndMapper"></param>
 /// <param name="createNewDBContext"></param>
 public CrudServices(DbContext context, IWrappedConfigAndMapper configAndMapper, IDbContextService createNewDBContext) : base(context, configAndMapper, createNewDBContext)
 {
     if (context == null)
     {
         throw new ArgumentNullException("The DbContext class is null. Either you haven't registered GenericServices, " +
                                         "or you are using the multi-DbContext version, in which case you need to use the CrudServices<TContext> and specify which DbContext to use.");
     }
 }
 public CustomerApiController(ICustomerService customerService,
                              IDbContextService dbContext)
 {
     _customerService = customerService;
     _dbContext       = dbContext;
 }