public ActionResult Edit(GroupEditModel model)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToCurrentUmbracoPage(Request.QueryString));
            }

            var group = _groupService.Get(model.Id);

            group         = Mapper.Map(model, group);
            group.ImageId = model.Media?.Split(',').First().ToNullableInt();
            var createdMedias = _mediaHelper.CreateMedia(model).ToList();

            if (createdMedias.Any())
            {
                group.ImageId = createdMedias.First();
            }
            _groupService.Edit(group);
            _groupMediaService.GroupTitleChanged(group.Id, group.Title);
            return(Redirect(_groupLinkProvider.GetGroupLink(group.Id)));
        }
        public override string Create(GroupCreateModel model)
        {
            var group = AutoMapperExtensions.Map <GroupModel>(model);

            group.GroupTypeId = GroupTypeEnum.Open.ToInt();

            var createdMedias = _mediaHelper.CreateMedia(model).ToList();

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

            var groupId = _groupService.Create(group);

            Add(groupId, model.Creator);

            _groupMediaService.GroupTitleChanged(groupId, group.Title);

            return(_groupLinkProvider.GetGroupLink(groupId));
        }
        public Guid Create(GroupCreateModel model, GroupMemberSubscriptionModel creator)
        {
            var group = model.Map <GroupModel>();

            group.CreatorId = _memberService.GetCurrentMemberId();

            group.GroupTypeId = GroupTypeEnum.Open.ToInt();

            var createdMedias = _mediaHelper.CreateMedia(model, MediaFolderTypeEnum.GroupsContent).ToList();

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

            var groupId = _groupService.Create(group);

            Add(groupId, creator);

            _groupMediaService.GroupTitleChanged(groupId, @group.Title);

            return(groupId);
        }