Example #1
0
        /// <summary>
        /// View either your own profile image, or another user's if you pass their profile id
        /// </summary>
        /// <param name="profileId">profileID, optional</param>
        /// <returns></returns>
        public ActionResult ViewProfileImage(Guid? profileId)
        {
            Profile profile;

            if (profileId.HasValue)
            {
                profile =
                    RepositoryFactory.ProfileRepository.Queryable.SingleOrDefault(x => x.Id == profileId.Value);
            }
            else
            {
                profile =
                    RepositoryFactory.ProfileRepository.Queryable.SingleOrDefault(
                        x => x.User.Identifier == CurrentUser.Identity.Name);
            }

            if (profile == null || string.IsNullOrWhiteSpace(profile.ImageUrl))
            {
                return PartialView(null);
            }

            var model = new ImageModel {Alt = "Profile Image", Width = 120, Height = 120};

            model.Url =
                new CompositionBuilder().WithLayer(
                    LayerBuilder.Image.SourceUrl(profile.ImageUrl)
                                .WithFilter(FilterBuilder.Resize.To(model.Width, model.Height)))
                                        .Url;

            return PartialView(model);
        }