Exemplo n.º 1
0
        public ActionResult Edit(ShopInputViewModel model)
        {
            if (ModelState.IsValid)
            {
                var shopUpdate = new Shop()
                {
                    Id          = model.ShopId,
                    Description = model.Description,
                    Name        = model.Name,
                    UserId      = model.UserId
                };
                this.AddPhoto(model.ShopId, model.ImageFile);

                this.Data.Shops.Update(shopUpdate);
                this.Data.SaveChanges();

                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
Exemplo n.º 2
0
        public ActionResult Create(ShopInputViewModel model)
        {
            var userId = this.UserProfile.Id;

            ViewData["UserId"] = userId;
            model.UserId       = userId;
            if (ModelState.IsValid)
            {
                Shop newShop = new Shop()
                {
                    UserId      = userId,
                    Name        = model.Name,
                    Description = model.Description,
                };
                this.Data.Shops.Add(newShop);
                this.Data.SaveChanges();
                this.AddPhoto(newShop.Id, model.ImageFile);
                ViewBag.Message = "Shop created successfully.";

                return(this.RedirectToAction("Index"));
            }

            return(View(model));
        }
Exemplo n.º 3
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Shop shop = this.Data.Shops.Find(id);

            if (shop == null)
            {
                return(HttpNotFound());
            }

            var model = new ShopInputViewModel()
            {
                UserId      = shop.UserId,
                ShopId      = shop.Id,
                Name        = shop.Name,
                Description = shop.Description,
                ImagePath   = shop.Images.FirstOrDefault().ImagePath
            };

            return(View(model));
        }
Exemplo n.º 4
0
        public ActionResult Create()
        {
            var model = new ShopInputViewModel();

            return(View(model));
        }