public async Task <ApiResponse <UserProfileOld> > CreateProfile(ProfileOldDTO profileDto) { var response = new ApiResponse <UserProfileOld>(); try { int isExist = await _profileRepository.CountAsync(i => i.UserId == profileDto.UserId); if (isExist == 0) { var Skills = string.Join(",", profileDto.Skills); UserProfileOld profile = new UserProfileOld(); profile.Id = Guid.NewGuid(); profile.Skills = Skills; profile.Looking = profileDto.Looking; profile.Description = profileDto.Description; profile.CreatedDate = DateTime.Now; profile.IsActive = true; var userRes = await _usersRepository.FindAsync(i => i.Id == profileDto.UserId); if (userRes != null) { profile.CreatedBy = userRes.Id; profile.UserId = userRes.Id; var data = await _profileRepository.AddAsyn(profile); response.Success = true; response.Data = data; } else { response.Success = false; response.Errors.Add("User not found"); } } else { response.Success = false; response.Errors.Add("Already User Profile Created "); } } catch (Exception ex) { response.Success = false; response.Errors.Add(ex.Message); } return(response); }
public async Task <ApiResponse <UserProfileOld> > CreateProfile(ProfileOldDTO profile) { try { ProfileOldService service = new ProfileOldService(); return(await service.CreateProfile(profile)); } catch (Exception ex) { return(new ApiResponse <UserProfileOld>() { Success = false, Errors = new List <string>() { ex.Message } }); } }