Exemple #1
0
        public ActionResult AddMediaItem(int id)
        {
            var cpManager = new API.Common.POIManager();
            var poi       = cpManager.Get(id, true);

            return(View(poi));
        }
        public ActionResult AddMediaItem(int id)
        {
            var cpManager = new API.Common.POIManager();
            var poi = cpManager.Get(id, true);

            return View(poi);
        }
        public async Task <ActionResult> AddMediaItem(int id)
        {
            ViewBag.IsReadOnlyMode = this.IsReadOnlyMode;

            var cpManager = new API.Common.POIManager();
            var poi       = await cpManager.Get(id, true);

            return(View(poi));
        }
        public ActionResult AddComment(int id)
        {
            var cpManager = new API.Common.POIManager();
            var poi = cpManager.Get(id, true);

            POIViewModel viewModel = new POIViewModel();
            viewModel.NewComment = new UserComment() { ChargePointID = poi.ID, CommentType = new UserCommentType { ID = 10 }, CheckinStatusType = new CheckinStatusType { ID = 0 } };
            viewModel.POI = poi;

            ViewBag.ReferenceData = new POIBrowseModel();

            return View(viewModel);
        }
Exemple #5
0
        public ActionResult AddComment(int id)
        {
            var cpManager = new API.Common.POIManager();
            var poi       = cpManager.Get(id, true);

            POIViewModel viewModel = new POIViewModel();

            viewModel.NewComment = new UserComment()
            {
                ChargePointID = poi.ID, CommentType = new UserCommentType {
                    ID = 10
                }, CheckinStatusType = new CheckinStatusType {
                    ID = 0
                }
            };
            viewModel.POI = poi;

            ViewBag.ReferenceData = new POIBrowseModel();

            return(View(viewModel));
        }
        public async Task <ActionResult> AddComment(int id)
        {
            ViewBag.IsReadOnlyMode = this.IsReadOnlyMode;

            var cpManager = new API.Common.POIManager();
            var poi       = await cpManager.Get(id, true);

            POIViewModel viewModel = new POIViewModel();

            viewModel.NewComment = new UserComment()
            {
                ChargePointID = poi.ID, CommentType = new UserCommentType {
                    ID = 10
                }, CheckinStatusType = new CheckinStatusType {
                    ID = 0
                }
            };
            viewModel.POI = poi;

            ViewBag.ReferenceData = new POIBrowseModel(GetCoreReferenceData());

            return(View(viewModel));
        }
        public async Task <ActionResult> Index(POIBrowseModel filter)
        {
            if (filter?.ReferenceData == null)
            {
                if (filter == null)
                {
                    filter = new POIBrowseModel();
                    filter.ShowAdvancedOptions = true;
                }
                filter.ReferenceData = await GetCoreReferenceDataAsync();
            }

            var cpManager = new API.Common.POIManager();

            //dropdown selections of -1 represent an intended null selection, fix this by nulling relevant items
            filter.CountryIDs        = this.ConvertNullableSelection(filter.CountryIDs);
            filter.LevelIDs          = this.ConvertNullableSelection(filter.LevelIDs);
            filter.ConnectionTypeIDs = this.ConvertNullableSelection(filter.ConnectionTypeIDs);
            filter.OperatorIDs       = this.ConvertNullableSelection(filter.OperatorIDs);
            filter.StatusTypeIDs     = this.ConvertNullableSelection(filter.StatusTypeIDs);
            filter.UsageTypeIDs      = this.ConvertNullableSelection(filter.UsageTypeIDs);
            filter.DataProviderIDs   = this.ConvertNullableSelection(filter.DataProviderIDs);
            filter.IncludeComments   = true;

            if (IsRequestByRobot)
            {
                //force mirror db when browser is a robot
                filter.AllowMirrorDB    = true;
                filter.AllowDataStoreDB = false;
            }

            if (!String.IsNullOrWhiteSpace(filter.Country))
            {
                //TODO: cache country id lookup
                using (var refData = new OCM.API.Common.ReferenceDataManager())
                {
                    var countrySelected = refData.GetCountryByName(filter.Country);
                    if (countrySelected != null)
                    {
                        filter.CountryIDs = new int[] { countrySelected.ID };
                    }
                }
            }
            else
            {
                //default to UK
                // if (filter.CountryIDs == null) filter.CountryIDs = new int[] { 1 };
            }

            filter.MaxResults = 100;

            if (!String.IsNullOrWhiteSpace(filter.SearchLocation))
            {
                if (filter.SearchLocation.ToUpper().StartsWith("OCM-"))
                {
                    filter.SearchLocation = filter.SearchLocation.Replace("OCM-", "");
                }
                if (filter.SearchLocation.ToUpper().StartsWith("OCM"))
                {
                    filter.SearchLocation = filter.SearchLocation.Replace("OCM", "");
                }

                if (IsNumeric(filter.SearchLocation.Trim()))
                {
                    int poiID = -1;
                    //treat numbers as OCM ref
                    if (int.TryParse(filter.SearchLocation.Trim(), out poiID))
                    {
                        filter.ChargePointIDs = new int[] { poiID };
                    }
                }
                else
                {
                    //attempt to geocode
                    var    geocode           = new GeocodingHelper(_settings);
                    string searchCountryName = null;
                    if (filter.CountryIDs != null && filter.CountryIDs.Count() > 0)
                    {
                        var searchCountry = filter.ReferenceData.Countries.FirstOrDefault(c => c.ID == filter.CountryIDs[0]);
                        searchCountryName = searchCountry.Title;
                    }

                    API.Common.Model.Extended.GeocodingResult position = null;

                    // FIXME: geocoding is disabled, find an laternative service to use
                    //geocode.GeolocateAddressInfo_Google(filter.SearchLocation.Trim() + (searchCountryName != null ? ", " + searchCountryName : ""));

                    if (filter.SearchLocation.Contains(","))
                    {
                        var vals = filter.SearchLocation.Split(',');
                        if (IsNumeric(vals[0]) && IsNumeric(vals[1]))
                        {
                            position = new API.Common.Model.Extended.GeocodingResult
                            {
                                Latitude  = double.Parse(vals[0]),
                                Longitude = double.Parse(vals[1])
                            };
                        }
                    }
                    if (position != null)
                    {
                        filter.Latitude  = position.Latitude;
                        filter.Longitude = position.Longitude;
                        if (filter.Distance == null)
                        {
                            filter.Distance = 50;
                        }
                        filter.DistanceUnit = API.Common.Model.DistanceUnit.Miles;
                        //TODO: distance unit KM
                        //if (distanceunit == "km") searchfilters.DistanceUnit = API.Common.Model.DistanceUnit.KM;

                        ViewBag.FormattedAddress = position.Address ?? "";
                    }
                }
            }

            filter.POIList = (await cpManager.GetPOIListAsync((OCM.API.Common.APIRequestParams)filter, filter.ReferenceData)).ToList();
            return(View(filter));
        }
        // GET: /POI/Details/5

        //[OutputCache(Duration=240, VaryByParam="id")]
        public async Task <ActionResult> Details(int id = 0, string layout = null, string status = null)
        {
            if (id <= 0)
            {
                return(RedirectToAction("Index"));
            }

            if (status != null)
            {
                ViewBag.Status = status;
            }

            OCM.API.Common.POIManager cpManager = new API.Common.POIManager();
            POIViewModel viewModel = new POIViewModel();

            var poi = await cpManager.Get(id, true, allowDiskCache : false, allowMirrorDB : true);

            if (poi != null)
            {
                ViewBag.FullTitle = "Location Details: OCM-" + poi.ID + " " + poi.AddressInfo.Title;

                List <LocationImage> imageList = null; // new OCM.MVC.App_Code.GeocodingHelper().GetGeneralLocationImages((double)poi.AddressInfo.Latitude, (double)poi.AddressInfo.Longitude);

                if (imageList != null)
                {
                    imageList         = imageList.Where(i => i.Width >= 500).ToList();
                    ViewBag.ImageList = imageList.ToList();
                }

                viewModel.POI = poi;

                if (!IsRequestByRobot)
                {
                    viewModel.NewComment = new UserComment()
                    {
                        ChargePointID = poi.ID, CommentType = new UserCommentType {
                            ID = 10
                        }, CheckinStatusType = new CheckinStatusType {
                            ID = 0
                        }
                    };

                    System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
                    sw.Start();
                    viewModel.POIListNearby = (await cpManager.GetPOIListAsync(new APIRequestParams {
                        MaxResults = 10, Latitude = poi.AddressInfo.Latitude, Longitude = poi.AddressInfo.Longitude, Distance = 15, DistanceUnit = DistanceUnit.Miles, AllowMirrorDB = true
                    })).ToList();
                    viewModel.POIListNearby.RemoveAll(p => p.ID == poi.ID); //don't include the current item in nearby POI list
                    sw.Stop();
                    System.Diagnostics.Debug.WriteLine(sw.ElapsedMilliseconds);

                    ViewBag.ReferenceData = new POIBrowseModel(await GetCoreReferenceDataAsync());

                    //get data quality report

                    //if (IsUserAdmin)
                    //{
                    viewModel.DataQualityReport = new DataAnalysisManager().GetDataQualityReport(poi);
                    //}

                    ViewBag.UserCanEditPOI = false;
                    if (IsUserSignedIn)
                    {
                        var user = new UserManager().GetUser((int)UserID);
                        if (POIManager.CanUserEditPOI(poi, user))
                        {
                            ViewBag.UserCanEditPOI = true;
                        }
                    }
                }
                else
                {
                    viewModel.POIListNearby = new List <ChargePoint>();
                }
            }

            return(View(viewModel));
        }
