// 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); }
/// <summary> /// Add Item to Shopping Cart /// </summary> /// <param name="id"></param> /// <param name="userId"></param> /// <returns>Num Items inside of Shopping Cart</returns> public int Add(int id, string userId) { // Get the cart from a blob if doesnt exist create a object var cart = GetCart(userId) ?? new ShoppingCartModel(); // get the image to Add in the cart var image = new PicPopImagesHelper().FindById(id); // Check if the image exist if (image == null) return cart.ListItems.Count; // Check if doesnt exist the image inside of the shopping cart if (!cart.ListItems.Any(x => x.Id.Equals(id))) cart.ListItems.Add(new ShoppingCartItemModel() { Id = id, Name = image.Name, Amount = image.Amount }); cart.TotalAmount = cart.ListItems.Sum(x => x.Amount); //TODO: Necesito calcular el Total Amount // save shopping cart SaveCart(userId, cart); return cart.ListItems.Count; }
public ActionResult Create(ImagesCreateViewModels images) { if (ModelState.IsValid) { string userId = User.Identity.GetUserId(); int categoryId; if (!int.TryParse(images.CategoryId, out categoryId)) categoryId = 0; var lstBlobs = new PicPop.Helper.PicPopImagesHelper().CreateImage(userId, images.File); PicPopImage image = new PicPopImage { Name = images.Name, Amount = images.Amount, DtAdded = DateTime.Now, UserId = userId, BlobFiles = lstBlobs, CategoryId = categoryId == 0 ? (int?) null : categoryId, CreatedBy = userId }; var imageHelper = new PicPopImagesHelper(); imageHelper.Add(image); return RedirectToAction("MyImages"); } images.Categories = PicPop.Helper.CategoriesHelper.GetCategoriesSelectedItems(); return View(images); }
public ActionResult Index(int? categoryId) { if (categoryId.HasValue) return RedirectToAction("Index", "Image", new {id = categoryId}); var images = new PicPopImagesHelper(); var lstImagesCarrousel = images.GetUrlImages(numImages: 5); var lastImagesInserted = images.LastImages(10); var model = new HomeViewModel() { Categories = PicPop.Helper.CategoriesHelper.GetCategoriesSelectedItems(), ListImages = lstImagesCarrousel.Select(CloudStorageManagerHelper.GetUrlInfo).ToList(), LastImagesInserted = lastImagesInserted.Select(CloudStorageManagerHelper.GetUrlInfo).ToList(), NumImages = lstImagesCarrousel.Count }; return View(model); }
public ActionResult MyImages() { PicPopImagesHelper images = new PicPopImagesHelper(); List<PicPopImage> lst = images.GetMyImagesList(User.Identity.GetUserId()); IEnumerable<ImagesDetailsViewModels> model = lst.Select(x => new ImagesDetailsViewModels() { Id = x.Id.ToString(), Name = x.Name, Amount = x.Amount, Blob = CloudStorageManagerHelper.GetUrlInfo(x.BlobFiles.FirstOrDefault(y=>y.Container.Equals((int)BlobFileType.ImagesOriginal))), IsMine = true }).AsEnumerable(); return View(model); }
// GET: Images public ActionResult Index(int? id, int? page) { PicPopImagesHelper imagesHelper = new PicPopImagesHelper(); List<PicPopImage> lst = imagesHelper.GetShop(User.Identity.GetUserId(), id); IEnumerable<ImagesDetailsViewModels> lstImages = lst.Select(x => new ImagesDetailsViewModels() { Id = x.Id.ToString(), Name = x.Name, Amount = x.Amount, Blob = CloudStorageManagerHelper.GetUrlInfo( x.BlobFiles.First(y => y.Container.Equals((int) BlobFileType.ImagesWaterMark))), IsMine = true }).AsEnumerable(); ImageSearchViewModel model = new ImageSearchViewModel() { Categories = PicPop.Helper.CategoriesHelper.GetCategoriesSelectedItems(), List = lstImages.ToPagedList(page??1, 12), Id = id }; return View(model); }
public ActionResult Edit(int id, ImagesEditViewModels model) { try { if (ModelState.IsValid) { int categoryId; var imageHelper = new PicPopImagesHelper(); PicPopImage image = imageHelper.FindById(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"); image.Name = model.Name; image.Amount = model.Amount; image.DtModified = DateTime.Now; image.UserId = User.Identity.GetUserId(); if (!int.TryParse(model.CategoryId, out categoryId)) categoryId = 0; image.CategoryId = categoryId == 0 ? (int?) null : categoryId; imageHelper.Update(image); return RedirectToAction("MyImages"); } return View(model); } catch { return View(); } }
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); }