Exemplo n.º 1
0
        public JsonResult GetEnterprisesCloseToMyLocation(string latitude, string longitude)
        {
            var enterprises = Db.Enterprises.GetNearbyEnterprises(latitude, longitude);

            var searchViewModel = new MainSearchViewModel
            {
                Enterprises = new List <LightEnterprise>()
            };

            foreach (var enterpriseViewModel in enterprises.Select(enterprise => new LightEnterprise
            {
                Key = EnterpriseHelper.GetKey(enterprise.Id),
                Name = enterprise.Name,
                LocationInfo = EnterpriseHelper.FormatDisplayStreet(enterprise),
                DistanceFromMyLocation = string.Empty,
                Categories = EnterpriseHelper.GetDisplayLabelsCategories(enterprise.Categories),
                Coordinates = enterprise.Coordinates,
            }))
            {
                searchViewModel.Enterprises.Add(enterpriseViewModel);
            }

            var myCoord = new GeoCoordinate(double.Parse(latitude, CultureInfo.InvariantCulture), double.Parse(longitude, CultureInfo.InvariantCulture));

            foreach (var enterprise in searchViewModel.Enterprises)
            {
                var enterpriseCoord = new GeoCoordinate(enterprise.Coordinates.Lat, enterprise.Coordinates.Lng);

                var distance = myCoord.GetDistanceTo(enterpriseCoord);

                enterprise.DistanceFromMyLocation = string.Format("{0}km", Math.Round((distance / 1000), 1));
            }
            return(Json(searchViewModel));
        }
Exemplo n.º 2
0
        public IActionResult FindComments(MainSearchViewModel model)
        {
            //*=> mean all
            if (!string.IsNullOrEmpty(model.MainContian))
            {
                model.Contain = model.MainContian;
            }
            else
            {
                model.Contain = model.Contain ?? "*";//* = all
            }

            model.CreateBy = model.CreateBy ?? "*";
            model.FromDate = model?.FromDate ?? "*";
            model.ToDate   = model?.ToDate ?? "*";
            model.Group    = model.Group ?? "*";

            return(View(model));
        }
Exemplo n.º 3
0
 public MainMaintenanceSearchView()
 {
     try
     {
         _viewModel                      = _vml.MainSearchViewModel;
         DataContext                     = _viewModel;
         _viewModel.ErrorNotice         += OnErrorNotice;
         _viewModel.MessageNotice       += OnMessageNotice;
         _viewModel.CloseNotice         += OnCloseNotice;
         _viewModel.AuthenticatedNotice += OnAuthenticatedNotice;
         InitializeComponent();
         if (!XERP.Client.ClientSessionSingleton.Instance.SessionIsAuthentic)
         {
             DisplayLogIn();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 4
0
        public JsonResult MainSearch(string searchTerm)
        {
            if (string.IsNullOrEmpty(searchTerm))
            {
                return(Json(null));
            }

            var enterprises = Db.Enterprises.MainSearch(searchTerm);

            var searchViewModel = new MainSearchViewModel
            {
                SearchQuery = searchTerm,
                Enterprises = new List <LightEnterprise>(),
                Locations   = new List <string> {
                    "Tumba", "Tullinge"
                },
                Categories = new List <string>()
            };

            var categories = GeneralHelper.GetCategories().Where(c => c.Text.ToLower().StartsWith(searchTerm.ToLower()));

            if (categories.Any())
            {
                searchViewModel.Categories = categories.Select(c => c.Text).ToList();
            }

            foreach (var enterpriseViewModel in enterprises.Select(enterprise => new LightEnterprise
            {
                Key = EnterpriseHelper.GetKey(enterprise.Id),
                Name = enterprise.Name,
                LocationInfo = EnterpriseHelper.FormatDisplayStreet(enterprise),
                DistanceFromMyLocation = string.Empty,
                Categories = EnterpriseHelper.GetDisplayLabelsCategories(enterprise.Categories)
            }))
            {
                searchViewModel.Enterprises.Add(enterpriseViewModel);
            }
            return(Json(searchViewModel));
        }