Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        public ActionResult Create()
        {
            var model = new ImagesCreateViewModels()
            {
                Categories = PicPop.Helper.CategoriesHelper.GetCategoriesSelectedItems()
            };

            return View(model);
        }