Exemplo n.º 1
0
        public async Task Put(string id, UpdateProfileRequest body)
        {
            var areArgumentsValid = !string.IsNullOrEmpty(id)
               && body != null
               && !string.IsNullOrEmpty(body.Name);
            if (!areArgumentsValid) return;

            var currentUserId = User.Identity.Name;
            if (currentUserId != id) return;

            var userProfile = _userProfileRepo.GetUserProfileById(id);
            var isUserProfileValid = userProfile != null && !userProfile.DeletedDate.HasValue;
            if (!isUserProfileValid) return;

            userProfile.Name = body.Name;
            userProfile.SchoolName = body.SchoolName;
            userProfile.IsPrivateAccount = body.IsPrivate;
            userProfile.CourseReminder = body.IsReminderOnceTime ? 
                UserProfile.ReminderFrequency.Once: 
                UserProfile.ReminderFrequency.Twice;
            _userProfileRepo.UpsertUserProfile(userProfile);
            var process = _backgroundProcessQueue.EnqueueUpdateUserProfile(new Engines.UpdateUserProfileMessage
            {
                UserProfileId = User.Identity.Name,
                DisplayName = userProfile.Name,
                ProfileImageUrl = userProfile.ImageProfileUrl
            });
            await Task.WhenAll(process);
        }
Exemplo n.º 2
0
        public void Put(string id, UpdateProfileRequest body)
        {
            var areArgumentsValid = !string.IsNullOrEmpty(id)
               && body != null
               && !string.IsNullOrEmpty(body.Name);
            if (!areArgumentsValid) return;

            // HACK: Uncomment it when we done the authentication
            //var currentUserId = User.Identity.Name;
            //if (currentUserId != id) return;

            var userProfile = _userProfileRepo.GetUserProfileById(id);
            var isUserProfileValid = userProfile != null && !userProfile.DeletedDate.HasValue;
            if (!isUserProfileValid) return;

            userProfile.Name = body.Name;
            userProfile.SchoolName = body.SchoolName;
            userProfile.IsPrivateAccount = body.IsPrivate;
            userProfile.CourseReminder = body.IsReminderOnceTime ? 
                UserProfile.ReminderFrequency.Once: 
                UserProfile.ReminderFrequency.Twice;
            _userProfileRepo.UpsertUserProfile(userProfile);
        }