Exemple #9
0
        // GET: /POI/

        public ActionResult Index(POIBrowseModel filter)
        {
            if (filter == null)
            {
                filter = new POIBrowseModel();
                filter.ShowAdvancedOptions = true;
            }
            var cpManager = new API.Common.POIManager();

            //dropdown selections of -1 represent an intended null selection, fix this by nulling relevant items
            filter.CountryIDs        = this.ConvertNullableSelection(filter.CountryIDs);
            filter.LevelIDs          = this.ConvertNullableSelection(filter.LevelIDs);
            filter.ConnectionTypeIDs = this.ConvertNullableSelection(filter.ConnectionTypeIDs);
            filter.OperatorIDs       = this.ConvertNullableSelection(filter.OperatorIDs);
            filter.StatusTypeIDs     = this.ConvertNullableSelection(filter.StatusTypeIDs);
            filter.UsageTypeIDs      = this.ConvertNullableSelection(filter.UsageTypeIDs);
            filter.DataProviderIDs   = this.ConvertNullableSelection(filter.DataProviderIDs);
            filter.IncludeComments   = true;

            if (IsRequestByRobot)
            {
                //force mirror db when browser is a robot
                filter.AllowMirrorDB = true;
            }

            if (!String.IsNullOrWhiteSpace(filter.Country))
            {
                //TODO: cache country id lookup
                var countrySelected = new OCM.API.Common.ReferenceDataManager().GetCountryByName(filter.Country);
                if (countrySelected != null)
                {
                    filter.CountryIDs = new int[] { countrySelected.ID };
                }
            }
            else
            {
                //default to UK
                // if (filter.CountryIDs == null) filter.CountryIDs = new int[] { 1 };
            }

            filter.MaxResults = 100;

            if (!String.IsNullOrWhiteSpace(filter.SearchLocation))
            {
                if (filter.SearchLocation.ToUpper().StartsWith("OCM-"))
                {
                    filter.SearchLocation = filter.SearchLocation.Replace("OCM-", "");
                }
                if (filter.SearchLocation.ToUpper().StartsWith("OCM"))
                {
                    filter.SearchLocation = filter.SearchLocation.Replace("OCM", "");
                }

                if (IsNumeric(filter.SearchLocation.Trim()))
                {
                    int poiID = -1;
                    //treat numbers as OCM ref
                    if (int.TryParse(filter.SearchLocation.Trim(), out poiID))
                    {
                        filter.ChargePointIDs = new int[] { poiID };
                    }
                }
                else
                {
                    //attempt to geocode
                    var    geocode           = new GeocodingHelper();
                    string searchCountryName = null;
                    if (filter.CountryIDs != null && filter.CountryIDs.Count() > 0)
                    {
                        var searchCountry = filter.ReferenceData.Countries.FirstOrDefault(c => c.ID == filter.CountryIDs[0]);
                        searchCountryName = searchCountry.Title;
                    }

                    var position = geocode.GeolocateAddressInfo_Google(filter.SearchLocation.Trim() + (searchCountryName != null ? ", " + searchCountryName : ""));

                    if (position != null)
                    {
                        filter.Latitude  = position.Latitude;
                        filter.Longitude = position.Longitude;
                        if (filter.Distance == null)
                        {
                            filter.Distance = 50;
                        }
                        filter.DistanceUnit = API.Common.Model.DistanceUnit.Miles;
                        //TODO: distance unit KM
                        //if (distanceunit == "km") searchfilters.DistanceUnit = API.Common.Model.DistanceUnit.KM;

                        ViewBag.FormattedAddress = position.Address;
                    }
                }
            }

            filter.POIList = cpManager.GetChargePoints((OCM.API.Common.APIRequestParams)filter);
            return(View(filter));
        }
