コード例 #1
0
        public ActionResult Create(Venue venue)
        {
            if (ModelState.IsValid)
            {
                db.Venues.AddObject(venue);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.CountryId = new SelectList(db.Countries, "CountryId", "CountryName", venue.CountryId);
            return View(venue);
        }
コード例 #2
0
 public ActionResult Edit(Venue venue)
 {
     if (ModelState.IsValid)
     {
         db.Venues.Attach(venue);
         db.ObjectStateManager.ChangeObjectState(venue, EntityState.Modified);
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.CountryId = new SelectList(db.Countries, "CountryId", "CountryName", venue.CountryId);
     return View(venue);
 }
コード例 #3
0
 /// <summary>
 /// Create a new Venue object.
 /// </summary>
 /// <param name="venueId">Initial value of the VenueId property.</param>
 /// <param name="venueName">Initial value of the VenueName property.</param>
 /// <param name="countryId">Initial value of the CountryId property.</param>
 public static Venue CreateVenue(global::System.Int32 venueId, global::System.String venueName, global::System.Int32 countryId)
 {
     Venue venue = new Venue();
     venue.VenueId = venueId;
     venue.VenueName = venueName;
     venue.CountryId = countryId;
     return venue;
 }
コード例 #4
0
        public JsonResult JsonCreate(Venue venue)
        {
            if (ModelState.IsValid)
            {
                if (ModelState.IsValid)
                {
                    db.Venues.AddObject(venue);
                    db.SaveChanges();

                    return Json(new { success = true, returnData = new { venueId = venue.VenueId, venueName = venue.VenueName } });
                }
            }

            // If we got this far, something failed
            return Json(new { errors = GetErrorsFromModelState() });
        }
コード例 #5
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Venues EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToVenues(Venue venue)
 {
     base.AddObject("Venues", venue);
 }