public override ConverterResponseModel MapViewModel(SocialEditPageModel node, SocialEditPageViewModel viewModel) { var id = _context.ParseQueryString("id").TryParseGuid(); if (!id.HasValue) { return(NotFoundResult()); } var social = _socialService.Get(id.Value); if (social == null) { return(NotFoundResult()); } if (social.GroupId.HasValue) { var group = _groupService.Get(social.GroupId.Value); if (group != null && group.IsHidden) { return(NotFoundResult()); } } if (!_socialService.CanEdit(id.Value)) { return(ForbiddenResult()); } viewModel.CanDelete = _socialService.CanDelete(id.Value); viewModel.OwnerId = social.OwnerId; viewModel.Id = social.Id; viewModel.Description = social.Description; viewModel.Name = _localizationModelService["Social.Edit"]; viewModel.Tags = _userTagService.Get(id.Value); viewModel.LightboxPreviewModel = _lightboxHelper.GetGalleryPreviewModel(social.MediaIds, PresetStrategies.ForActivityDetails); viewModel.AvailableTags = _userTagProvider.GetAll(); viewModel.Links = _feedLinkService.GetLinks(social.Id); var mediaSettings = _socialService.GetMediaSettings(); viewModel.AllowedMediaExtensions = mediaSettings.AllowedMediaExtensions; var groupId = HttpContext.Current.Request["groupId"].TryParseGuid(); if (groupId.HasValue && social.GroupId == groupId.Value) { viewModel.GroupHeader = _groupHelper.GetHeader(groupId.Value); } return(OkResult()); }
private SocialCreateDataViewModel GetData(Guid?groupId) { var model = new SocialCreateDataViewModel(); var currentMember = _memberService.GetCurrentMember(); model.Links = model.GroupId.HasValue ? _feedLinkService.GetCreateLinks(ActivityType, model.GroupId.Value) : _feedLinkService.GetCreateLinks(ActivityType); var mediaSettings = _socialService.GetMediaSettings(); model.AllowedMediaExtensions = mediaSettings.AllowedMediaExtensions; model.Tags = _tagProvider.GetAll(); model.Creator = currentMember.ToViewModel(); model.GroupId = groupId; model.Date = DateTime.UtcNow.ToDateFormat(); return(model); }