コード例 #1
0
        public IActionResult GetApplicationUserProfile(string subject)
        {
            var applicationUserProfileFromRepo = _galleryRepository.GetApplicationUserProfile(subject);

            if (applicationUserProfileFromRepo == null)
            {
                //subject must come from token
                var subjectFromToken = User.Claims.FirstOrDefault(c => c.Type == "sub").Value;

                applicationUserProfileFromRepo = new Entities.ApplicationUserProfile()
                {
                    Subject           = subject,
                    SubscriptionLevel = "FreeUser"
                };

                _galleryRepository.AddApplicationUserProfile(applicationUserProfileFromRepo);
                _galleryRepository.Save();
            }

            return(Ok(_mapper.Map <ApplicationUserProfile>(applicationUserProfileFromRepo)));
        }
        public IActionResult GetApplicationUserProfile(string subject)
        {
            var applicationUserProfileFromRepo = _galleryRepository.GetApplicationUserProfile(subject);

            //Create Application user profile if it doesn't exists
            if (applicationUserProfileFromRepo == null)
            {
                //Get subject from Token
                var subjectFromToken = User.Claims.FirstOrDefault(c => c.Type == "sub").Value;

                applicationUserProfileFromRepo = new Entities.ApplicationUserProfile()
                {
                    Subject           = subject,
                    SubscriptionLevel = "FreeUser"
                };


                _galleryRepository.AddApplicationUserProfile(applicationUserProfileFromRepo);
                _galleryRepository.Save();
            }

            return(Ok(_mapper.Map <Model.ApplicationUserProfile>(applicationUserProfileFromRepo)));
        }