Exemple #10
0
        //
        // GET: /POI/
        public ActionResult Index(POIBrowseModel filter)
        {
            if (filter == null)
            {
                filter = new POIBrowseModel();
                filter.ShowAdvancedOptions = true;
            }
            var cpManager = new API.Common.POIManager();

            //dropdown selections of -1 represent an intended null selection, fix this by nulling relevant items
            filter.CountryIDs = this.ConvertNullableSelection(filter.CountryIDs);
            filter.LevelIDs = this.ConvertNullableSelection(filter.LevelIDs);
            filter.ConnectionTypeIDs = this.ConvertNullableSelection(filter.ConnectionTypeIDs);
            filter.OperatorIDs = this.ConvertNullableSelection(filter.OperatorIDs);
            filter.StatusTypeIDs = this.ConvertNullableSelection(filter.StatusTypeIDs);
            filter.UsageTypeIDs = this.ConvertNullableSelection(filter.UsageTypeIDs);
            filter.DataProviderIDs = this.ConvertNullableSelection(filter.DataProviderIDs);
            filter.IncludeComments = true;

            if (IsRequestByRobot)
            {
                //force mirror db when browser is a robot
                filter.AllowMirrorDB = true;
            }

            if (!String.IsNullOrWhiteSpace(filter.Country))
            {
                //TODO: cache country id lookup
                var countrySelected = new OCM.API.Common.ReferenceDataManager().GetCountryByName(filter.Country);
                if (countrySelected != null)
                {
                    filter.CountryIDs = new int[] { countrySelected.ID };
                }
            }
            else
            {
                //default to UK
                // if (filter.CountryIDs == null) filter.CountryIDs = new int[] { 1 };
            }

            filter.MaxResults = 100;

            if (!String.IsNullOrWhiteSpace(filter.SearchLocation))
            {
                if (filter.SearchLocation.ToUpper().StartsWith("OCM-")) filter.SearchLocation = filter.SearchLocation.Replace("OCM-", "");
                if (filter.SearchLocation.ToUpper().StartsWith("OCM")) filter.SearchLocation = filter.SearchLocation.Replace("OCM", "");

                if (IsNumeric(filter.SearchLocation.Trim()))
                {
                    int poiID = -1;
                    //treat numbers as OCM ref
                    if (int.TryParse(filter.SearchLocation.Trim(), out poiID))
                    {
                        filter.ChargePointIDs = new int[] { poiID };
                    }
                }
                else
                {
                    //attempt to geocode
                    var geocode = new GeocodingHelper();
                    string searchCountryName = null;
                    if (filter.CountryIDs != null && filter.CountryIDs.Count() > 0)
                    {
                        var searchCountry = filter.ReferenceData.Countries.FirstOrDefault(c => c.ID == filter.CountryIDs[0]);
                        searchCountryName = searchCountry.Title;
                    }

                    var position = geocode.GeolocateAddressInfo_Google(filter.SearchLocation.Trim() + (searchCountryName != null ? ", " + searchCountryName : ""));

                    if (position != null)
                    {
                        filter.Latitude = position.Latitude;
                        filter.Longitude = position.Longitude;
                        if (filter.Distance == null) filter.Distance = 50;
                        filter.DistanceUnit = API.Common.Model.DistanceUnit.Miles;
                        //TODO: distance unit KM
                        //if (distanceunit == "km") searchfilters.DistanceUnit = API.Common.Model.DistanceUnit.KM;

                        ViewBag.FormattedAddress = position.Address;
                    }
                }
            }

            filter.POIList = cpManager.GetChargePoints((OCM.API.Common.APIRequestParams)filter);
            return View(filter);
        }
