コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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));
        }
コード例 #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);
            }
        }