Exemple #1
0
        /// <summary>
        /// 新增一筆主題討論活動
        /// </summary>
        /// <param name="circleKey"></param>
        /// <param name="memberId"></param>
        /// <param name="name"></param>
        /// <param name="description"></param>
        /// <param name="fileCount"></param>
        /// <param name="tagId"></param>
        /// <returns></returns>
        public ActDiscussion Add(string circleKey, int memberId, string name, string description, int fileCount, int tagId)
        {
            var      db    = _uow.DbContext;
            Guid     eveId = Guid.NewGuid();
            DateTime?dt    = DateTime.UtcNow;
            var      learningCircleInfo = learningCircleService.GetDetailByOuterKey(circleKey);

            #region // 1. 建立主題討論活動物件
            var objDiscussion = new ActDiscussion()
            {
                LearningId  = learningCircleInfo.Id,
                Name        = name,
                EventId     = eveId,
                CreateUser  = memberId,
                Created     = TimeData.Create(dt),
                Updated     = TimeData.Create(null),
                Deleted     = TimeData.Create(null),
                Description = description,

                TagId      = tagId,
                Visibility = true,
                Enable     = true,
                FileCount  = fileCount
            };
            #endregion
            #region // 2. 替主題討論活動建立一筆訊息物件
            Activitys objAct = new Activitys()
            {
                Duration    = 0,
                ModuleKey   = ModuleType.Discussion,
                ToRoomId    = circleKey,
                CreateUser  = memberId,
                Created     = TimeData.Create(dt),
                Updated     = TimeData.Create(null),
                Deleted     = TimeData.Create(null),
                OuterKey    = eveId,
                StartDate   = dt,
                IsActivity  = true,
                CardisShow  = true,
                Publish_Utc = dt
            };
            #endregion

            // 3. 寫入DB
            db.ActDiscussion.Add(objDiscussion);
            db.Activitys.Add(objAct);

            //要先儲存Activity的內容才能生出ActivityId
            db.SaveChanges();

            return(objDiscussion);
        }
Exemple #2
0
        /// <summary>
        /// 新增一筆主題討論活動
        /// </summary>
        /// <param name="circleKey"></param>
        /// <param name="memberId"></param>
        /// <param name="name"></param>
        /// <param name="description"></param>
        /// <param name="fileCount"></param>
        /// <param name="tagId"></param>
        /// <returns></returns>
        public Infrastructure.ViewModel.ActivitysViewModel Add(string circleKey, int memberId, string name, string description, List <Infrastructure.DataTransferObject.RequestFile> files, int tagId)
        {
            var      db                 = _uow.DbContext;
            Guid     eveId              = Guid.NewGuid();
            DateTime?dt                 = DateTime.UtcNow;
            int      fileCount          = files.Count();
            var      learningCircleInfo = learningCircleService.GetDetailByOuterKey(circleKey);

            #region // 1. 建立主題討論活動物件
            var objDiscussion = new ActDiscussion()
            {
                LearningId  = learningCircleInfo.Id,
                Name        = name,
                EventId     = eveId,
                CreateUser  = memberId,
                Created     = TimeData.Create(dt),
                Updated     = TimeData.Create(null),
                Deleted     = TimeData.Create(null),
                Description = description,

                TagId      = tagId,
                Visibility = true,
                Enable     = true,
                FileCount  = fileCount
            };
            #endregion
            #region // 2. 替主題討論活動建立一筆訊息物件
            Activitys objAct = new Activitys()
            {
                Duration    = 0,
                ModuleKey   = ModuleType.Discussion,
                ToRoomId    = circleKey,
                CreateUser  = memberId,
                Created     = TimeData.Create(dt),
                Updated     = TimeData.Create(null),
                Deleted     = TimeData.Create(null),
                OuterKey    = eveId,
                StartDate   = dt,
                IsActivity  = true,
                CardisShow  = true,
                Publish_Utc = dt
            };
            #endregion

            // 3. 寫入DB
            db.ActDiscussion.Add(objDiscussion);
            db.Activitys.Add(objAct);

            //要先儲存Activity的內容才能生出ActivityId
            db.SaveChanges();
            #region // 3. 替主題討論活動建立一筆互動物件 方便於未來做更多功能而存
            if (fileCount != 0)
            {
                // 2018-03-22 yuschang 建立附加檔案
                var fileStorages = fileService.GetFileStorages(memberId, files);

                //建立主題討論與檔案的關聯
                discussionFileService.DiscussionFileReference(objDiscussion.Id, fileStorages, null);
            }

            #endregion
            return(activityService.SignalrResponse(circleKey, objDiscussion.EventId, ModuleType.Discussion, memberId, true));
        }
Exemple #3
0
        /// <summary>
        /// 新增一筆主題討論活動
        /// </summary>
        /// <param name="circleKey"></param>
        /// <param name="memberId"></param>
        /// <param name="name"></param>
        /// <param name="googleDriveFileId"></param>
        /// <param name="description"></param>
        /// <param name="fileCount"></param>
        /// <param name="tagId"></param>
        /// <returns></returns>
        private Infrastructure.BusinessObject.DiscussionEvent Add(string circleKey, int memberId, string name, string googleDriveFileId, string description, int fileCount, int tagId)
        {
            var      db    = _uow.DbContext;
            Guid     eveId = Guid.NewGuid();
            DateTime?dt    = DateTime.UtcNow;
            int      id    = cacheService.GetCircle(circleKey).Id;

            #region // 1. 建立主題討論活動物件
            var objDiscussion = new ActDiscussion()
            {
                LearningId     = id,
                Name           = name,
                EventId        = eveId,
                CreateUser     = memberId,
                Created        = Infrastructure.Property.TimeData.Create(dt),
                Updated        = Infrastructure.Property.TimeData.Create(null),
                Deleted        = Infrastructure.Property.TimeData.Create(null),
                Description    = description,
                GoogleDriveUrl = googleDriveFileId,
                TagId          = tagId,
                Visibility     = true,
                Enable         = true,
                FileCount      = fileCount
            };
            #endregion
            #region // 2. 替主題討論活動建立一筆訊息物件
            Activitys objAct = new Activitys()
            {
                Duration    = 0,
                ModuleKey   = Utility.ParaCondition.ModuleType.Discussion,
                ToRoomId    = circleKey,
                CreateUser  = memberId,
                Created     = Infrastructure.Property.TimeData.Create(dt),
                Updated     = Infrastructure.Property.TimeData.Create(null),
                Deleted     = Infrastructure.Property.TimeData.Create(null),
                OuterKey    = eveId,
                StartDate   = dt,
                IsActivity  = true,
                CardisShow  = true,
                Publish_Utc = dt
            };
            #endregion

            // 3. 寫入DB
            db.ActDiscussion.Add(objDiscussion);
            db.Activitys.Add(objAct);

            //要先儲存Activity的內容才能生出ActivityId
            db.SaveChanges();


            #region // 回傳給APP的物件
            var data = new Infrastructure.BusinessObject.DiscussionEvent()
            {
                ClassId    = circleKey,
                OuterKey   = eveId,
                Creator    = memberId.ToString(),
                CreateDate = Convert.ToDateTime(dt)
            };
            #endregion

            return(data);
        }