예제 #1
0
        public IActionResult ViewTaxRegDetails(string CompanyId, string TaxRegId)
        {
            TaxRegDetails model = new TaxRegDetails();

            requestForTaxReg            = new TaxRegestrationDetails_Req();
            responseForTaxReg           = new TaxRegestrationDetails_Res();
            requestForTaxReg.Company_Id = CompanyId;
            requestForTaxReg.TaxReg_Id  = TaxRegId;

            responseForTaxReg = supplierProviders.GetTaxRegDetails(requestForTaxReg, token).Result;
            model.Company_Id  = CompanyId;

            #region Get currency list
            QuoteSearchViewModel modelMasterForTaxRgStatus = new QuoteSearchViewModel();
            modelMasterForTaxRgStatus = TaxTypeLibrary.BindMasterData(_configuration, token, "TaxRgStatus");
            QuoteSearchViewModel modelMasterForTaxRgType = new QuoteSearchViewModel();
            modelMasterForTaxRgType = TaxTypeLibrary.BindMasterData(_configuration, token, "TaxRgType");
            model.TaxRegStatus      = modelMasterForTaxRgStatus.TaxRgStatusList;
            model.TaxRegType        = modelMasterForTaxRgType.TaxRgTypeList;
            SalesProviders objSalesProvider = new SalesProviders(_configuration);
            var            objAgentResponse = agentProviders.GetSystemCompanyDetails(ckUserContactId, token).Result;
            AgentGetReq    request          = new AgentGetReq();
            request.CompanyId = objAgentResponse.SystemCompanyId;
            request.UserId    = ckLoginUser_Id;
            AgentGetRes responseForCompany = new AgentGetRes();
            responseForCompany = agentProviders.GetAgentDetails(request, token).Result;
            List <Attributes> stateList = masterProviders.GetAllStatesByCountryId(responseForCompany.AgentList.FirstOrDefault()?.CountryId, token).Result;
            model.States = stateList;

            #endregion

            if (responseForTaxReg != null && !string.IsNullOrEmpty(TaxRegId))
            {
                var TaxRegDetails = responseForTaxReg.TaxRegestrationDetails.Where(x => x.TaxReg_Id == TaxRegId).FirstOrDefault();
                model.TaxReg_Id    = TaxRegDetails.TaxReg_Id;
                model.State        = TaxRegDetails.State;
                model.State_Id     = TaxRegDetails.State_Id;
                model.Number       = TaxRegDetails.Number;
                model.Status       = TaxRegDetails.Status;
                model.Type         = TaxRegDetails.Type;
                model.TaxStatus    = TaxRegDetails.TaxStatus;
                model.Type_Id      = TaxRegDetails.Type_Id;
                model.TaxStatus_Id = TaxRegDetails.Taxstatus_Id;
                model.Company_Id   = TaxRegDetails.Company_id;
            }
            return(PartialView("ViewTaxRegDetails", model));
        }
예제 #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 }));
        }