Exemplo n.º 1
0
        public bool AddEarnAndBurnRule(BOTS_TblPointsEarnRuleConfig earnrule, object[] slab, string slabType)
        {
            bool status = false;

            try
            {
                using (var context = new CommonDBContext())
                {
                    BOTS_TblPointsEarnRuleConfig objpointearnburn = new BOTS_TblPointsEarnRuleConfig();

                    objpointearnburn = earnrule;
                    foreach (var item in slab)
                    {
                        BOTS_TblEarnPointsSlabConfig objslabearn = new BOTS_TblEarnPointsSlabConfig();
                        string   str  = String.Join(",", item.ToString());
                        string[] val1 = str.Split('-', (char)2);
                        objslabearn.GroupId    = earnrule.GroupId;
                        objslabearn.BrandId    = earnrule.BrandId;
                        objslabearn.CategoryId = earnrule.CategoryId;
                        objslabearn.SlabType   = slabType;
                        // objslabearn.EarnSlab
                        if (slabType == "makingslabin%")
                        {
                            objslabearn.EarnPointSlabFromPercentage = Convert.ToDecimal(Convert.ToString(val1[0]));
                            objslabearn.EarnPointSlabToPercentage   = Convert.ToDecimal(Convert.ToString(val1[1]));
                        }
                        if (slabType == "makingslabinRs")
                        {
                            objslabearn.EarnPointSlabFromPercentage = Convert.ToDecimal(Convert.ToString(val1[0]));
                            objslabearn.EarnPointSlabToPercentage   = Convert.ToDecimal(Convert.ToString(val1[1]));
                        }
                        context.BOTS_TblEarnPointsSlabConfig.AddOrUpdate(objslabearn);
                        context.SaveChanges();
                    }

                    context.BOTS_TblPointsEarnRuleConfig.AddOrUpdate(objpointearnburn);
                    context.SaveChanges();
                    status = true;
                }
            }
            catch (Exception ex)
            {
                newexception.AddException(ex, "AddEarnBurnRule");
            }


            return(status);
        }
Exemplo n.º 2
0
        // GET: CustomerOnBoarding
        public ActionResult Index(string groupId, string LeadId)
        {
            CommonFunctions common = new CommonFunctions();

            if (!string.IsNullOrEmpty(groupId))
            {
                groupId = common.DecryptString(groupId);
            }
            JavaScriptSerializer     json_serializer = new JavaScriptSerializer();
            OnBoardingSalesViewModel objData         = new OnBoardingSalesViewModel();

            try
            {
                BOTS_TblPointsEarnRuleConfig objpointsearncofig  = new BOTS_TblPointsEarnRuleConfig();
                BOTS_TblEarnPointsSlabConfig objpointsslabconfig = new BOTS_TblEarnPointsSlabConfig();
                List <SelectListItem>        refferedname        = new List <SelectListItem>();

                SelectListItem item = new SelectListItem();
                item.Value = "0";
                item.Text  = "Please Select";
                refferedname.Add(item);
                objData.lstAllGroups = refferedname;
                objData.lstBrands    = refferedname;

                objData.lstCity             = CR.GetCity();
                objData.lstRetailCategory   = CR.GetRetailCategory();
                objData.lstBillingPartner   = CR.GetBillingPartner();
                objData.lstSourcedBy        = CR.GetSourcedBy();
                objData.lstRMAssigned       = CR.GetRMAssigned();
                objData.lstRefferedCategory = CR.GetAllRefferedCategory();
                objData.lstStates           = CR.GetStates();
                if (!string.IsNullOrEmpty(LeadId))
                {
                    var leadDetails = SLR.GetsalesLeadByLeadId(Convert.ToInt32(LeadId));
                    objData.bots_TblGroupMaster = MeargeLeadData(leadDetails);
                    objData.LeadId = LeadId;
                }

                if (!string.IsNullOrEmpty(groupId))
                {
                    objData.bots_TblGroupMaster    = OBR.GetGroupMasterDetails(groupId);
                    objData.bots_TblDealDetails    = OBR.GetDealMasterDetails(groupId);
                    objData.bots_TblPaymentDetails = OBR.GetPaymentDetails(groupId);
                    objData.objRetailList          = OBR.GetRetailDetails(groupId);
                    objData.objInstallmentList     = OBR.GetInstallmentDetails(groupId);
                    objData.lstOutlets             = OBR.GetOutletDetails(groupId);

                    foreach (var brand in objData.objRetailList)
                    {
                        objData.lstBrands.Add(new SelectListItem
                        {
                            Text  = brand.BrandName,
                            Value = Convert.ToString(brand.BrandId)
                        });
                    }


                    if (objData.lstOutlets.Count == 0)
                    {
                        var brandId  = 1;
                        var outletId = 1;
                        foreach (var item1 in objData.objRetailList)
                        {
                            for (int i = 1; i <= item1.NoOfEnrolled; i++)
                            {
                                BOTS_TblOutletMaster outlet = new BOTS_TblOutletMaster();
                                outlet.Id        = 0;
                                outlet.BrandId   = Convert.ToString(brandId);
                                outlet.OutletId  = Convert.ToString(outletId);
                                outlet.BrandName = item1.BrandName;
                                objData.lstOutlets.Add(outlet);
                                outletId++;
                            }
                            brandId++;
                        }
                    }
                    else
                    {
                        foreach (var item1 in objData.objRetailList)
                        {
                            foreach (var item2 in objData.lstOutlets)
                            {
                                if (item1.BrandId == item2.BrandId)
                                {
                                    item2.BrandName = item1.BrandName;
                                }
                            }
                        }
                    }
                    objData.bots_TblGroupMaster.CategoryData        = json_serializer.Serialize(objData.objRetailList);
                    objData.bots_TblGroupMaster.PaymentScheduleData = json_serializer.Serialize(objData.objInstallmentList);
                }
                objData.lstearnpoint            = FillEarnPointLevel();
                objData.objpointsearnruleconfig = objpointsearncofig;
                objData.objearnpointslab        = objpointsslabconfig;
            }
            catch (Exception ex)
            {
                newexception.AddException(ex, "");
            }
            return(View(objData));
        }