コード例 #1
0
        public ActionResult CreateStep1(string userName)
        {
            ViewBag.MaximumSize = Services.SystemConfig.GetValueByKey(TeleConsult.Infrastructure.Core.Const.SystemConfig.FILE_UPLOAD_LIMITS);
            UserDto account = Services.Users.GetByUserName(userName);
            if (account != null)
            {
                LocationDto customerLocation = account.Locations.FirstOrDefault();
                LocationViewModel locationModel;
                if (customerLocation == null)
                {
                    locationModel = new LocationViewModel();
                }
                else
                {
                    Mapper.CreateMap<LocationDto, LocationViewModel>()
                        .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id));
                    locationModel = Mapper.Map<LocationDto, LocationViewModel>(customerLocation);
                }

                ProfileViewModel profileModel;
                ProfileDto customerProfile = account.Profiles.FirstOrDefault(x => x.UserId == account.Id);
                if (customerProfile == null)
                {
                    profileModel = new ProfileViewModel();
                }
                else
                {
                    Mapper.CreateMap<ProfileDto, ProfileViewModel>()
                        .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id));
                    profileModel = Mapper.Map<ProfileDto, ProfileViewModel>(customerProfile);
                }

                UserViewModel userModel;
                Mapper.CreateMap<UserDto, UserViewModel>()
                    .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id));
                userModel = Mapper.Map<UserDto, UserViewModel>(account);
                userModel.TitleGender = account.Title;
                userModel.AvatarPath = account.Avatar != null ? Path.Combine(BlueChilli.Web.Helpers.S3PathWithoutQuery("").Substring(1),
                    account.Avatar)
                : ConstPath.DefaulAvatar;

                var model = new ProfileIndexViewModel { Location = locationModel, Profile = profileModel, User = userModel };
                model.Location.ListCountry = GetCultureList();
                model.Location.ListTimeZone = GetTimeZoneList();
                return View(model);
            }
            else
            {
                return View("Error");
            }
        }
コード例 #2
0
        public ActionResult CheckValidLocation(LocationViewModel location)
        {
            if (location != null)
            {
                if (location.Country != "Australia")
                {
                    return Json(new { status = true });
                }

                GeoIpService geoServices = new GeoIpService();
                var coordinate = geoServices.GetByAddress(location.StreetNumber, location.Street, location.Postcode, location.Country, location.State);
                if (coordinate != null)
                {
                    return Json(new { status = true });
                }
            }
            return Json(new { status = false });
        }