コード例 #1
0
        public async Task<bool> Register(UserProfile userprofile)
        {
            try
            {
                var userProfileRepo = new UserProfileRepository();
                await userProfileRepo.CreateSync(userprofile);

                var userId = userprofile.Id.ToString();
                if (!string.IsNullOrEmpty(userId))
                {
                    var code = userId.Substring(userId.Length - 6, 6);
                    var badge = new Badge
                    {
                        User = userprofile.Username,
                        Code = code,
                        IsAddressVerified = false,
                        IsDriversLicenseVerified = false,
                        IsPhoneVerified = false,
                        IsVehicleVerified = false
                    };

                    var badgeRepo = new BadgeRepository();
                    await badgeRepo.CreateSync(badge);
                    return true;
                }
                return false;
            }
            catch(Exception ex)
            {
                return false;
            }
        }
コード例 #2
0
        public async Task<ActionResult> Badges()
        {
            var badgeRepository = new BadgeRepository();
            var badge = await badgeRepository.GetBadge(User.Identity.Name);
            if (badge == null)
            {
                var userProfileRepo = new UserProfileRepository();
                var user = await userProfileRepo.GetUserProfile(User.Identity.Name);
                var code = user.Id.ToString().Substring(user.Id.ToString().Length - 6, 6);
                badge = new Badge
                {
                    User = User.Identity.Name,
                    Code = code,
                    IsAddressVerified = false,
                    IsDriversLicenseVerified = false,
                    IsPhoneVerified = false,
                    IsVehicleVerified = false
                };
                var badgeRepo = new BadgeRepository();
                await badgeRepo.CreateSync(badge);

            }
            return View(badge);
        }