示例#1
0
 public static HtmlString Avatar(this HtmlHelper htmlHelper, Profile profile, string className, bool isSmall = false)
 {
     return htmlHelper.Avatar(
         profile.GetFirstHeadshot(isSmall),
         profile.Gender,
         profile.UserId,
         profile.Nickname,
         className);
 }
示例#2
0
        private string AvatarUrl(Profile profile)
        {            
            var photo = profile.GetFirstHeadshot(true);
            var url = "";

            if (string.IsNullOrEmpty(photo))
            {
                //Use one of the default avatars
                url = "/Content/images/";
                url += profile.Gender == OkbConstants.MALE ? "no-avatar-male-chat.png" : "no-avatar-female-chat.png";
            }
            else
            {
                //use user profile photo
                var baseUrl = ConfigurationManager.AppSettings["StorageUrl"] + OkbConstants.PHOTO_CONTAINER + "/";
                url = baseUrl + profile.UserId + "/" + photo;
            }
            return url;
        }
示例#3
0
        public Profile Next()
        {
            //Generate a new random profile
            var profile = new Profile();

            if (_rand.Next() % 2 == 0)
            {
                //Male
                profile.Gender = 1;
                profile.LookingForGender = 2;
                profile.Nickname = _maleNames[_rand.Next() % _maleNames.Length];
            }
            else
            {
                //Female
                profile.Gender = 2;
                profile.LookingForGender = 1;
                profile.Nickname = _femaleNames[_rand.Next() % _maleNames.Length];
            }

            profile.Birthdate = DateTime.Now.AddYears(-_rand.Next(16, 99));

            //20% chance in beijing
            if (_rand.Next() % 5 == 0)
            {
                profile.LocationId1 = 1;
            }
            else
            {
                profile.LocationId1 = (short)_provinces[_rand.Next() % _provinces.Count()].LocationId;
            }

            profile.LocationId2 = 1;

            return profile;
        }
示例#4
0
        //[ValidateAntiForgeryToken]
        public async Task<ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new OkbUser
                {
                    UserName = model.Email,
                    Email = model.Email,
                    JoinDate = DateTime.Now,
                    LastLoginDate = DateTime.Now
                };

                var profile = new Profile
                {
                    Gender = model.Gender,
                    LookingForGender = model.LookingForGender,
                    Birthdate = model.Birthdate,
                    Nickname = model.Nickname,
                    LocationId1 = model.LocationId1,
                    LocationId2 = model.LocationId2,
                    UserId = user.Id
                };

                user.Profile = profile;

                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);

                    // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    //Update activity feed
                    var profileId = _profileRepo.GetProfileId(user.Id);
                    _feedRepo.JoinedActivity(profileId);

                    return RedirectToAction("Index", "Home");
                }

                //AddErrors(result);
            }

            // If we got this far, something failed, redisplay form 
            // Re-populate model with provinces           
            var prov = _locationRepo.GetProvinces();
            model.JsonProvinces = JsonConvert.SerializeObject(prov);
            return View(model);
        }