Example #1
0
        public async Task <ResponseStatus> SetCompanyTaxRegDetails(SetCompanyTaxReg_RQ request, string ticket)
        {
            ResponseStatus response = new ResponseStatus();

            response = await serviceProxy.PostData(_configuration.GetValue <string>("BRIDGEServiceCompany:SetCompanyTaxRegDetails"), request, typeof(ResponseStatus), ticket, "Bridge");

            return(response);
        }
Example #2
0
        public IActionResult SaveTaxRegDetails(TaxRegDetails model)
        {
            request = new AgentGetReq()
            {
                CompanyId = model.Company_Id
            };
            AgentGetRes response = agentProviders.GetAgentDetailedInfo(request, token).Result;
            var         msg = ""; var taxRegID = ""; var status = "";
            AgentSetReq req          = new AgentSetReq();
            var         details      = response.AgentDetails.TaxRegestrationDetails.Where(x => x.TaxReg_Id == model.TaxReg_Id).FirstOrDefault();
            var         existsrecord = response.AgentDetails.TaxRegestrationDetails.Where(x => x.Type == model.Type && x.State == model.State && x.Number == model.Number && x.State_Id == model.State_Id && x.Type_Id == model.Type_Id).FirstOrDefault();

            if (details != null)
            {
                req.IsNewTaxRegistrationDetails = false;
                taxRegID = details.TaxReg_Id;
                req.companies.Company_Id = model.Company_Id;

                TaxRegestrationDetails b = new TaxRegestrationDetails();
                b.TaxReg_Id    = model.TaxReg_Id;
                b.Company_id   = model.Company_Id;
                b.Type         = model.Type;
                b.Type_Id      = model.Type_Id;
                b.State        = model.State;
                b.State_Id     = model.State_Id;
                b.Number       = model.Number;
                b.Taxstatus_Id = model.TaxStatus_Id;
                b.TaxStatus    = model.TaxStatus;
                b.Status       = model.Status;
                b.CreateUser   = details.CreateUser;
                b.CreateDate   = details.CreateDate;
                b.EditUser     = ckUserEmailId;
                req.companies.TaxRegestrationDetails.Add(b);
                AgentSetRes res = agentProviders.SetAgentDetailedInfo(req, token).Result;
                if (res.ResponseStatus.Status.ToLower() == "success")
                {
                    status = "success"; taxRegID = res.TaxRegId;
                }
                else if (res.ResponseStatus.Status.ToLower() == "failure")
                {
                    status = "error1";
                }
                else
                {
                    status = "error";
                }
            }
            else
            {
                req.IsNewTaxRegistrationDetails = true;

                if (existsrecord != null)
                {
                    status = "error1";
                    msg    = "Duplicate record";
                }
                else
                {
                    req.companies.Company_Id = model.Company_Id;
                    TaxRegestrationDetails b = new TaxRegestrationDetails();

                    b.TaxReg_Id    = model.TaxReg_Id;
                    b.Company_id   = model.Company_Id;
                    b.Type         = model.Type;
                    b.Type_Id      = model.Type_Id;
                    b.State        = model.State;
                    b.State_Id     = model.State_Id;
                    b.Number       = model.Number;
                    b.Taxstatus_Id = model.TaxStatus_Id;
                    b.TaxStatus    = model.TaxStatus;
                    b.Status       = model.Status;
                    b.CreateUser   = ckUserEmailId;



                    req.companies.TaxRegestrationDetails.Add(b);

                    AgentSetRes res = agentProviders.SetAgentDetailedInfo(req, token).Result;
                    model.TaxReg_Id = res.TaxRegId;
                    if (res.ResponseStatus.Status.ToLower() == "success")
                    {
                        status = "success"; taxRegID = res.TaxRegId;
                    }
                    else
                    {
                        status = "error";
                    }
                }
            }

            //Call Bridge service to save Contact data in SQL databse
            ResponseStatus result = new ResponseStatus();

            if (status == "success")
            {
                SetCompanyTaxReg_RQ request = new SetCompanyTaxReg_RQ();
                request.TaxRegId = model.TaxReg_Id;
                request.User     = ckUserEmailId;
                result           = agentProviders.SetCompanyTaxRegDetails(request, token).Result;

                if (result != null)
                {
                    if (!string.IsNullOrEmpty(result.Status) && result.Status == "Success")
                    {
                        status = "success";
                        msg    = "Details Updated Successfully.";
                    }
                    else
                    {
                        status = "error";
                        msg    = result.ErrorMessage + " " + result.StatusMessage;
                    }
                }
                else
                {
                    status = "error";
                    msg    = "Error in updating records.";
                }
            }
            return(Json(new { status = status, responseText = msg, TaxRegId = taxRegID }));
        }