Exemplo n.º 1
0
        public ActionResult MyPhoto(int id)
        {
            var userId = Helper_Classes.UserHelpers.GetUserProfile().Id;

            var viewModel = new ViewPhotoViewModel();
            //viewModel.Photo = _context.UserProgressLogs.SingleOrDefault(m => m.Id == id).Photo.Photo;
            var photoBase64 = Convert.ToBase64String(_context.UserPhotos.SingleOrDefault(m => m.Id == id).Photo);


            //viewModel.Photo = new HtmlString("<img src=\"data:image/*;base64," + photoBase64 + "\"");
            viewModel.Photo = photoBase64;
            //viewModel.PhotoString = new HtmlString("\"<img src=\"data:image/*;base64," + photoBase64 + "\">");


            return(View(viewModel));
        }
Exemplo n.º 2
0
        public ActionResult Photo(int id)
        {
            if (new ApplicationDbContext().UserPhotos.SingleOrDefault(m => m.Id == id).Photo == null)
            {
                return(HttpNotFound());
            }

            var dbPhoto =
                Convert.ToBase64String(new ApplicationDbContext().UserPhotos.SingleOrDefault(m => m.Id == id).Photo);
            //var imgSrc = "'" + String.Format("data:image/jpg;base64,{0}", dbPhoto) + "'";
            var imgSrc = "'" + String.Format("data:image/jpg;base64,{0}", dbPhoto) + "'";
            var img    = new HtmlString(String.Format("<img  class='img-thumbnail' src={0}/>", imgSrc));

            var viewModel = new ViewPhotoViewModel();

            viewModel.Photo = dbPhoto;
            return(View(viewModel));
        }
        public IActionResult ViewPhoto(int id)
        {
            var photo  = this._photoFileProcessor.PhotoService.GetPhotoById(id);
            var userId = this._userSessionService.GetCurrentUserID();

            if (photo != null)
            {
                var vm = new ViewPhotoViewModel()
                {
                    Id                   = photo.Id,
                    Title                = photo.Title,
                    Path                 = photo.Path,
                    Views                = this._photoFileProcessor.PhotoService.IncreasePhotoViews(id),
                    UploaderId           = photo.UploaderId,
                    DateUploaded         = photo.DateUploaded,
                    DoesUserLikeThePhoto = this._likeService.DoesUserLikeThePhoto(userId, id),
                    Likes                = this._likeService.GetLikesCount(id),
                    ViewerIsTheUploader  = photo.UploaderId == userId
                };
                return(View(vm));
            }

            return(RedirectToAction("ErrorNotFound", "Error"));
        }