Exemple #11
0
        //
        // GET: /POI/Details/5
        //[OutputCache(Duration=240, VaryByParam="id")]
        public ActionResult Details(int id = 0, string layout = null, string status = null)
        {
            if (id <= 0) return RedirectToAction("Index");

            if (status != null) ViewBag.Status = status;

            OCM.API.Common.POIManager cpManager = new API.Common.POIManager();
            POIViewModel viewModel = new POIViewModel();

            var poi = cpManager.Get(id, true, allowDiskCache: false, allowMirrorDB: true);
            if (poi != null)
            {
                ViewBag.FullTitle = "Location Details: OCM-" + poi.ID + " " + poi.AddressInfo.Title;

                List<LocationImage> imageList = null; // new OCM.MVC.App_Code.GeocodingHelper().GetGeneralLocationImages((double)poi.AddressInfo.Latitude, (double)poi.AddressInfo.Longitude);

                if (imageList != null)
                {
                    imageList = imageList.Where(i => i.Width >= 500).ToList();
                    ViewBag.ImageList = imageList.ToList();
                }

                viewModel.POI = poi;

                if (!IsRequestByRobot)
                {
                    viewModel.NewComment = new UserComment() { ChargePointID = poi.ID, CommentType = new UserCommentType { ID = 10 }, CheckinStatusType = new CheckinStatusType { ID = 0 } };

                    System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
                    sw.Start();
                    viewModel.POIListNearby = cpManager.GetChargePoints(new APIRequestParams { MaxResults = 10, Latitude = poi.AddressInfo.Latitude, Longitude = poi.AddressInfo.Longitude, Distance = 15, DistanceUnit = DistanceUnit.Miles, AllowMirrorDB = true });
                    viewModel.POIListNearby.RemoveAll(p => p.ID == poi.ID); //don't include the current item in nearby POI list
                    sw.Stop();
                    System.Diagnostics.Debug.WriteLine(sw.ElapsedMilliseconds);

                    ViewBag.ReferenceData = new POIBrowseModel();

                    //get data quality report

                    //if (IsUserAdmin)
                    //{
                    viewModel.DataQualityReport = new DataAnalysisManager().GetDataQualityReport(poi);
                    //}
                }
                else
                {
                    viewModel.POIListNearby = new List<ChargePoint>();
                }
            }

            if (layout == "simple")
            {
                ViewBag.EnableSimpleView = true;
                return View("Details", "_SimpleLayout", viewModel);
            }
            else
            {
                return View(viewModel);
            }
        }
