Пример #1
0
        public GeoLocationServiceResponse <GeoLocation> GetGeoLocations(GeoLocationRequest req, List <ServiceLogRecord> logRecords = null)
        {
            var response = new GeoLocationServiceResponse <GeoLocation>();

            var geoLocations = new List <GeoLocation>();

            #region [ Envelope settings ]

            // Create the including fields according to the envelope
            var includes = new List <string>();

            #endregion

            #region [ Filters ]

            // Check for filters
            Expression <Func <GeoLocation, bool> > filterPredicate = PredicateBuilder.New <GeoLocation>(true);

            // Add the filters
            if (req.GeoLocationIds.Any())
            {
                filterPredicate = filterPredicate.And(r => req.GeoLocationIds.Contains(r.GeoLocationId));
            }
            if (req.GeoLocationPaths.Any())
            {
                filterPredicate = filterPredicate.And(r => req.GeoLocationPaths.Contains(r.Path));
            }
            if (req.GeoLocationParents.Any())
            {
                filterPredicate = filterPredicate.And(r => req.GeoLocationParents.Contains(r.Parent));
            }
            if (!String.IsNullOrEmpty(req.Prefix))
            {
                filterPredicate = filterPredicate.And(r => r.Name.StartsWith(req.Prefix));
            }
            try
            {
                // Make the query
                if (filterPredicate.Parameters.Count > 0)
                {
                    geoLocations = geoLocationServiceBase.GetIncluding(filterPredicate, includes.ToArray()).Result;
                }
                else
                {
                    geoLocations = geoLocationServiceBase.GetAllIncluding(includes.ToArray()).Result;
                }
            }
            catch (Exception e)
            {
                throw;
            }

            response.Type   = ServiceResponseTypes.Success;
            response.Result = geoLocations;

            return(response);

            #endregion
        }
Пример #2
0
        private UserViewModel CreateSelectLists(UserViewModel model)
        {
            var accountStatuses = new Dictionary <Lidia.Identity.Common.Models.AccountStatus, string>
            {
                { Lidia.Identity.Common.Models.AccountStatus.Active, "Aktif" },
                { Lidia.Identity.Common.Models.AccountStatus.Passive, "Pasif" },
                { Lidia.Identity.Common.Models.AccountStatus.Verified, "Onaylanmış" },
            };

            var genders = new Dictionary <string, string>();

            genders.Add("Erkek", "Erkek");
            genders.Add("Kadın", "Kadın");

            var cities = new Dictionary <string, string>();
            //cities.Add("İstanbul", "İstanbul");
            //cities.Add("Ankara", "Ankara");

            var request  = new GeoLocationRequest();
            var response = _geoLocationService.GetGeoLocations(request).Result.Where(x => x.Parent == "TR").OrderBy(x => x.Name).ToList();

            foreach (var city in response)
            {
                cities.Add(city.Name, city.Name);
            }

            model.GenderList        = new SelectList(genders.Select(x => new { Value = x.Key, Text = x.Value }), "Value", "Text", model.Gender);
            model.AccountStatusList = new SelectList(accountStatuses.Select(x => new { Value = x.Key, Text = x.Value }), "Value", "Text", (int)model.AccountStatus);
            model.CityList          = new SelectList(cities.Select(x => new { Value = x.Key, Text = x.Value }), "Value", "Text"); // EKIN

            // Load roles
            var roles = identityServiceClient.GetRoles(new RoleQuery()
            {
            }).Result;

            // Remove the not authorized role selections
            if (User.IsInRole("Superuser"))
            {
                roles.RemoveAll(r => r.Name == "Administrator");
            }
            else if (User.IsInRole("ResellerAdmin"))
            {
                roles.RemoveAll(r => r.Name == "Administrator");
                roles.RemoveAll(r => r.Name == "SuperUser");
            }
            else if (User.IsInRole("ResellerAgent"))
            {
                roles.RemoveAll(r => r.Name == "Administrator");
                roles.RemoveAll(r => r.Name == "SuperUser");
                roles.RemoveAll(r => r.Name == "ResellerAdmin");
            }

            // Set the selection list
            model.RoleList = new SelectList(roles.Select(x => new { Value = x.Id, Text = x.Name }), "Value", "Text", model.RoleId);

            return(model);
        }