public async Task InsertUserActionToDB(UserActionCreateDTO userAction)
 {
     // Map, add fields to customer entity
     UserAction userActionEntity = AMapper.Mapper.Map <UserActionCreateDTO, UserAction>(userAction);
     // Insert a customer into the database
     await UserActionRepository.Insert(userActionEntity);
 }
        public async Task <IEnumerable <UserActionGetDetailDTO> > GetAllUserActions()
        {
            IEnumerable <UserAction> userActions = await UserActionRepository.GetAll();

            var UserActionDTOs = AMapper.Mapper.Map <IEnumerable <UserAction>, IEnumerable <UserActionGetDetailDTO> >(userActions);

            return(UserActionDTOs);
        }
Ejemplo n.º 3
0
        public ParticipantsController()
        {
            var connectionStr = Settings.GetStringDB();

            this._participantsRepository = new ParticipantRepository(connectionStr);
            _userActionRepository        = new UserActionRepository(connectionStr);
            ur = new UserRepository(connectionStr);
        }
Ejemplo n.º 4
0
        public TranslationController()
        {
            var connectionString = Settings.GetStringDB();

            translationRepository = new TranslationRepository(connectionString);
            userRepository        = new UserRepository(connectionString);
            _userActionRepository = new UserActionRepository(connectionString);
        }
Ejemplo n.º 5
0
        public GlossariesController(GlossariesService glossariesService)
        {
            _glossariesService = glossariesService;
            var connectionString = Settings.GetStringDB();

            _userActionRepository = new UserActionRepository(connectionString);

            ur = new UserRepository(connectionString);
        }
Ejemplo n.º 6
0
        public void removeUserActionInvalid()
        {
            //Arrange
            DataBaseContext       db     = new DataBaseContext();
            IUserActionRepository uaRepo = new UserActionRepository(db);
            Guid   userID = new Guid();
            string action = "View_Watchlist";

            //Act => Assert
            Assert.ThrowsException <ArgumentNullException>(() => uaRepo.RemoveUserAction(userID, action));
        }
        public async Task <IEnumerable <UserActionGetDetailDTO> > GetUserActionsByDate(DateTime dateTime)
        {
            // convert date to string because SQLite doesn't have DateTime type
            string dateTimeStr = dateTime.Date.ToString(dateTimeFormat);
            // according to string format of dateTime in SQLite first part of dateTimeStr will be "yyyy-MM-dd"
            string dateStr = dateTimeStr.Split(' ')[0];
            IEnumerable <UserAction> userActions = await UserActionRepository.GetByDate(dateStr);

            var UserActionDTOs = AMapper.Mapper.Map <IEnumerable <UserAction>, IEnumerable <UserActionGetDetailDTO> >(userActions);

            return(UserActionDTOs);
        }
Ejemplo n.º 8
0
        public ProjectController()
        {
            string connectionString = Settings.GetStringDB();

            _localizationProjectRepository         = new LocalizationProjectRepository(connectionString);
            _localizationProjectsLocalesRepository = new LocalizationProjectsLocalesRepository(connectionString);
            _localeRepository     = new LocaleRepository(connectionString);
            _userActionRepository = new UserActionRepository(connectionString);
            ur = new UserRepository(connectionString);
            _participantsRepository = new ParticipantRepository(connectionString);
            _roleRepository         = new RoleRepository(connectionString);
        }
Ejemplo n.º 9
0
        public void UserActionRepository_RemoveUserAction_InvalidUA()
        {
            //Arrange
            DataBaseContext       db     = new DataBaseContext();
            IUserActionRepository uaRepo = new UserActionRepository(db);
            Guid       userID            = new Guid();
            string     action            = "View_Watchlist";
            UserAction ua = new UserAction(userID, action);

            //Act => Assert
            Assert.ThrowsException <DbUpdateConcurrencyException>(() => uaRepo.RemoveUserAction(ua));
        }
Ejemplo n.º 10
0
        public void UserActionRepository_GetUsersByAction_NullAction()
        {
            //Arrange
            DataBaseContext       db     = new DataBaseContext();
            IUserActionRepository uaRepo = new UserActionRepository(db);
            string action = "";

            //Act
            List <User> ul = uaRepo.GetUsersByAction(action);

            //Assert
            Assert.AreEqual(ul.Count, 0);
        }
