Example #1
0
        public void Update(AvatarServiceEntity avatar)
        {
            if (avatar == null)
                throw new ArgumentNullException(nameof(avatar));

            _avatarRepository.Update(avatar.ToDalEntity());
            _uow.Commit();
        }
        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);
        }
Example #3
0
 private void CreateUserAvatar(UserServiceEntity user)
 {
     var avatar = new AvatarServiceEntity(user.Id)
     {
         Image = AvatarCreator.Get(user.Name),
         IsCustom = false
     };
     _avatarService.Create(avatar);
 }
        private void UpdateAvatar(AvatarServiceEntity avatarEntity, byte[] img)
        {
            avatarEntity.Image = img;
            avatarEntity.IsCustom = true;

            _avatarService.Update(avatarEntity);
        }
 private void CreateNewAvatar(int userId, byte[] img)
 {
     var avatarEntity = new AvatarServiceEntity(userId)
     {
         Image = img,
         IsCustom = true
     };
     _avatarService.Create(avatarEntity);
 }