Exemple #12
0
        //
        // GET: /POI/Details/5

        //[OutputCache(Duration=240, VaryByParam="id")]
        public ActionResult Details(int id = 0, string layout = null, string status = null)
        {
            if (id <= 0)
            {
                return(RedirectToAction("Index"));
            }

            if (status != null)
            {
                ViewBag.Status = status;
            }

            OCM.API.Common.POIManager cpManager = new API.Common.POIManager();

            var poi = cpManager.Get(id, true, allowDiskCache: false, allowMirrorDB: true);

            ViewBag.FullTitle = "Location Details: OCM-" + poi.ID + " " + poi.AddressInfo.Title;

            List <LocationImage> imageList = null; // new OCM.MVC.App_Code.GeocodingHelper().GetGeneralLocationImages((double)poi.AddressInfo.Latitude, (double)poi.AddressInfo.Longitude);

            if (imageList != null)
            {
                imageList         = imageList.Where(i => i.Width >= 500).ToList();
                ViewBag.ImageList = imageList.ToList();
            }

            POIViewModel viewModel = new POIViewModel();

            viewModel.POI = poi;

            if (!IsRequestByRobot)
            {
                viewModel.NewComment = new UserComment()
                {
                    ChargePointID = poi.ID, CommentType = new UserCommentType {
                        ID = 10
                    }, CheckinStatusType = new CheckinStatusType {
                        ID = 0
                    }
                };

                System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
                sw.Start();
                viewModel.POIListNearby = cpManager.GetChargePoints(new APIRequestSettings {
                    MaxResults = 10, Latitude = poi.AddressInfo.Latitude, Longitude = poi.AddressInfo.Longitude, Distance = 15, DistanceUnit = DistanceUnit.Miles, AllowMirrorDB = true
                });
                viewModel.POIListNearby.RemoveAll(p => p.ID == poi.ID); //don't include the current item in nearby POI list
                sw.Stop();
                System.Diagnostics.Debug.WriteLine(sw.ElapsedMilliseconds);

                ViewBag.ReferenceData = new POIBrowseModel();
            }
            else
            {
                viewModel.POIListNearby = new List <ChargePoint>();
            }

            if (layout == "simple")
            {
                ViewBag.EnableSimpleView = true;
                return(View("Details", "_SimpleLayout", viewModel));
            }
            else
            {
                return(View(viewModel));
            }
        }