public ActionResult Edit([Bind(Include = "Id,Description,Name,Score,Category,Address,Photos")] Objective objective) { if (ModelState.IsValid) { ctx.Entry(objective).State = EntityState.Modified; foreach (var p in objective.Photos) { ctx.Entry(p).State = EntityState.Modified; } ctx.SaveChanges(); return(RedirectToAction("Details/" + objective.Category, "Category", null)); } return(View(objective)); }
public ActionResult Create(string TourTitle, List <int> obj, List <int> transport, List <String> info) { var tour = new Tour(); var j = 0; var id = 0; var ObjTours = new List <ObjectiveTour>(); tour.Name = TourTitle; tour.Stops = obj.Count(); tour.Rating = 0; tour.User = _usersWorkerSvc.GetUserFromFacebookID(Session["FacebookID"].ToString()); db.Tours.Add(tour); db.Entry(tour.User).State = EntityState.Unchanged; db.SaveChanges(); id = _toursWorkerSvc.GetLastTourID(); foreach (var i in obj) { db.ObjectiveTour.Add(new ObjectiveTour { ObjectiveId = i, TourId = id, SortOrder = j++ }); } j = 0; foreach (var i in transport) { db.TransportTour.Add(new TransportTour { TransportId = i, Info = info[j], TourId = id, SortOrder = j++ }); } db.SaveChanges(); return(Redirect("/Tours/Index")); }