public ActionResult Create(Gallery gallery, HttpPostedFileBase imagen)
        {
            if (ModelState.IsValid)
            {
                if (imagen == null)
                {
                    return View();
                }

                if (imagen.ContentLength == 0)
                {
                    return View();
                }
                _db.Galleries.Add(gallery);
                var bar = (from u in _db.Bars
                             where u.BarID == gallery.BarId
                             select u).Single();

                var reader = new StreamReader(imagen.InputStream);
                imagen.SaveAs(Server.MapPath("/Content/gallery/") + bar.BarName + imagen.FileName);
                gallery.UrlImage = "../../Content/gallery/" + bar.BarName + imagen.FileName;
                gallery.IsActived = true;
                gallery.RegisterDate = DateTime.Now;

                _db.SaveChanges();

                return RedirectToAction("Index");
            }

            ViewBag.UPUserID = new SelectList(_db.Bars, "UPUserID", "upUserName", gallery.BarId);
            return View(gallery);
        }
        //
        // GET: /Gallery/Create
        public ActionResult Create()
        {
            //ViewBag.UPUserID = new SelectList(db.UPUsers, "UPUserID", "upUserName");
            Bar bars = _db.Bars.FirstOrDefault(c => c.Email.Equals(User.Identity.Name));

            var model = new Gallery()
                {
                    BarId = bars.BarID,
                    Bar = bars
                };

            return View(model);
        }
 public ActionResult Edit(Gallery gallery)
 {
     if (ModelState.IsValid)
     {
         _db.Entry(gallery).State = EntityState.Modified;
         _db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.UPUserID = new SelectList(_db.Bars, "UPUserID", "upUserName", gallery.BarId);
     return View(gallery);
 }