public ActionResult Create(NewPartnerCallViewModel m)
        {
            if (!m.ForOutdoor && !m.ForIndoor) { ModelState.AddModelError("For", "Your partner call must be for indoor, outdoor or both."); }

            if (ModelState.IsValid)
            {
                DateTime endDateTime;

                var startDateTime = DateTimeExtensions.ParseDateAndTime(m.StartDate, m.StartTime);
                DateTimeExtensions.TryParseDateAndTime(m.EndDate, m.EndTime, out endDateTime);

                var pc = pcSvc.CreatePartnerCall( new PartnerCall() { Comment = m.Comment, StartDateTime = startDateTime,
                    EndDateTime = endDateTime, ForIndoor = m.ForIndoor, ForOutdoor = m.ForOutdoor, PlaceID = m.ParnterCallPlaceID,
                    PreferredLevel = (byte)m.PreferredLevel }
                );

                if (!pcSvc.UserHasSubscriptionForRelatedGeo(m.ParnterCallPlaceID))
                {
                    var pcs = pcSvc.CreatePartnerCallSubscription(new PartnerCallSubscription()
                    {
                        ForIndoor = true,
                        ForOutdoor = true,
                        PlaceID = m.ParnterCallPlaceID,
                        EmailRealTime = true,
                        MobileRealTime = false,
                        ExactMatchOnly = false
                    });
                    //return RedirectToAction("SubscriptionSuggestion", new { id = m.ParnterCallPlaceID });
                }

                return RedirectToAction("ListPlace", new { id = m.ParnterCallPlaceID });
            }
            else
            {
                PrepareNewCallViewData(AppLookups.GetCacheIndexEntry(m.ParnterCallPlaceID));
                return View("New");
            }
        }
 public ActionResult Create(NewPartnerCallViewModel m)
 {
     //ViewBag.PartnerCalls = pcSvc.GetPlacesPartnerCalls(id);
     return View();
 }
        private NewPartnerCallViewModel PrepareNewCallViewData(CfCacheIndexEntry place)
        {
            var m = new NewPartnerCallViewModel() { ParnterCallPlaceID = place.ID, ForIndoor = true, ForOutdoor = true };

            if (place.Type == CfType.Country)
            {
                ViewBag.PlaceDisallowed = true;
                ViewBag.Place = place;
            }
            else if (place.Type == CfType.Province)
            {
                var area = geoSvc.GetAreaByID(place.ID);

                ViewBag.PlaceDisallowed = true;
                ViewBag.Place = place;

                ViewBag.InterectingAreas = geoSvc.GetIntersectingAreas(area).Where(a => a.Type != CfType.Province
                    && !a.DisallowPartnerCalls).ToList();
            }
            else if (place.Type.ToPlaceCateogry() == PlaceCategory.Area)
            {
                ViewBag.PlaceType = "Area";
                var area = geoSvc.GetAreaByID(place.ID);
                ViewBag.Place = area;

                if (area.DisallowPartnerCalls) { ViewBag.PlaceDisallowed = true; }
                else
                {
                    var geoJsonUrl = Stgs.MapSvcRelativeUrl + "area/" + place.ID.ToString();

                    var mapModel = new Bing7GeoJsonMapViewModel("climbing-map-" + place.ID, 680, 400, geoJsonUrl);
                    mapModel.ViewOptions = new Bing7MapViewOptionsViewModel(mappingSvc.GetBingViewByID(area.ID));
                    var mapItems = new MappingService().GetAreaEditMapItems(area);
                    ViewBag.MapItemsArea = mapItems.Items[0];
                    mapItems.Items.RemoveAt(0);
                    ViewBag.MapItemsLocations = mapItems.Items;
                    ViewBag.MapModel = mapModel;
                }

                ViewBag.ChildLocations = geoSvc.GetGeoDeduciblePlaces(place).Where(p=>p.Type.IsLocation());

                ViewBag.InterectingAreas = geoSvc.GetIntersectingAreas(area).Where(a => a.Type != CfType.Province
                    && !a.DisallowPartnerCalls).ToList();
            }
            else if (place.Type.ToPlaceCateogry() == PlaceCategory.IndoorClimbing
                || place.Type.ToPlaceCateogry() == PlaceCategory.OutdoorClimbing)
            {
                ViewBag.PlaceType = "Location";
                var location = geoSvc.GetLocationByID(place.ID);
                ViewBag.Place = location;

                if (location.IsIndoorClimbing) { m.ForOutdoor = false; }
                if (location.IsOutdoorClimbing) { m.ForIndoor = false; }

                var mapModel = new Bing7MapWithLocationViewModel(location.NameUrlPart, 732, 340, location.Latitude,
                    location.Longitude, location.AvatarRelativeUrl);

                var mapViewSettings = mappingSvc.GetBingViewByID(location.ID);
                if (mapViewSettings == default(PlaceBingMapView)) { mapViewSettings = PlaceBingMapView.GetDefaultIndoorSettings(location); }
                mapModel.ViewOptions = new Bing7MapViewOptionsViewModel(mapViewSettings);
                ViewBag.LocationMapView = mapModel;

                ViewBag.InterectingAreas = geoSvc.GetIntersectingAreasOfPoint(location.Latitude, location.Longitude)
                    .Where(a => a.Type != CfType.Province && !a.DisallowPartnerCalls).ToList();
            }
            else
            {
                throw new ArgumentException("Place type [" + place.Type.ToString() + "] not supported for partner calls");
            }

            return m;
        }