public async Task <IActionResult> UsersLoginAuthenticate([FromBody] LoginDto loginDto) { try { var _checkLoginAuthentication = await _UsersService.LoginAuthenticate(new CustomerRegistrationDto { Email = loginDto.Email }); if (_checkLoginAuthentication != null) { var tokenDto = await _CustomerRegistrationService.GetToken(new TokenDto { Type = _checkLoginAuthentication.Type, GUID = _checkLoginAuthentication.GUID }); if (EncryptionHelper.Decrypt(_checkLoginAuthentication.PWD) == loginDto.PWD) { await _UsersService.UpdateGUID(new CustomerRegistrationDto { Email = loginDto.Email }); if (_checkLoginAuthentication.Type == "C") { var _getData = await _CustomerRegistrationService.Authenticate(new CustomerRegistrationDto { Email = loginDto.Email }); UsersProfileDto UsersProfileDto = new UsersProfileDto(); UsersProfileDto.Id = _checkLoginAuthentication.Id; UsersProfileDto.Username = _getData.Email; UsersProfileDto.Type = _checkLoginAuthentication.Type; UsersProfileDto.Status = _checkLoginAuthentication.Status; UsersProfileDto.GUID = _checkLoginAuthentication.GUID; UsersProfileDto.token = tokenDto.Token; return(Ok(new LoginResultDto <UsersProfileDto> { Result = "Success", LoginStatus = _checkLoginAuthentication.Status.ToString(), ReEmail = _getData.Email, ReFirstName = _getData.FirstName, LoginType = _checkLoginAuthentication.Type, ResultData = UsersProfileDto, Token = UsersProfileDto.token })); } else if (_checkLoginAuthentication.Type == "M") { string Categories = string.Empty, SellCountries = string.Empty; MerchantDto.Email = loginDto.Email; strImagePath = _configuration["FilePath:ImagePath"] + "MerchantImages/"; string strServerURL = _configuration["FilePath:ServerURL"] + "MerchantImages/"; var Merchantdetails = await _MerchantService.GetMerchantDetailsByStatus(MerchantDto); if (Merchantdetails != null) { Merchant Merchant = Merchantdetails; MerchantProfile.Id = Merchant.Id; MerchantProfile.Name = Merchant.Name; MerchantProfile.MerchantRedirectionUrl = Merchant.MerchantRedirectionUrl; MerchantProfile.Country = Merchant.LookupCountry.Description; foreach (var MerchantCategoryItem in Merchant.MerchantCategory) { Categories += MerchantCategoryItem.Category.Name + ","; } foreach (var MerchantSellCountriesItem in Merchant.MerchantSellCountries) { SellCountries += MerchantSellCountriesItem.LookupTypeValues.Description + ","; } MerchantProfile.Categories = Categories.TrimEnd(','); MerchantProfile.SellCountries = SellCountries.TrimEnd(','); if ((System.IO.File.Exists(strImagePath + Merchant.ProfileImage + ""))) { MerchantProfile.ProfileImage = strServerURL + Merchant.ProfileImage; } else { MerchantProfile.ProfileImage = strServerURL + "Dummy.jpg"; } if ((System.IO.File.Exists(strImagePath + Merchant.CompanyImage))) { MerchantProfile.ProfileImage = strServerURL + Merchant.CompanyImage; } else { MerchantProfile.CompanyImage = strServerURL + "Dummy.jpg"; } MerchantProfile.Company = Merchant.Company; MerchantProfile.Website = Merchant.Website; MerchantProfile.Email = Merchant.Email; return(Ok(new LoginResultDto <MerchantProfile> { Result = "Success", LoginStatus = _checkLoginAuthentication.Status.ToString(), ReEmail = Merchant.Email, ReFirstName = Merchant.Name, LoginType = _checkLoginAuthentication.Type, Website = Merchant.Website, ResultData = MerchantProfile, Token = tokenDto.Token })); } else { return(Ok(new GenericResultDto <string> { Result = "Your account is under verification and after successful completion, will send a confirmation e-mail.", ReEmail = loginDto.Email })); } } else { objNaqelUsersDto.Email = loginDto.Email; NaqelUsers NaqelUsers = await _NaqelUsersService.GetNaqelUserDetails(objNaqelUsersDto); ProfileDto profileDto = new ProfileDto(); profileDto.Id = NaqelUsers.Id; 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; strImagePath = _configuration["FilePath:ImagePath"] + "MerchantImages/"; string strServerURL = _configuration["FilePath:ServerURL"] + "MerchantImages/"; if ((System.IO.File.Exists(strImagePath + NaqelUsers.Image + ""))) { profileDto.Image = strServerURL + NaqelUsers.Image; } else { profileDto.Image = strServerURL + "Dummy.jpg"; } return(Ok(new LoginResultDto <ProfileDto> { Result = "Success", LoginStatus = _checkLoginAuthentication.Status.ToString(), ReEmail = NaqelUsers.Email, ReFirstName = NaqelUsers.FirstName, LoginType = _checkLoginAuthentication.Type, ResultData = profileDto, Token = tokenDto.Token })); } } else { return(Ok(new GenericResultDto <string> { Result = "Invalid password", ReEmail = loginDto.Email })); } } else { // if (_types != null && _types.Type == "M") // return BadRequest(new GenericResultDto<string> { Result = "Merchant Sign In Under Process", ReEmail = CustomerRegistrationDto.Email }); // else return(Ok(new GenericResultDto <string> { Result = "Invalid email", ReEmail = loginDto.Email })); } } catch (Exception err) { return(BadRequest(new GenericResultDto <string> { Result = err.Message })); } return(Ok(new GenericResultDto <string> { Result = "Valid email" })); }