예제 #1
0
        public async Task <ResponseStatus> SetCompany_ProductOperatingMarket(SetProductOperatingMarket_RQ request, string ticket)
        {
            ResponseStatus response = new ResponseStatus();

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

            return(response);
        }
예제 #2
0
        public IActionResult SaveManageProduct(ProductViewModel model)
        {
            try
            {
                var            status = ""; var msg = "";
                SupplierSetReq req = new SupplierSetReq();
                req.Company_Id             = model.CompanyId;
                req.ProductSupplier_Id     = model.ProductSupplierId;
                req.EditUser               = ckUserEmailId;
                req.IsProduct              = true;
                req.Product.SupplierStatus = model.Status == "Active" ? string.Empty : "X";
                req.Product.CurrencyId     = model.Currency_Id;
                req.Product.IsPreferred    = model.IsPreferred;
                req.Product.IsDefault      = model.IsDefault;
                if (string.IsNullOrEmpty(model.ActiveFrom))
                {
                    req.Product.ActiveFrom = null;
                }
                else
                {
                    var strFromDT = model.ActiveFrom.Split("/");
                    if (strFromDT?.Count() >= 3)
                    {
                        DateTime fromDT = new DateTime(Convert.ToInt32(strFromDT[2]), Convert.ToInt32(strFromDT[1]), Convert.ToInt32(strFromDT[0]));
                        req.Product.ActiveFrom = fromDT;
                    }
                    else
                    {
                        req.Product.ActiveFrom = null;
                    }
                }
                if (string.IsNullOrEmpty(model.ActiveTo))
                {
                    req.Product.ActiveTo = null;
                }
                else
                {
                    var strToDT = model.ActiveTo.Split("/");
                    if (strToDT?.Count() >= 3)
                    {
                        DateTime toDT = new DateTime(Convert.ToInt32(strToDT[2]), Convert.ToInt32(strToDT[1]), Convert.ToInt32(strToDT[0]));
                        req.Product.ActiveTo = toDT;
                    }
                    else
                    {
                        req.Product.ActiveTo = null;
                    }
                }

                req.Product.Contact_Sales_Id   = model.ContactSalesId;
                req.Product.Contact_Sales_Name = model.ContactSalesName;

                req.Product.Contact_FIT_Id   = model.ContactFitId;
                req.Product.Contact_FIT_Name = model.ContactFitName;

                req.Product.Contact_Group_Id   = model.ContactGroupId;
                req.Product.Contact_Group_Name = model.ContactGroupName;

                req.Product.Contact_Emergency_Id   = model.ContactEmergencyId;
                req.Product.Contact_Emergency_Name = model.ContactEmergencyName;

                req.Product.Contact_Finance_Id   = model.ContactFinanceId;
                req.Product.Contact_Finance_Name = model.ContactFinanceName;

                req.Product.Contact_Complaints_Id   = model.ContactComplaintId;
                req.Product.Contact_Complaints_Name = model.ContactComplaintName;

                req.Product.OperatingMarket = model.selectedlstOperatingMarket.Select(x => new ProductSupplierOperatingMarket {
                    ProductSupplierOperatingMkt_Id = x.ProductSupplierOperatingMkt_Id, BusinessRegion_Id = x.BusinessRegion_Id, BusinessRegion = x.BusinessRegion
                }).ToList();
                req.Product.SalesMarket = model.selectedlstSalesMarket.Select(x => new ProductSupplierSalesMarket {
                    ProductSupplierSalesMkt_Id = x.ProductSupplierSalesMkt_Id, BusinessRegion_Id = x.BusinessRegion_Id, BusinessRegion = x.BusinessRegion
                }).ToList();

                SupplierSetRes res = supplierProviders.SetSupplierProduct(req, token).Result;

                //Call Bridge service to save Product data in SQL databse
                ResponseStatus result = new ResponseStatus();
                if (res.ResponseStatus != null)
                {
                    if (res.ResponseStatus.Status.ToLower() == "success")
                    {
                        SetProduct_RQ request = new SetProduct_RQ();
                        request.ProductSupplier_Id = model.ProductSupplierId;
                        request.User = ckUserEmailId;
                        result       = supplierProviders.SetCompany_Product(request, token).Result;
                        var salesAgentId = res.SalesAgentId;

                        status = result.Status;
                        msg    = res.ResponseStatus.ErrorMessage + " " + result.StatusMessage;

                        //Call Bridge service to save Sales Market data in SQL databse
                        ResponseStatus result1 = new ResponseStatus();
                        if (res.ResponseStatus != null)
                        {
                            if (res.ResponseStatus.Status.ToLower() == "success")
                            {
                                SetProductSalesMarket_RQ request1 = new SetProductSalesMarket_RQ();
                                request1.ProductSupplier_Id = model.ProductSupplierId;
                                request1.User = ckUserEmailId;
                                result1       = supplierProviders.SetCompany_ProductSalesMarket(request1, token).Result;

                                status = result.Status;
                                msg    = res.ResponseStatus.ErrorMessage + " " + result.StatusMessage;
                            }
                            else
                            {
                                status = "failure";
                                msg    = res.ResponseStatus.ErrorMessage;
                            }
                        }

                        //Call Bridge service to save Operating Market data in SQL databse
                        ResponseStatus res1 = new ResponseStatus();
                        if (res.ResponseStatus != null)
                        {
                            if (res.ResponseStatus.Status.ToLower() == "success")
                            {
                                SetProductOperatingMarket_RQ req1 = new SetProductOperatingMarket_RQ();
                                req1.ProductSupplier_Id = model.ProductSupplierId;
                                req1.User = ckUserEmailId;
                                res1      = supplierProviders.SetCompany_ProductOperatingMarket(req1, token).Result;

                                status = result.Status;
                                msg    = res.ResponseStatus.ErrorMessage + " " + result.StatusMessage;
                            }
                            else
                            {
                                status = "failure";
                                msg    = res.ResponseStatus.ErrorMessage;
                            }
                        }


                        if (model.IsDefault == true)
                        {
                            //Call Bridge service to save Sales Agent data in SQL databse
                            ResponseStatus res2 = new ResponseStatus();
                            if (res.ResponseStatus != null)
                            {
                                if (res.ResponseStatus.Status.ToLower() == "success")
                                {
                                    SetProductSalesAgent_RQ req2 = new SetProductSalesAgent_RQ();
                                    req2.ProductSupplier_Id = model.ProductSupplierId;
                                    req2.User = ckUserEmailId;
                                    res2      = supplierProviders.DelCompany_ProductSalesAgent(req2, token).Result;

                                    status = result.Status;
                                    msg    = res.ResponseStatus.ErrorMessage + " " + result.StatusMessage;
                                }
                                else
                                {
                                    status = "failure";
                                    msg    = res.ResponseStatus.ErrorMessage;
                                }
                            }
                        }
                    }
                    else
                    {
                        status = "failure";
                        msg    = res.ResponseStatus.ErrorMessage;
                    }
                }
                return(Json(new { status = status, responseText = msg }));
            }
            catch (Exception ex)
            {
                throw;
            }
        }