public IHttpActionResult Get(int id) { var media = _mediaService.Get(id); if (media == null) { return(NotFound()); } var entityMedia = _entityMediaService.FirstOrDefault(x => x.MediaId == id); MediaReponseModel model = null; //todo: verify permissions to see if media can be viewed by logged in user switch (entityMedia.EntityName) { case "Skill": model = media.ToModel <Skill>(entityMedia.EntityId, _mediaService, _mediaSettings, _generalSettings, _userService, commentService: _commentService, likeService: _likeService, withSocialInfo: true, withNextAndPreviousMedia: true, avoidMediaTypeForNextAndPreviousMedia: true); break; case "UserSkill": model = media.ToModel <UserSkill>(entityMedia.EntityId, _mediaService, _mediaSettings, _generalSettings, _userService, commentService: _commentService, likeService: _likeService, withSocialInfo: true, withNextAndPreviousMedia: true, avoidMediaTypeForNextAndPreviousMedia: true); break; default: model = media.ToModel(_mediaService, _mediaSettings, _generalSettings, _userService, commentService: _commentService, likeService: _likeService, withSocialInfo: true, withNextAndPreviousMedia: true); break; } return(RespondSuccess(new { Media = model })); }
public IHttpActionResult Get(int id) { var media = _mediaService.GetById(id); if (media == null) { return(NotFound()); } var entityMedia = _entityMediaService.FirstOrDefault(x => x.MediaId == id); MediaReponseModel model = null; //todo: verify permissions to see if media can be viewed by logged in user switch (entityMedia.EntityName) { case "Skill": model = media.ToModel <Skill>(entityMedia.EntityId, _mediaService, _mediaSettings, _workContext, _storeContext, _userService, _customerProfileService, _customerProfileViewService, _pictureService, Url, _webHelper, _friendService, _commentService, _likeService, true, true, true, true); break; case "UserSkill": model = media.ToModel <UserSkill>(entityMedia.EntityId, _mediaService, _mediaSettings, _workContext, _storeContext, _userService, _customerProfileService, _customerProfileViewService, _pictureService, Url, _webHelper, _friendService, _commentService, _likeService, true, true, true, true); break; default: model = media.ToModel(_mediaService, _mediaSettings, _workContext, _storeContext, _userService, _customerProfileService, _customerProfileViewService, _customerFollowService, _friendService, _commentService, _likeService, _pictureService, Url, _webHelper, true, true, true); break; } return(Response(new { Success = true, Media = model })); }