Ejemplo n.º 1
0
        public ActionResult Create(AdventureLocationModel model)
        {
            using (var businessValidator = new LocationBusiness())
            {
                IList<ValidationResult> validationErrorResults = new List<ValidationResult>();
                if (businessValidator.Validate(model.AdventureLocation, validationErrorResults))
                {
                    // Assign the adventure region to the location object.
                    model.AdventureLocation
                        .Region = _adventureRegionRepository
                            .GetAdventureRegion(model.AdventureLocation.Region.Id);

                    var locationResponse = _adventureLocationRepository.SaveAdventureLocation(model.AdventureLocation);

                    return View("Details", locationResponse);
                }

                ErrorUtility.TransformResponseErrors(ModelState, validationErrorResults);

                model.SelectableAdventureRegions = _adventureRegionRepository.GetAdventureRegions();
                model.SelectableAdventureRegions.Insert(0, Region.CreateNewRegion);

            }

            return View(model);
        }
Ejemplo n.º 2
0
        public ActionResult Create()
        {
            var model = new AdventureLocationModel();

            model.SelectableAdventureRegions = _adventureRegionRepository.GetAdventureRegions();
            model.SelectableAdventureRegions.Insert(0, Region.CreateNewRegion);
            //model.SelectableAdventureRegions.Insert(0, new AdventureRegion(new LocationPoint() { Lat = double.MaxValue }, "** Create New Region **", "", ""));
            return View(model);
        }
Ejemplo n.º 3
0
        public ActionResult Edit(string id)
        {
            var locationResponse = _adventureLocationRepository.GetAdventureLocation(id);

            var model = new AdventureLocationModel()
                            {
                                AdventureLocation = locationResponse,
                                SelectableAdventureRegions = _adventureRegionRepository.GetAdventureRegions()
                            };
            model.SelectableAdventureRegions.Insert(0, Region.CreateNewRegion);

            return View(model);
        }