Ejemplo n.º 11
0
        public void getUserActionsByUserIDNotNull()
        {
            //Arrange
            DataBaseContext       db     = new DataBaseContext();
            IUserActionRepository uaRepo = new UserActionRepository(db);
            Guid id = new Guid("7AF91B37-DC4A-E911-8259-0A64F53465D0");


            //Act
            List <string> ua = uaRepo.GetActionsByUserID(id);

            //Assert
            Assert.AreEqual(ua.Count, 2);
        }
Ejemplo n.º 12
0
        public void UserActionRepository_GetUserAction_ValidUA()
        {
            //Arrange
            DataBaseContext       db     = new DataBaseContext();
            IUserActionRepository uaRepo = new UserActionRepository(db);
            Guid   userID = new Guid("44361F37-036B-E911-AA03-021598E9EC9E");
            string action = "Login";

            //Act
            UserAction ua = uaRepo.GetUserAction(userID, action);

            //Assert
            Assert.IsNotNull(ua);
        }
Ejemplo n.º 13
0
        public void UserActionRepository_GetActionsByUserID_ValidUserID()
        {
            //Arrange
            DataBaseContext       db     = new DataBaseContext();
            IUserActionRepository uaRepo = new UserActionRepository(db);
            Guid id = new Guid("44361F37-036B-E911-AA03-021598E9EC9E");


            //Act
            List <string> ua = uaRepo.GetActionsByUserID(id);

            //Assert
            Assert.AreEqual(ua.Count, 2);
        }
Ejemplo n.º 14
0
        public void UserActionRepository_GetUserAction_InvalidUA()
        {
            //Arrange
            DataBaseContext       db     = new DataBaseContext();
            IUserActionRepository uaRepo = new UserActionRepository(db);
            Guid   userID = new Guid("7CF91B37-DC4A-E911-8259-0A64F53465D0");
            string action = "Search";

            //Act
            UserAction ua = uaRepo.GetUserAction(userID, action);

            //Assert
            Assert.IsNull(ua);
        }
Ejemplo n.º 15
0
        public void removeUserActionValid()
        {
            //Arrange
            DataBaseContext       db     = new DataBaseContext();
            IUserActionRepository uaRepo = new UserActionRepository(db);
            Guid   userID = new Guid("7BF91B37-DC4A-E911-8259-0A64F53465D0");
            string action = "View_Watchlist";

            //Act
            uaRepo.RemoveUserAction(userID, action);
            UserAction removedUA = uaRepo.GetUserAction(userID, action);

            //Assert
            Assert.IsNull(removedUA);
        }
Ejemplo n.º 16
0
        public void UserActionRepository_AddUserAction_ValidUser()
        {
            //Arrange
            DataBaseContext       db     = new DataBaseContext();
            IUserActionRepository uaRepo = new UserActionRepository(db);
            Guid       userID            = new Guid("F98A70A1-056B-E911-AA03-021598E9EC9E");
            string     action            = "View_Watchlist";
            UserAction ua = new UserAction(userID, action);

            //Act
            uaRepo.AddUserAction(ua);
            UserAction newUA = uaRepo.GetUserAction(userID, action);

            //Assert
            Assert.IsNotNull(newUA);
        }
Ejemplo n.º 17
0
        public void UserActionRepository_GetActionsByUserID_NullID()
        {
            //Arrange
            DataBaseContext db = new DataBaseContext();

            using (DataBaseContext _db = new DataBaseContext())
            {
            }
            IUserActionRepository uaRepo = new UserActionRepository(db);
            Guid id = new Guid();


            //Act
            List <string> ua = uaRepo.GetActionsByUserID(id);

            //Assert
            Assert.AreEqual(ua.Count, 0);
        }
Ejemplo n.º 18
0
 public UserActionsController(IDbContext dbContext)
 {
     _repository = new UserActionRepository(dbContext);
 }
Ejemplo n.º 19
0
 public UserActionService(DataBaseContext db)
 {
     uaRepo = new UserActionRepository(db);
 }
Ejemplo n.º 20
0
 public UserActionService()
 {
     UserActionRepository = new UserActionRepository();
     AMapper = new AMapper();
 }
Ejemplo n.º 21
0
 public ProjectLocaleController()
 {
     _localizationProjectsLocalesRepository = new LocalizationProjectsLocalesRepository(Settings.GetStringDB());
     _userActionRepository = new UserActionRepository(Settings.GetStringDB());
 }