コード例 #1
0
        public void Update(AvatarServiceEntity avatar)
        {
            if (avatar == null)
                throw new ArgumentNullException(nameof(avatar));

            _avatarRepository.Update(avatar.ToDalEntity());
            _uow.Commit();
        }
コード例 #2
0
        public ActionResult GetUserInfo()
        {
            string userEmail = HttpContext.User.Identity.Name;
            var user = _userService.GetUserEntity(userEmail);
            var avatar = _avatarService.GetByUserId(user.Id);
            if (avatar == null)
            {
                avatar = new AvatarServiceEntity()
                {
                    Image = AvatarCreator.Get(user.Name),
                };
            }

            var userProfile = new UserProfileModel()
            {
                Name = user.Name,
                Avatar = Convert.ToBase64String(avatar.Image),
            };

            return Json(userProfile, JsonRequestBehavior.AllowGet);
        }
コード例 #3
0
 private void CreateUserAvatar(UserServiceEntity user)
 {
     var avatar = new AvatarServiceEntity(user.Id)
     {
         Image = AvatarCreator.Get(user.Name),
         IsCustom = false
     };
     _avatarService.Create(avatar);
 }
コード例 #4
0
        private void UpdateAvatar(AvatarServiceEntity avatarEntity, byte[] img)
        {
            avatarEntity.Image = img;
            avatarEntity.IsCustom = true;

            _avatarService.Update(avatarEntity);
        }
コード例 #5
0
 private void CreateNewAvatar(int userId, byte[] img)
 {
     var avatarEntity = new AvatarServiceEntity(userId)
     {
         Image = img,
         IsCustom = true
     };
     _avatarService.Create(avatarEntity);
 }