protected virtual BulletinBase MapToBulletin(BulletinCreateModel model)
        {
            var bulletin = model.Map <BulletinBase>();

            bulletin.PublishDate = DateTime.UtcNow;
            bulletin.CreatorId   = bulletin.OwnerId = _memberService.GetCurrentMemberId();

            if (model.NewMedia.HasValue())
            {
                bulletin.MediaIds = _mediaHelper.CreateMedia(model);
            }

            return(bulletin);
        }
        protected override void OnBulletinCreated(BulletinBase bulletin, BulletinCreateModel model)
        {
            base.OnBulletinCreated(bulletin, model);
            var groupId = Request.QueryString.GetGroupId();

            if (groupId.HasValue)
            {
                _groupActivityService.AddRelation(groupId.Value, bulletin.Id);
                var extendedBulletin = _bulletinsService.Get(bulletin.Id);
                extendedBulletin.GroupId = groupId;
            }

            if (model is BulletinExtendedCreateModel extendedModel)
            {
                _activityTagsHelper.ReplaceTags(bulletin.Id, extendedModel.TagIdsData);
            }
        }
        protected virtual BulletinCreateModel GetCreateFormModel(IActivityCreateLinks links)
        {
            var currentMember = _memberService.GetCurrentMember();
            var mediaSettings = _bulletinsService.GetMediaSettings();

            var result = new BulletinCreateModel
            {
                Title                  = currentMember.DisplayedName,
                ActivityType           = _activityTypeProvider[ActivityTypeId],
                Dates                  = DateTime.UtcNow.ToDateFormat().ToEnumerable(),
                Creator                = currentMember.Map <MemberViewModel>(),
                Links                  = links,
                AllowedMediaExtensions = mediaSettings.AllowedMediaExtensions,
                MediaRootId            = mediaSettings.MediaRootId
            };

            return(result);
        }
        public virtual JsonResult Create(BulletinCreateModel model)
        {
            var result = new BulletinCreationResultModel();

            if (!ModelState.IsValid)
            {
                return(Json(result));
            }

            var bulletin          = MapToBulletin(model);
            var createdBulletinId = _bulletinsService.Create(bulletin);

            bulletin.Id = createdBulletinId;
            OnBulletinCreated(bulletin, model);

            result.Id        = createdBulletinId;
            result.IsSuccess = true;

            return(Json(result));
        }
예제 #5
0
        protected override void OnBulletinCreated(BulletinBase bulletin, BulletinCreateModel model)
        {
            base.OnBulletinCreated(bulletin, model);
            var groupId = Request.QueryString.GetGroupIdOrNone();

            groupId.IfSome(id => _groupActivityService.AddRelation(id, bulletin.Id));

            var extendedBulletin = _bulletinsService.Get(bulletin.Id);

            extendedBulletin.GroupId = groupId.ToNullable();

            if (model is BulletinExtendedCreateModel extendedModel)
            {
                _activityTagsHelper.ReplaceTags(bulletin.Id, extendedModel.TagIdsData);
            }

            if (string.IsNullOrEmpty(model.Description))
            {
                return;
            }
            ResolveMentions(model.Description, bulletin);
        }
 protected virtual void OnBulletinCreated(BulletinBase bulletin, BulletinCreateModel model)
 {
 }