public void Seed()
        {
            var hist = new UserHistoryEntity
            {
                ProjectId = 1,
                UserType  = "Guest",
                Goal      = "to be able to open the website",
                Reason    = "I can navigate it"
            };
            var hist2 = new UserHistoryEntity
            {
                ProjectId = 1,
                UserType  = "User",
                Goal      = "to be able to send messages to other users",
                Reason    = "I can communicate through the website"
            };
            var hist3 = new UserHistoryEntity
            {
                ProjectId = 1,
                UserType  = "Administrator",
                Goal      = "to be able to ban users",
                Reason    = "I can moderate the website"
            };
            var hist4 = new UserHistoryEntity
            {
                ProjectId = 2,
                UserType  = "Administrator",
                Goal      = "be able to post an entry on the website",
                Reason    = "I can have a blog"
            };
            var hist5 = new UserHistoryEntity
            {
                ProjectId = 2,
                UserType  = "Administrator",
                Goal      = "be able to archive an entry",
                Reason    = "it can no longer be seen by blog readers"
            };
            var hist6 = new UserHistoryEntity
            {
                ProjectId = 3,
                UserType  = "Project Developer",
                Goal      = "be able to write code",
                Reason    = "I can develop an app"
            };
            var hist7 = new UserHistoryEntity
            {
                ProjectId = 3,
                UserType  = "Project Leader",
                Goal      = "be able to check Developer logs",
                Reason    = "I can keep track of the Developers' work"
            };

            _session.Save(hist);
            _session.Save(hist2);
            _session.Save(hist3);
            _session.Save(hist4);
            _session.Save(hist5);
            _session.Save(hist6);
            _session.Save(hist7);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="connection"></param>
        /// <param name="transaction"></param>
        /// <returns></returns>
        public static DbDataReader Select(UserHistoryEntity entity, DbConnection connection, DbTransaction transaction)
        {
            var reader = KandaTableDataGateway._factory.CreateReader(connection, transaction);

            reader.CommandText = @"usp_SelectUserHistories";

            KandaDbDataMapper.MapToParameters(reader, entity);

            reader.ExecuteReader();

            return(reader);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="connection"></param>
        /// <param name="transaction"></param>
        /// <returns></returns>
        public static int Insert(UserHistoryEntity entity, DbConnection connection, DbTransaction transaction)
        {
            var command = KandaTableDataGateway._factory.CreateCommand(connection, transaction);

            command.CommandText = @"usp_InsertUserHistories";

            KandaDbDataMapper.MapToParameters(command, entity);

            var result = KandaTableDataGateway._factory.CreateParameter(KandaTableDataGateway.RETURN_VALUE, DbType.Int32, sizeof(int), ParameterDirection.ReturnValue, DBNull.Value);

            command.Parameters.Add(result);

            command.ExecuteNonQuery();

            return((int)result.Value);
        }
Example #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="connection"></param>
        /// <param name="transaction"></param>
        /// <returns></returns>
        public IEnumerable <UserHistoryEntity> Get(UserHistoryEntity entity, DbConnection connection, DbTransaction transaction)
        {
            var reader = default(DbDataReader);

            try
            {
                reader = UserHistoriesGateway.Select(entity, connection, transaction);

                var entities = KandaDbDataMapper.MapToEnumerable <UserHistoryEntity>(reader);

                return(entities);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
        }
        public async Task <IEnumerable <IUserHistoryItem> > GetUserHistory(string userId, DateTime dateFrom, DateTime dateTo)
        {
            DateTime startDate   = dateFrom.Date;
            DateTime endDate     = dateTo.Date.AddDays(1);
            DateTime currentDate = startDate;

            List <UserHistoryEntity> retval = new List <UserHistoryEntity>();

            do
            {
                string partitionKey = UserHistoryEntity.GetPartitionKey(userId, currentDate);
                var    entities     = (await _hstorage.GetDataAsync(new[] { partitionKey }, int.MaxValue))
                                      .OrderByDescending(item => item.Timestamp);
                retval.AddRange(entities);

                currentDate = currentDate.AddDays(1);
            } while (currentDate < endDate);


            return(retval.Select(UserHistoryEntity.CreateDto));
        }
Example #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="connection"></param>
        /// <param name="transaction"></param>
        /// <returns></returns>
        public bool Create(UserHistoryEntity entity, DbConnection connection, DbTransaction transaction)
        {
            var created = UserHistoriesGateway.Insert(entity, connection, transaction);

            return(created == 1);
        }
Example #7
0
 /// <summary>
 /// コンストラクター。
 /// </summary>
 /// <param name="entity"></param>
 public UserHistory(UserHistoryEntity entity)
 {
     this._entity    = entity;
     this.Attributes = new Collection <UserHistoryAttributeEntity>();
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="entity"></param>
 public UserHisotryAttributes(UserHistoryEntity entity)
 {
     this._entity = entity;
 }