Example #1
0
 public IActionResult AddProfile([FromBody] Profile profile)
 {
     try
     {
         if (!_profileRepository.UserHasProfile(profile.UserId))
         {
             if (IdentityHelper.GetUserId(HttpContext) == profile.UserId)
             {
                 _profileRepository.AddProfile(profile);
                 return(Ok());
             }
             else
             {
                 // profile.UserId did not match the current UserId
                 return(Unauthorized());
             }
         }
         else
         {
             // User already has a profile
             return(NotFound());
         }
     }
     catch
     {
         return(NotFound());
     }
 }