Exemple #1
0
        public async Task <ManageAgentRes> GetAgentDetailedInfo(ManageAgentReq agentReq, string ticket)
        {
            ManageAgentRes response = new ManageAgentRes();

            //response = await serviceProxy.PostData(_configuration.GetValue<string>("AgentService:GetAgentDetailedInfo"), agentReq, typeof(AgentGetRes), ticket);
            return(response);
        }
Exemple #2
0
        public async Task <ManageAgentRes> CreateUpdatePartnerAgentDetails(ManageAgentReq request, string ticket)
        {
            ManageAgentRes response = new ManageAgentRes();

            response = await serviceProxy.PostData(_configuration.GetValue <string>("AgentService:CreateUpdatePartnerAgentDetails"), request, typeof(ManageAgentRes), ticket);

            return(response);
        }
Exemple #3
0
        public async Task <ManageAgentRes> CreateUpdatePartnerAgentDetails([FromBody] ManageAgentReq request)
        {
            var response = new ManageAgentRes();

            try
            {
                response = await _agentRepository.CreateUpdatePartnerAgentDetails(request);
            }
            catch (Exception ex)
            {
                response.ResponseStatus.Status       = "Failure";
                response.ResponseStatus.ErrorMessage = "An Error Occurs :- " + ex.Message;
            }

            return(response);
        }
Exemple #4
0
        public ManageAgentReq SetAgentInfoWithModel(AgentPartnerReq model)
        {
            ManageAgentReq res = new ManageAgentReq();

            res.AgentInfo      = new AgentThirdPartyInfo();
            res.AgentInfo.Name = model.AgentInfo.Name;
            res.AgentInfo.ApplicationEntityCode = model.AgentInfo.ApplicationEntityCode;
            res.AgentInfo.Address2 = model.AgentInfo.Address2;
            res.AgentInfo.Address1 = model.AgentInfo.Address1;
            res.AgentInfo.City     = model.AgentInfo.City;
            res.AgentInfo.Country  = model.AgentInfo.Country;
            res.AgentInfo.PostCode = model.AgentInfo.PostCode;

            res.CredentialInfo        = new IntegrationLoginRequest();
            res.CredentialInfo.Key    = model.CredentialInfo.Key;
            res.CredentialInfo.User   = model.CredentialInfo.User;
            res.CredentialInfo.Source = model.CredentialInfo.Source;

            return(res);
        }
Exemple #5
0
        public async Task <IActionResult> CreateUpdateAgentInfo([FromBody] AgentPartnerReq model)
        {
            ManageAgentReq request  = new ManageAgentReq();
            var            response = new ManageAgentRes();

            try
            {
                if (!ModelState.IsValid)
                {
                    response.ResponseStatus.Status       = "Failure";
                    response.ResponseStatus.ErrorMessage = "Request is not valid";
                    return(BadRequest(ModelState));
                }
                else
                {
                    if (model != null)
                    {
                        request = SetAgentInfoWithModel(model);
                        IntegrationLoginResponse objTokenResponse = loginProviders.GetIntegrationToken(request.CredentialInfo).Result;
                        if (string.Compare(objTokenResponse.Message, "Success", true) == 0 && objTokenResponse.Token != "")
                        {
                            request.CreatedUser           = objTokenResponse.UserInfo.UserName;
                            request.Application           = request.CredentialInfo.Source;
                            request.Token                 = objTokenResponse.Token;
                            request.LoggedInUserContactId = objTokenResponse.UserInfo.Contact_Id;

                            var countryInfo = agentProviders.GetPartnerCountryDetails(new Attributes {
                                Attribute_Id = request.AgentInfo.Country
                            }, objTokenResponse.Token).Result;
                            if (countryInfo != null && !string.IsNullOrEmpty(countryInfo.ResortInfo.Voyager_Resort_Id))
                            {
                                request.AgentInfo.CountryName = countryInfo.ResortInfo.ResortName;
                            }
                            else
                            {
                                return(BadRequest(countryInfo.ResponseStatus));
                            }

                            var cityInfo = agentProviders.GetPartnerCityDetails(new Attributes {
                                Attribute_Id = request.AgentInfo.City
                            }, request.AgentInfo.Country, countryInfo.ResortInfo.ResortCode, objTokenResponse.Token).Result;
                            if (cityInfo != null && !string.IsNullOrEmpty(cityInfo.ResortInfo.Voyager_Resort_Id))
                            {
                                request.AgentInfo.CityName = cityInfo.ResortInfo.ResortName;
                            }
                            else
                            {
                                return(BadRequest(cityInfo.ResponseStatus));
                            }

                            request.AgentInfo.Country = countryInfo.ResortInfo.Voyager_Resort_Id;
                            request.AgentInfo.City    = cityInfo.ResortInfo.Voyager_Resort_Id;

                            response = agentProviders.CreateUpdatePartnerAgentDetails(request, objTokenResponse.Token).Result;

                            if (response.ResponseStatus != null && !string.IsNullOrEmpty(response.ResponseStatus.Status) && response.ResponseStatus.Status.ToLower() == "duplicate")
                            {
                                return(StatusCode(Microsoft.AspNetCore.Http.StatusCodes.Status422UnprocessableEntity, response.ResponseStatus));
                            }
                            if (response.ResponseStatus != null && !string.IsNullOrEmpty(response.ResponseStatus.StatusMessage) && response.ResponseStatus.StatusMessage.ToLower() == "companycodeerror")
                            {
                                return(BadRequest(response.ResponseStatus));
                            }
                        }
                        else
                        {
                            return(Unauthorized());
                        }
                    }
                    else
                    {
                        response.ResponseStatus.Status       = "Failure";
                        response.ResponseStatus.ErrorMessage = "AgentInfo details can not be save due to error.";
                        return(BadRequest(response.ResponseStatus));
                    }
                }
            }
            catch (Exception ex)
            {
                response.ResponseStatus.Status       = "Failure";
                response.ResponseStatus.ErrorMessage = "An error occurs " + ex.Message.ToString();
                return(BadRequest(response.ResponseStatus));
            }
            return(Ok(new { Status = response.ResponseStatus.Status, ErrorMessage = response.ResponseStatus.ErrorMessage, StatusMessage = response.ResponseStatus.StatusMessage, Id = response.CompanyInfo.Company_Id }));
        }