예제 #1
0
        protected virtual void Save(IIntranetActivity activity, Action <IIntranetActivity> afterSaveAction)
        {
            var entity = _activityRepository.Get(activity.Id);

            entity.JsonData = activity.ToJson();

            _activityLocationService.Set(activity.Id, activity.Location);
            _activityRepository.Update(entity);
            _intranetMediaService.Update(activity.Id, activity.MediaIds.JoinToString());
            AssignLinkPreview(activity);

            afterSaveAction?.Invoke(activity);
            UpdateActivityCache(activity.Id);
        }
예제 #2
0
        protected virtual async Task SaveAsync(IIntranetActivity activity, Action <IIntranetActivity> afterSaveAction)
        {
            var entity = await _activityRepository.GetAsync(activity.Id);

            entity.JsonData = activity.ToJson();

            await _activityLocationService.SetAsync(activity.Id, activity.Location);

            await _activityRepository.UpdateAsync(entity);

            await _intranetMediaService.UpdateAsync(activity.Id, activity.MediaIds.JoinToString());

            await AssignLinkPreviewAsync(activity);

            afterSaveAction?.Invoke(activity);
            await UpdateActivityCacheAsync(activity.Id);
        }
예제 #3
0
        protected virtual Guid Create(IIntranetActivity activity, Action <Guid> afterCreateAction)
        {
            var newActivity = new IntranetActivityEntity {
                Type = Type.ToInt(), JsonData = activity.ToJson()
            };

            _activityRepository.Create(newActivity);
            var newActivityId = newActivity.Id;

            _activityLocationService.Set(newActivityId, activity.Location);
            _intranetMediaService.Create(newActivityId, activity.MediaIds.JoinToString());
            AssignLinkPreview(newActivityId, activity);

            afterCreateAction?.Invoke(newActivityId);

            UpdateActivityCache(newActivityId);
            return(newActivityId);
        }