public bool CreateItinerary(ItineraryCreate model)
        {
            var entity = new Itinerary()
            {
                ItineraryDate = model.ItineraryDate,
                ItineraryName = model.ItineraryName,
                Region        = model.Region
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Itinerarys.Add(entity);
                return
                    (ctx.SaveChanges() == 1);
            }
        }
        public ActionResult Create(ItineraryCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateService();

            if (service.CreateItinerary(model))
            {
                TempData["SaveResult"] = "Your activity is saved!";
                return(RedirectToAction("Index"));
            }
            ModelState.AddModelError("", "Activity could not be saved.");
            return(View(model));
        }
Ejemplo n.º 3
0
        //--THE REST OF THESE GO IN CONTRACTS
        public bool CreateItinerary(ItineraryCreate model)
        {
            var entity =
                new Itinerary()
            {
                OwnerID             = _userID,
                ItineraryID         = model.ItineraryID,
                ActivityName        = model.ActivityName,
                ActivityDescription = model.ActivityDescription,
                Type         = model.Type,
                ActivityCost = model.ActivityCost,
                ActivityDate = model.ActivityDate
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Itineraries.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }