public async Task <UserProfileDto> GetProfile(GetProfileDto getProfileDto) { var user = await _userRepository.FindById(getProfileDto.Id); if (user is null) { throw new InvalidLoginAttemptException("User with given credentials doesn't exists"); } return(new UserProfileDto(user.Id, user.UserName, user.Email, user.Created, user.Modified, user.LastLogged)); }
public async Task <ActionResult <GetProfileDto> > CreateProfile(AddProfileDto addProfileDto) { GetProfileDto getProfileDto = null; try { getProfileDto = await _profileService.AddProfileAsync(addProfileDto); } catch { return(BadRequest()); } return(CreatedAtRoute(nameof(GetProfileById), new { id = getProfileDto.Id }, getProfileDto)); }
public async Task <IActionResult> GetProfileDetails([FromBody] GetProfileDto customerRegistrationDto) { try { ProfileDto profileDto = new ProfileDto(); var _getUsers = await _UsersService.UserPWD(new CustomerRegistrationDto { Email = customerRegistrationDto.Email }); if (_getUsers != null) { if (_getUsers.Type.ToUpper() == "C") { strImagePath = _configuration["FilePath:ImagePath"] + "ProfileImages/"; string strServerURL = _configuration["FilePath:ServerURL"] + "ProfileImages/"; var _types = await _CustomerRegistrationService.Authenticate(new CustomerRegistrationDto { Email = customerRegistrationDto.Email }); profileDto.FirstName = _types.FirstName; profileDto.LastName = _types.LastName; profileDto.Email = _types.Email; profileDto.Country = _types.LookupCountry.Description; profileDto.City = _types.City; profileDto.Mobile = _types.Mobile; profileDto.Address = _types.Address; profileDto.Status = _getUsers.Status; profileDto.Type = _getUsers.Type; profileDto.Id = _getUsers.GUID; profileDto.Customercurrency = _types.LookupCountry.ShortDesc; if (_types.Wallet != null) { profileDto.Wallet = _types.Wallet.Amount; } else { profileDto.Wallet = 0; } if (_types.WalletPoints != null) { profileDto.WalletPoints = _types.WalletPoints.Points; } else { profileDto.WalletPoints = 0; } if ((System.IO.File.Exists(strImagePath + _types.Image + ""))) { if (_types.Image == null || _types.Image == "") { profileDto.Image = strServerURL + "Dummy.jpg"; } else { profileDto.Image = strServerURL + _types.Image; } } else { profileDto.Image = strServerURL + "Dummy.jpg"; } } else if (_getUsers.Type.ToUpper() == "M") { string Categories = string.Empty, SellCountries = string.Empty; MerchantDto.Email = customerRegistrationDto.Email; Merchant Merchant = await _MerchantService.GetMerchantDetails(MerchantDto); strImagePath = _configuration["FilePath:ImagePath"] + "MerchantImages/"; string strServerURL = _configuration["FilePath:ServerURL"] + "MerchantImages/"; profileDto.FirstName = Merchant.Name; profileDto.Email = Merchant.Email; profileDto.Company = Merchant.Company; profileDto.Website = Merchant.Website; profileDto.Email = Merchant.Email; profileDto.Status = _getUsers.Status; profileDto.Type = _getUsers.Type; profileDto.Id = Merchant.Id; profileDto.MerchantRedirectionUrl = Merchant.MerchantRedirectionUrl; profileDto.Country = Merchant.LookupCountry.Description; profileDto.Company = Merchant.Company; //foreach (var MerchantCategoryItem in Merchant.MerchantCategory) //{ // Categories += MerchantCategoryItem.Category.Name + ","; //} //foreach (var MerchantSellCountriesItem in Merchant.MerchantSellCountries) //{ // SellCountries += MerchantSellCountriesItem.LookupTypeValues.Description + ","; //} List <ProfileCategoriesDto> profileCategoriesList = new List <ProfileCategoriesDto>(); foreach (var CategoriesIteams in Merchant.MerchantCategory) { ProfileCategoriesDto ProfileCategories = new ProfileCategoriesDto(); ProfileCategories.CategoryId = CategoriesIteams.Category.Id; ProfileCategories.CategoryName = CategoriesIteams.Category.Name; profileCategoriesList.Add(ProfileCategories); } List <ProfileSellCountriesDto> ProfileSellCountriesList = new List <ProfileSellCountriesDto>(); foreach (var SellCountriesIteams in Merchant.MerchantSellCountries) { ProfileSellCountriesDto ProfileSellCountries = new ProfileSellCountriesDto(); ProfileSellCountries.SellCountryId = SellCountriesIteams.LookupTypeValues.Id; ProfileSellCountries.SellCountryName = SellCountriesIteams.LookupTypeValues.Description; ProfileSellCountriesList.Add(ProfileSellCountries); } profileDto.Categories = profileCategoriesList; profileDto.SellCountries = ProfileSellCountriesList; if ((System.IO.File.Exists(strImagePath + Merchant.ProfileImage + ""))) { profileDto.ProfileImage = strServerURL + Merchant.ProfileImage; } else { profileDto.ProfileImage = strServerURL + "Dummy.jpg"; } if ((System.IO.File.Exists(strImagePath + Merchant.CompanyImage))) { profileDto.CompanyImage = strServerURL + Merchant.CompanyImage; } else { profileDto.CompanyImage = strServerURL + "Dummy.jpg"; } } else { objNaqelUsersDto.Email = customerRegistrationDto.Email; NaqelUsers NaqelUsers = await _NaqelUsersService.GetNaqelUserDetails(objNaqelUsersDto); profileDto.FirstName = NaqelUsers.FirstName; profileDto.LastName = NaqelUsers.LastName; profileDto.Country = NaqelUsers.LookupTypeCountry.Description; profileDto.Email = NaqelUsers.Email; profileDto.Mobile = NaqelUsers.Mobile; profileDto.Address = NaqelUsers.Address; profileDto.Status = _getUsers.Status; profileDto.Type = _getUsers.Type; profileDto.Id = NaqelUsers.Id; profileDto.NaqelUserType = NaqelUsers.UserType; strImagePath = _configuration["FilePath:ImagePath"] + "NaqelUsersImages/"; string strServerURL = _configuration["FilePath:ServerURL"] + "NaqelUsersImages/"; if ((System.IO.File.Exists(strImagePath + NaqelUsers.Image + ""))) { profileDto.Image = strServerURL + NaqelUsers.Image; } else { profileDto.Image = strServerURL + "Dummy.jpg"; } } return(Ok(profileDto)); } else { return(Ok(new GenericResultDto <string> { Result = "User Profile not found" })); } } catch (Exception err) { return(BadRequest(new GenericResultDto <string> { Result = err.Message })); } }