Badges.Controllers.ProfileController.ViewProfileImage C# (CSharp) Method

ViewProfileImage() public method

View either your own profile image, or another user's if you pass their profile id
public ViewProfileImage ( System.Guid profileId ) : System.Web.Mvc.ActionResult
profileId System.Guid profileID, optional
return System.Web.Mvc.ActionResult
        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);
        }