public ActionResult Create(GroupCreateModel createModel)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToCurrentUmbracoPage(Request.QueryString));
            }

            var group = createModel.Map <GroupModel>();

            group.GroupTypeId = GroupTypeEnum.Open.ToInt();
            var createdMedias = _mediaHelper.CreateMedia(createModel).ToList();

            group.ImageId = createdMedias.Any() ? (int?)createdMedias.First() : null;

            Guid groupId = _groupService.Create(group);

            _groupMediaService.GroupTitleChanged(groupId, group.Title);

            _groupMemberService.Add(groupId, createModel.CreatorId);

            return(Redirect(_groupLinkProvider.GetGroupLink(groupId)));
        }
Esempio n. 2
0
 public IActionResult Create([FromBody] GroupMemberViewModel viewModel)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     try
     {
         GroupMember groupMember = _mapper.Map <GroupMemberViewModel, GroupMember>(viewModel);
         _groupMemberService.Add(groupMember);
         _unitOfWork.Commit();
         return(CreatedAtRoute("find", new { id = groupMember.Id }, groupMember));
     }
     catch
     {
         return(StatusCode(500));
     }
 }
Esempio n. 3
0
        public virtual RedirectToUmbracoPageResult Subscribe(Guid groupId)
        {
            var currentMember = _memberService.GetCurrentMember();

            if (_groupMemberService.IsGroupMember(groupId, currentMember.Id))
            {
                _groupMemberService.Remove(groupId, currentMember.Id);
            }
            else
            {
                var subscription = new GroupMemberSubscriptionModel
                {
                    MemberId = currentMember.Id,
                    IsAdmin  = false
                };

                _groupMemberService.Add(groupId, subscription);
            }

            return(RedirectToCurrentUmbracoPage(Request.QueryString));
        }
Esempio n. 4
0
 private void InviteUser(MemberGroupInviteModel invite) =>
 _groupMemberService.Add(invite.GroupId, new GroupMemberSubscriptionModel
 {
     MemberId = invite.MemberId
 });