public async Task <IActionResult> InsertMerchantDetails([FromBody] InsertMerchantDto InsertMerchantDto)
        {
            try
            {
                Guid MerchantRequestId = Guid.NewGuid();
                CustomerRegistrationDto CustomerRegistrationDto = new CustomerRegistrationDto();
                CustomerRegistrationDto.Email = InsertMerchantDto.Email;
                var _emailCheck = await _UsersService.LoginAuthenticate(CustomerRegistrationDto);

                if (InsertMerchantDto.TermandCondition == "Y")
                {
                    InsertMerchantDto.TermandCondition = Convert.ToString(1);
                }
                else if (InsertMerchantDto.TermandCondition == "N")
                {
                    InsertMerchantDto.TermandCondition = Convert.ToString(0);
                }
                if (_emailCheck == null)
                {
                    strMerchantImages = _configuration["FilePath:ImagePath"] + "MerchantImages/";
                    if (!String.IsNullOrEmpty(InsertMerchantDto.ProfileImage))
                    {
                        if (!Directory.Exists(strMerchantImages))
                        {
                            Directory.CreateDirectory(strMerchantImages);
                        }
                        Byte[] imageByteData = Convert.FromBase64String(InsertMerchantDto.ProfileImage);
                        var    fs            = new BinaryWriter(new FileStream(strMerchantImages + ProfileImage + ".jpg", FileMode.Append, FileAccess.Write));
                        fs.Write(imageByteData);
                        fs.Close();
                        InsertMerchantDto.ProfileImage = ProfileImage + ".jpg";
                    }
                    else
                    {
                        InsertMerchantDto.ProfileImage = "";
                    }
                    if (!String.IsNullOrEmpty(InsertMerchantDto.CompanyImage))
                    {
                        if (!Directory.Exists(strMerchantImages))
                        {
                            Directory.CreateDirectory(strMerchantImages);
                        }
                        Byte[] imageByteData = Convert.FromBase64String(InsertMerchantDto.CompanyImage);
                        var    fs            = new BinaryWriter(new FileStream(strMerchantImages + CompanyImage + ".jpg", FileMode.Append, FileAccess.Write));
                        fs.Write(imageByteData);
                        fs.Close();
                        InsertMerchantDto.CompanyImage = CompanyImage + ".jpg";
                    }
                    else
                    {
                        InsertMerchantDto.CompanyImage = "";
                    }
                    CustomerRegistrationDto objCustomerRegistrationDto = new CustomerRegistrationDto();
                    objCustomerRegistrationDto.Email = InsertMerchantDto.Email;
                    objCustomerRegistrationDto.PWD   = InsertMerchantDto.PWD;
                    objCustomerRegistrationDto.Type  = "M";
                    MerchantDto MerchantDto = new MerchantDto();
                    MerchantDto.Email = InsertMerchantDto.Email;
                    await _UsersService.UserDetails(objCustomerRegistrationDto);

                    int getuserID = await _UsersService.getUsersId(InsertMerchantDto.Email);

                    await _MerchantService.InsertMerchantDetails(InsertMerchantDto, getuserID);

                    var getMerchantID = await _MerchantService.GetMerchantDetails(MerchantDto);

                    await _MerchantCategoryService.InsertMerchantCategory(getMerchantID.Id, InsertMerchantDto.Categories);

                    await _MerchantSellCountriesService.InsertSellCountriesDetails(getMerchantID.Id, InsertMerchantDto.SellCountries);

                    await _MerchantRequestService.InsertRequestDetails(getMerchantID.Id, 24, "Open Request", 4, MerchantRequestId.ToString());

                    var getMerchantRequestId = await _MerchantRequestService.GetMerchantRequestId(MerchantRequestId.ToString());

                    if (getMerchantRequestId > 0)
                    {
                        await _MerchantRequestDetailsService.InsertMerchantRequestDetails(getMerchantRequestId, 24, "Open Request", 4);
                    }
                    string strEmaiL = _configuration["EmailSender:Email"];
                    string Message  = "<table width='100%'><tr><td> Dear Admin,</td></tr><tr><td style='padding: 10px 0 10px 0; '>New Merchant Registration.</td></tr><tr><td  style='padding: 10px 0 10px 0;'> <b>" + InsertMerchantDto.Name + " </b> has registered on the dunyana</td></tr><tr><td  style='padding: 15px 0 15px 0;'> Regards,<br /> Dunyana</td></tr></table>";
                    await _emailService.SendEmail(strEmaiL, "New Merchant Registration", Message);
                }
                else
                {
                    return(BadRequest(new GenericResultDto <string> {
                        Result = "Email Id already registered", LoginType = _emailCheck.Type, ReEmail = _emailCheck.Username
                    }));
                }
            }

            catch (Exception err)
            {
                return(BadRequest(new GenericResultDto <string> {
                    Result = err.Message
                }));
            }
            return(Ok(new GenericResultDto <string> {
                Result = "We have received your registration request, Please allow us some time to process.", ReFirstName = InsertMerchantDto.Name, ReEmail = InsertMerchantDto.Email
            }));
        }