public ActionResult Create(Venues venues, HttpPostedFileBase ImagePath) { try { if (!ModelState.IsValid) { var viewModel = new VenueCitiesViewModel { Venues = venues, Cities = _context.Cities.ToList() }; } venues.ApplicationUserCreatedById = "4af95f1c-0f73-4df9-bb6d-166a07b6e5f4"; venues.ApplicationUserCreatedDate = DateTime.Now; venues.ApplicationUserLastUpdatedById = venues.ApplicationUserCreatedById; venues.ApplicationUserLastUpdatedDate = DateTime.Now; // TODO: Add insert logic here _context.venues.Add(venues); _context.SaveChanges(); return(RedirectToAction("CreateImages/" + venues.Id)); } catch { return(View()); } }
public ActionResult Edit(int id, Venues venues) { try { if (!ModelState.IsValid) { var viewModel = new VenueCitiesViewModel { Venues = venues, Cities = _context.Cities.ToList() }; //return View("CustomerForm", viewModel); } // TODO: Add update logic here var venueinDb = _context.venues.Single(v => v.Id == venues.Id); venueinDb.VenueName = venues.VenueName; venueinDb.Address = venues.Address; venueinDb.Street = venues.Street; venueinDb.Sector = venues.Sector; venueinDb.CityId = venues.CityId; venueinDb.Introduction = venues.Introduction; venueinDb.ContactNo = venues.ContactNo; //venueinDb.ImagePath = venues.ImagePath; _context.SaveChanges(); return(RedirectToAction("CreateImages/" + id)); } catch { return(View()); } }
// GET: Venues/Create public ActionResult Create(Venues venues) { if (!ModelState.IsValid) { var viewModel = new VenueCitiesViewModel { Venues = venues, Cities = _context.Cities.ToList() }; return(View("Create", viewModel)); } else { return(RedirectToAction("Index")); } }
// GET: Venues/Edit/5 public ActionResult Edit(int id) { var venues = _context.venues.SingleOrDefault(c => c.Id == id); if (venues == null) { return(HttpNotFound()); } var viewModel = new VenueCitiesViewModel { Venues = venues, Cities = _context.Cities.ToList() }; return(View(viewModel)); }