Esempio n. 1
0
        public static GeoLocation getGeoLocationModelFromViewModel(GeoLocationView geoView)
        {
            GeoLocation geoModel = null;

            if (geoView != null && !geoView.isEmpty())
            {
                geoModel = new GeoLocation()
                {
                    CAP = geoView.CAP,
                    City = geoView.City,
                    Lat = geoView.Lat,
                    Lng = geoView.Lng,
                    Nation = geoView.Nation,
                    Number = geoView.Number,
                    Province = geoView.Province,
                    Region = geoView.Region,
                    Street = geoView.Street
                };
            }

            return geoModel;
        }
Esempio n. 2
0
        private IQueryable<Viaggio> AddTappaSearchFilter(IQueryable<Viaggio> viaggiToBeFiltered, GeoLocation locationFilter, TipoSearch tipoSearch, TipoTappa tipoTappa)
        {
            try
            {
                IQueryable<Viaggio> viaggiFiltered = null;

                if (tipoSearch == null)
                    tipoSearch = TipoSearch.Città;

                switch (tipoSearch)
                {
                    case TipoSearch.Città:
                        viaggiFiltered = viaggiToBeFiltered.Where(v => v.Tappe.Any(t => t != null && t.Location != null && t.Location.City != null && t.Tipo == tipoTappa && t.Location.City.Equals(locationFilter.City)));
                        break;
                    case TipoSearch.Provincia:
                        viaggiFiltered = viaggiToBeFiltered.Where(v => v.Tappe.Any(t => t != null && t.Location != null && t.Location.Province != null && t.Tipo == tipoTappa && t.Location.Province.Equals(locationFilter.Province)));
                        break;
                    case TipoSearch.Regione:
                        viaggiFiltered = viaggiToBeFiltered.Where(v => v.Tappe.Any(t => t != null && t.Location != null && t.Location.Region != null && t.Tipo == tipoTappa && t.Location.Region.Equals(locationFilter.Region)));
                        break;
                    case TipoSearch.Nazione:
                        viaggiFiltered = viaggiToBeFiltered.Where(v => v.Tappe.Any(t => t != null && t.Location != null && t.Location.Nation != null && t.Tipo == tipoTappa && t.Location.Nation.Equals(locationFilter.Nation)));
                        break;
                    default:
                        throw new Exception("TipoSearch sconosciuto: " + Enum.GetName(typeof(TipoSearch), tipoSearch));

                }

                return viaggiFiltered;
            }
            catch (Exception ex)
            {
                string msg = String.Format("Errore nell'aggiunta del filtro per tappa/destinazione");
                logger.ErrorException(msg, ex);
                throw new Exception(msg, ex);
            }
        }