Example #1
0
        // fetch by Primary key into current object
        // links:
        //  docLink: http://sql2x.org/documentationLink/bbab4791-c9e7-49bf-90d5-fca19b1fedaa
        // parameters:
        //  defaultUserId: primary key of table default_user
        public CrudeDefaultUserContract FetchByDefaultUserId(System.Guid defaultUserId)
        {
            var dataAccessLayer = new CrudeDefaultUserData();
            var contract        = new CrudeDefaultUserContract();

            dataAccessLayer.FetchByDefaultUserId(defaultUserId);
            DataToContract(dataAccessLayer, contract);

            return(contract);
        }
        /// <summary>
        /// Add an activity
        /// </summary>
        /// <param name="userId">User who triggered the activity</param>
        public void AddActivity(
            Guid userId,
            string userActivityTypeRcd,
            string activityNote,
            string originatingAddress
            )
        {
            CrudeDefaultUserActivityData defaultUserActivity = new CrudeDefaultUserActivityData {
                DefaultUserActivityId      = Guid.NewGuid(),
                DefaultUserActivityTypeRcd = userActivityTypeRcd,
                UserActivityNote           = activityNote,
                OriginatingAddress         = originatingAddress,
                DefaultUserId = userId,
                DateTime      = DateTime.UtcNow
            };

            defaultUserActivity.Insert();

            CrudeDefaultUserData defaultUser = new CrudeDefaultUserData();

            defaultUser.FetchByDefaultUserId(userId);
            defaultUser.LastActivityDateTime = DateTime.UtcNow;
            defaultUser.Update(); // todo, possible to only update LastActivityDateTime?
        }