Ejemplo n.º 1
0
        // GET: Images/Details/5
        public ActionResult Details(int id)
        {
            var imageHelper = new PicPopImagesHelper();
            PicPopImage image = imageHelper.Details(id);

            // Check if the image exist and if the image is relationship with the user
            if (image == null) //|| !image.UserId.Equals(User.Identity.GetUserId()))
                return RedirectToAction("Index");

            string userId = User.Identity.GetUserId();
            int containerId = (int) BlobFileType.ImagesWaterMark;
            if (!string.IsNullOrEmpty(userId) &&
                (image.UserId.Equals(userId) ||
                 (image.TransactionItems != null && image.TransactionItems.Any(y=>y.Transaction.UserId.Equals(userId)))))
                containerId = (int) BlobFileType.ImagesOriginal;

            ImagesDetailsViewModels model = new ImagesDetailsViewModels()
            {
                Id = image.Id.ToString(),
                Name = image.Name,
                Amount = image.Amount,
                //Blob = CloudStorageManagerHelper.GetUrlInfo(BlobFileType.ImagesOriginal, image.BlobFiles.First().BlobKey),
                Blob = CloudStorageManagerHelper.GetUrlInfo(image.BlobFiles.First(y => y.Container.Equals(containerId))),
                Category = image.CategoryId.HasValue ? image.Category.Name : "None",
                IsMine = image.UserId.Equals(User.Identity.GetUserId())
            };

            return View(model);
        }
Ejemplo n.º 2
0
        public ActionResult Edit(int id)
        {
            var imageHelper = new PicPopImagesHelper();
            PicPopImage image = imageHelper.Details(id);

            // Check if the image exist and if the image is relationship with the user
            if (image == null || !image.UserId.Equals(User.Identity.GetUserId()))
                return RedirectToAction("Index");

            ImagesEditViewModels model = new ImagesEditViewModels()
            {
                Name = image.Name,
                Amount = image.Amount,
                CategoryId = image.CategoryId.ToString(),
                Categories = PicPop.Helper.CategoriesHelper.GetCategoriesSelectedItems(),
                //Blob = CloudStorageManagerHelper.GetUrlInfo(BlobFileType.ImagesOriginal, image.BlobFiles.First().BlobKey)
                Blob = CloudStorageManagerHelper.GetUrlInfo(image.BlobFiles.First())
            };

            return View(model);
        }