示例#1
0
        public void SavePlacement(Placement b)
        {
            var context = new TourEntities1();

            if (b.Id == 0)
            {

                context.Placement.Add(b);
            }
            else
            {

                Placement dbEntry = context.Placement.Find(b.Id);
                if (dbEntry != null)
                {

                    dbEntry.Description = b.Description;

                    dbEntry.Name = b.Name;

                }
            }

            context.SaveChanges();
        }
示例#2
0
        public ActionResult EditPlacement(Placement tour, HttpPostedFileBase image)
        {
            var context = new TourEntities1();
            if (ModelState.IsValid)
            {

                SavePlacement(tour);
                TempData["message"] = string.Format("{0} has been saved", tour.Name);
                return RedirectToAction("Index", "Admin");
            }
            else
            {
                // there is something wrong with the data values
                return View(tour);
            }
        }