public IActionResult EditEppGrpSetup(GroupSetupModel groupSetupModel) { try { var grpId = long.Parse(groupSetupModel.GrpId); var grpMstdata = _unitofWork.GroupMasterRepository.Find(x => x.GrpId == grpId).Result.FirstOrDefault(); if (grpMstdata == null) { return(BadRequest("Incorrect group id")); } if (!string.IsNullOrEmpty(groupSetupModel.EmlAddrss)) { // get partner id var enrlmntPrtnr = _unitofWork.eppEnrlmntPrtnrsRepository.GetEnrlmntPrtnrId(groupSetupModel.EmlAddrss); if (enrlmntPrtnr != null) { groupSetupModel.EnrlmntPrtnrsId = enrlmntPrtnr.EnrlmntPrtnrsId.ToString(); } else { _unitofWork.eppEnrlmntPrtnrsRepository.Add(new EppEnrlmntPrtnrs { EnrlmntPrtnrsId = Helper.GetRandomNumber(), CrtdBy = "", EmlAddrss = groupSetupModel.EmlAddrss, EnrlmntPrtnrsNm = groupSetupModel.EnrlmntPrtnrsNm }); } } grpMstdata.GrpNbr = groupSetupModel.GrpNbr; grpMstdata.GrpNm = groupSetupModel.GrpNm; grpMstdata.ActvFlg = groupSetupModel.ActvFlg; grpMstdata.EnrlmntPrtnrsId = long.Parse(groupSetupModel.EnrlmntPrtnrsId); grpMstdata.AcctMgrNm = groupSetupModel.AcctMgrNm; grpMstdata.AcctMgrEmailAddrs = groupSetupModel.AcctMgrEmailAddrs; grpMstdata.GrpEfftvDt = groupSetupModel.GrpEfftvDt; grpMstdata.GrpSitusSt = groupSetupModel.GrpSitusSt; grpMstdata.GrpPymnId = groupSetupModel.GrpPymn; grpMstdata.OccClass = groupSetupModel.OccClass; grpMstdata.CrtdBy = CrtdBy; // update group Master _unitofWork.GroupMasterRepository.Update(grpMstdata); UpdateAgent(groupSetupModel.GrpAgents, grpId); // add update enrollment partner if (!string.IsNullOrEmpty(groupSetupModel.EmlAddrss)) { // get partner id var enrlmntPrtnr = _unitofWork.eppEnrlmntPrtnrsRepository.GetEnrlmntPrtnrId(groupSetupModel.EmlAddrss); if (enrlmntPrtnr != null) { groupSetupModel.EnrlmntPrtnrsId = enrlmntPrtnr.EnrlmntPrtnrsId.ToString(); } else { groupSetupModel.EnrlmntPrtnrsId = Helper.GetRandomNumber().ToString(); _unitofWork.eppEnrlmntPrtnrsRepository.Add(new EppEnrlmntPrtnrs { EnrlmntPrtnrsId = long.Parse(groupSetupModel.EnrlmntPrtnrsId), CrtdBy = CrtdBy, EmlAddrss = groupSetupModel.EmlAddrss, EnrlmntPrtnrsNm = groupSetupModel.EnrlmntPrtnrsNm }); } } // goup product for existing products var Grpprdcts = _unitofWork.eppGrpprdctRepository.Find(x => x.GrpId == grpId).Result; // For Edit foreach (var prod in Grpprdcts) { var prodData = _unitofWork.EppProductRepository.SingleOrDefault(x => x.ProductId == prod.ProductId).Result; switch (prodData.ProductNm) { case "FPPG": { var prdid = Helper.GetProductIdbyName(prodData.ProductNm, _unitofWork); // add Product code if (!string.IsNullOrEmpty(groupSetupModel.FPPG.emp_ProductCode)) { PlanCodeViewModel planCodeViewModel = new PlanCodeViewModel { ProductCode = groupSetupModel.FPPG.emp_ProductCode, ProductId = prdid }; groupSetupModel.FPPG.emp_plan_cd = DataHelper.UpdatePlanCode(planCodeViewModel, _unitofWork).ProdctCdId.ToString(); } if (!string.IsNullOrEmpty(groupSetupModel.FPPG.sp_ProductCode)) { PlanCodeViewModel planCodeViewModel = new PlanCodeViewModel { ProductCode = groupSetupModel.FPPG.sp_ProductCode, ProductId = prdid }; groupSetupModel.FPPG.sp_plan_cd = DataHelper.UpdatePlanCode(planCodeViewModel, _unitofWork).ProdctCdId.ToString(); } if (!string.IsNullOrEmpty(groupSetupModel.FPPG.ch_ProductCode)) { PlanCodeViewModel planCodeViewModel = new PlanCodeViewModel { ProductCode = groupSetupModel.FPPG.ch_ProductCode, ProductId = prdid }; groupSetupModel.FPPG.ch_plan_cd = DataHelper.UpdatePlanCode(planCodeViewModel, _unitofWork).ProdctCdId.ToString(); } UpdateBulkRefTable(groupSetupModel.FPPG, prod.GrpprdctId); groupSetupModel.isFPPGActive = false; break; } case "ACC_HI": { UpdateBulkRefTable(groupSetupModel.ACC_HI, prod.GrpprdctId); groupSetupModel.isACC_HIActive = false; break; } case "ER_CI": { var prdid = Helper.GetProductIdbyName(prodData.ProductNm, _unitofWork); // add Product code if (!string.IsNullOrEmpty(groupSetupModel.ER_CI.emp_ProductCode)) { PlanCodeViewModel planCodeViewModel = new PlanCodeViewModel { ProductCode = groupSetupModel.ER_CI.emp_ProductCode, ProductId = prdid }; groupSetupModel.ER_CI.emp_plan_cd = DataHelper.UpdatePlanCode(planCodeViewModel, _unitofWork).ProdctCdId.ToString(); } if (!string.IsNullOrEmpty(groupSetupModel.ER_CI.sp_ProductCode)) { PlanCodeViewModel planCodeViewModel = new PlanCodeViewModel { ProductCode = groupSetupModel.ER_CI.sp_ProductCode, ProductId = prdid }; groupSetupModel.ER_CI.sp_plan_cd = DataHelper.UpdatePlanCode(planCodeViewModel, _unitofWork).ProdctCdId.ToString(); } if (!string.IsNullOrEmpty(groupSetupModel.ER_CI.ch_ProductCode)) { PlanCodeViewModel planCodeViewModel = new PlanCodeViewModel { ProductCode = groupSetupModel.ER_CI.ch_ProductCode, ProductId = prdid }; groupSetupModel.ER_CI.ch_plan_cd = DataHelper.UpdatePlanCode(planCodeViewModel, _unitofWork).ProdctCdId.ToString(); } UpdateBulkRefTable(groupSetupModel.ER_CI, prod.GrpprdctId); groupSetupModel.isER_CIActive = false; break; } case "VOL_CI": { var prdid = Helper.GetProductIdbyName(prodData.ProductNm, _unitofWork); if (!string.IsNullOrEmpty(groupSetupModel.VOL_CI.emp_ProductCode)) { PlanCodeViewModel planCodeViewModel = new PlanCodeViewModel { ProductCode = groupSetupModel.VOL_CI.emp_ProductCode, ProductId = prdid }; groupSetupModel.VOL_CI.emp_plan_cd = DataHelper.UpdatePlanCode(planCodeViewModel, _unitofWork).ProdctCdId.ToString(); } if (!string.IsNullOrEmpty(groupSetupModel.VOL_CI.sp_ProductCode)) { PlanCodeViewModel planCodeViewModel = new PlanCodeViewModel { ProductCode = groupSetupModel.VOL_CI.sp_ProductCode, ProductId = prdid }; groupSetupModel.VOL_CI.sp_plan_cd = DataHelper.UpdatePlanCode(planCodeViewModel, _unitofWork).ProdctCdId.ToString(); } if (!string.IsNullOrEmpty(groupSetupModel.VOL_CI.ch_ProductCode)) { PlanCodeViewModel planCodeViewModel = new PlanCodeViewModel { ProductCode = groupSetupModel.VOL_CI.ch_ProductCode, ProductId = prdid }; groupSetupModel.VOL_CI.ch_plan_cd = DataHelper.UpdatePlanCode(planCodeViewModel, _unitofWork).ProdctCdId.ToString(); } UpdateBulkRefTable(groupSetupModel.VOL_CI, prod.GrpprdctId); groupSetupModel.isVOL_CIActive = false; break; } case "VGL": { UpdateBulkRefTable(groupSetupModel.VGL, prod.GrpprdctId); groupSetupModel.isVGLActive = false; break; } case "BGL": { UpdateBulkRefTable(groupSetupModel.BGL, prod.GrpprdctId); groupSetupModel.isBGLActive = false; break; } case "FPPI": { var prdid = Helper.GetProductIdbyName(prodData.ProductNm, _unitofWork); if (!string.IsNullOrEmpty(groupSetupModel.FPPI.emp_ProductCode)) { PlanCodeViewModel planCodeViewModel = new PlanCodeViewModel { ProductCode = groupSetupModel.FPPI.emp_ProductCode, ProductId = prdid }; groupSetupModel.FPPI.emp_plan_cd = DataHelper.UpdatePlanCode(planCodeViewModel, _unitofWork).ProdctCdId.ToString(); } if (!string.IsNullOrEmpty(groupSetupModel.FPPI.sp_ProductCode)) { PlanCodeViewModel planCodeViewModel = new PlanCodeViewModel { ProductCode = groupSetupModel.FPPI.sp_ProductCode, ProductId = prdid }; groupSetupModel.FPPI.sp_plan_cd = DataHelper.UpdatePlanCode(planCodeViewModel, _unitofWork).ProdctCdId.ToString(); } if (!string.IsNullOrEmpty(groupSetupModel.FPPI.ch_ProductCode)) { PlanCodeViewModel planCodeViewModel = new PlanCodeViewModel { ProductCode = groupSetupModel.FPPI.ch_ProductCode, ProductId = prdid }; groupSetupModel.FPPI.ch_plan_cd = DataHelper.UpdatePlanCode(planCodeViewModel, _unitofWork).ProdctCdId.ToString(); } UpdateBulkRefTable(groupSetupModel.FPPI, prod.GrpprdctId); groupSetupModel.isFPPIActive = false; break; } case "HI": { UpdateBulkRefTable(groupSetupModel.HI, prod.GrpprdctId); groupSetupModel.isHIActive = false; break; } } } // for New Add // Add BulkRef data List <EppBulkRefTbl> bulkRefTbls = new List <EppBulkRefTbl>(); if (groupSetupModel.isFPPGActive) { AddFPPG(groupSetupModel.FPPG, "FPPG", grpId, bulkRefTbls); } if (groupSetupModel.isACC_HIActive) { AddACCHI(groupSetupModel.ACC_HI, "ACC_HI", grpId, bulkRefTbls); } if (groupSetupModel.isER_CIActive) { AddER_CI(groupSetupModel.ER_CI, "ER_CI", grpId, bulkRefTbls); } if (groupSetupModel.isVOL_CIActive) { AddVOL_CI(groupSetupModel.VOL_CI, "VOL_CI", grpId, bulkRefTbls); } if (groupSetupModel.isVGLActive) { AddVGL(groupSetupModel.VGL, "VGL", grpId, bulkRefTbls); } if (groupSetupModel.isBGLActive) { AddBGL(groupSetupModel.BGL, "BGL", grpId, bulkRefTbls); } if (groupSetupModel.isFPPIActive) { AddFPPI(groupSetupModel.FPPI, "FPPI", grpId, bulkRefTbls); } if (groupSetupModel.isHIActive) { AddHI(groupSetupModel.HI, "HI", grpId, bulkRefTbls); } if (bulkRefTbls.Count > 0) { _unitofWork.eppBulkRefTblRepository.AddRange(bulkRefTbls); } var id = _unitofWork.Complete().Result; return(Ok($"Group No. {groupSetupModel.GrpNbr} updated sucessfully!")); } catch (Exception ex) { throw ex; } }
public IActionResult EppGetGrpSetup(string grpNbr) { try { GroupSetupModel groupSetupModel = new GroupSetupModel(); if (string.IsNullOrEmpty(grpNbr)) { // grpNbr = "-1"; groupSetupModel.GrpPymn = 10007; return(Ok(groupSetupModel)); } var GrpMaster = _unitofWork.GroupMasterRepository.SingleOrDefault(x => x.GrpNbr == grpNbr).Result; if (GrpMaster != null) { groupSetupModel.GrpId = GrpMaster.GrpId.ToString(); groupSetupModel.GrpNbr = GrpMaster.GrpNbr; groupSetupModel.GrpNm = GrpMaster.GrpNm; groupSetupModel.ActvFlg = GrpMaster.ActvFlg; groupSetupModel.EnrlmntPrtnrsId = GrpMaster.EnrlmntPrtnrsId.ToString(); var enrlPartner = _unitofWork.eppEnrlmntPrtnrsRepository.SingleOrDefault(x => x.EnrlmntPrtnrsId == GrpMaster.EnrlmntPrtnrsId).Result; if (enrlPartner != null) { groupSetupModel.EmlAddrss = enrlPartner.EmlAddrss; groupSetupModel.EnrlmntPrtnrsNm = enrlPartner.EnrlmntPrtnrsNm; } groupSetupModel.AcctMgrNm = GrpMaster.AcctMgrNm; groupSetupModel.AcctMgrEmailAddrs = GrpMaster.AcctMgrEmailAddrs; groupSetupModel.GrpEfftvDt = GrpMaster.GrpEfftvDt; groupSetupModel.GrpPymn = GrpMaster.GrpPymnId; groupSetupModel.GrpSitusSt = GrpMaster.GrpSitusSt; groupSetupModel.user_token = GrpMaster.UsrTkn; groupSetupModel.case_token = GrpMaster.CaseTkn; groupSetupModel.OccClass = GrpMaster.OccClass; // Load Agent groupSetupModel.GrpAgents = GetAgents(GrpMaster.GrpId); // Load Product Master var Grpprdcts = _unitofWork.eppGrpprdctRepository.Find(x => x.GrpId == GrpMaster.GrpId).Result; foreach (var prod in Grpprdcts) { // load product var prodData = _unitofWork.EppProductRepository.SingleOrDefault(x => x.ProductId == prod.ProductId).Result; switch (prodData.ProductNm) { case "FPPG": { groupSetupModel.isFPPGActive = true; groupSetupModel.FPPG = new FPPG(); GetProductValue(groupSetupModel.FPPG, prod.GrpprdctId); if (!string.IsNullOrEmpty(groupSetupModel.FPPG.emp_plan_cd)) { groupSetupModel.FPPG.emp_ProductCode = GetProductCode(groupSetupModel.FPPG.emp_plan_cd); } if (!string.IsNullOrEmpty(groupSetupModel.FPPG.sp_plan_cd)) { groupSetupModel.FPPG.sp_ProductCode = GetProductCode(groupSetupModel.FPPG.sp_plan_cd); } if (!string.IsNullOrEmpty(groupSetupModel.FPPG.ch_plan_cd)) { groupSetupModel.FPPG.ch_ProductCode = GetProductCode(groupSetupModel.FPPG.ch_plan_cd); } break; } case "ACC_HI": { groupSetupModel.isACC_HIActive = true; groupSetupModel.ACC_HI = new ACC_HI(); GetProductValue(groupSetupModel.ACC_HI, prod.GrpprdctId); break; } case "ER_CI": { groupSetupModel.isER_CIActive = true; groupSetupModel.ER_CI = new ER_CI(); GetProductValue(groupSetupModel.ER_CI, prod.GrpprdctId); if (!string.IsNullOrEmpty(groupSetupModel.ER_CI.emp_plan_cd)) { groupSetupModel.ER_CI.emp_ProductCode = GetProductCode(groupSetupModel.ER_CI.emp_plan_cd); } if (!string.IsNullOrEmpty(groupSetupModel.ER_CI.sp_plan_cd)) { groupSetupModel.ER_CI.sp_ProductCode = GetProductCode(groupSetupModel.ER_CI.sp_plan_cd); } if (!string.IsNullOrEmpty(groupSetupModel.ER_CI.ch_plan_cd)) { groupSetupModel.ER_CI.ch_ProductCode = GetProductCode(groupSetupModel.ER_CI.ch_plan_cd); } break; } case "VOL_CI": { groupSetupModel.isVOL_CIActive = true; groupSetupModel.VOL_CI = new VOL_CI(); GetProductValue(groupSetupModel.VOL_CI, prod.GrpprdctId); if (!string.IsNullOrEmpty(groupSetupModel.VOL_CI.emp_plan_cd)) { groupSetupModel.VOL_CI.emp_ProductCode = GetProductCode(groupSetupModel.VOL_CI.emp_plan_cd); } if (!string.IsNullOrEmpty(groupSetupModel.VOL_CI.sp_plan_cd)) { groupSetupModel.VOL_CI.sp_ProductCode = GetProductCode(groupSetupModel.VOL_CI.sp_plan_cd); } if (!string.IsNullOrEmpty(groupSetupModel.VOL_CI.ch_plan_cd)) { groupSetupModel.VOL_CI.ch_ProductCode = GetProductCode(groupSetupModel.VOL_CI.ch_plan_cd); } break; } case "VGL": { groupSetupModel.isVGLActive = true; groupSetupModel.VGL = new VGL(); GetProductValue(groupSetupModel.VGL, prod.GrpprdctId); break; } case "BGL": { groupSetupModel.isBGLActive = true; groupSetupModel.BGL = new BGL(); GetProductValue(groupSetupModel.BGL, prod.GrpprdctId); break; } case "FPPI": { groupSetupModel.isFPPIActive = true; groupSetupModel.FPPI = new FPPI(); GetProductValue(groupSetupModel.FPPI, prod.GrpprdctId); if (!string.IsNullOrEmpty(groupSetupModel.FPPI.emp_plan_cd)) { groupSetupModel.FPPI.emp_ProductCode = GetProductCode(groupSetupModel.FPPI.emp_plan_cd); } if (!string.IsNullOrEmpty(groupSetupModel.FPPI.sp_plan_cd)) { groupSetupModel.FPPI.sp_ProductCode = GetProductCode(groupSetupModel.FPPI.sp_plan_cd); } if (!string.IsNullOrEmpty(groupSetupModel.FPPI.ch_plan_cd)) { groupSetupModel.FPPI.ch_ProductCode = GetProductCode(groupSetupModel.FPPI.ch_plan_cd); } break; } case "HI": { groupSetupModel.isHIActive = true; groupSetupModel.HI = new HI(); GetProductValue(groupSetupModel.HI, prod.GrpprdctId); break; } } } } return(Ok(groupSetupModel)); }catch (Exception ex) { throw ex; } }
public IActionResult EppCreateGrpSetup(GroupSetupModel groupSetupModel) { try { long enrlmntPrtnrsId = 0; var grpprdct = _unitofWork.GroupMasterRepository.Find(x => x.GrpNbr == groupSetupModel.GrpNbr || x.GrpNm == groupSetupModel.GrpNm).Result; if (grpprdct.Count != 0) { return(BadRequest(" Group name or number already exist")); } if (!string.IsNullOrEmpty(groupSetupModel.EmlAddrss)) { // get partner id var enrlmntPrtnr = _unitofWork.eppEnrlmntPrtnrsRepository.GetEnrlmntPrtnrId(groupSetupModel.EmlAddrss); if (enrlmntPrtnr != null) { enrlmntPrtnrsId = enrlmntPrtnr.EnrlmntPrtnrsId; groupSetupModel.EnrlmntPrtnrsId = enrlmntPrtnrsId.ToString(); } else { enrlmntPrtnrsId = Helper.GetRandomNumber(); groupSetupModel.EnrlmntPrtnrsId = enrlmntPrtnrsId.ToString(); _unitofWork.eppEnrlmntPrtnrsRepository.Add(new EppEnrlmntPrtnrs { EnrlmntPrtnrsId = long.Parse(groupSetupModel.EnrlmntPrtnrsId), CrtdBy = "", EmlAddrss = groupSetupModel.EmlAddrss, EnrlmntPrtnrsNm = groupSetupModel.EnrlmntPrtnrsNm }); } } var grpId = Helper.GetRandomNumber(); var CrtdBy = ""; _unitofWork.GroupMasterRepository.Add(new EppGrpmstr { GrpNbr = groupSetupModel.GrpNbr, GrpNm = groupSetupModel.GrpNm, ActvFlg = 'Y', EnrlmntPrtnrsId = enrlmntPrtnrsId, AcctMgrNm = groupSetupModel.AcctMgrNm, AcctMgrEmailAddrs = groupSetupModel.AcctMgrEmailAddrs, GrpEfftvDt = groupSetupModel.GrpEfftvDt, GrpSitusSt = groupSetupModel.GrpSitusSt, GrpPymnId = groupSetupModel.GrpPymn, OccClass = groupSetupModel.OccClass, CaseTkn = groupSetupModel.case_token, UsrTkn = groupSetupModel.user_token, GrpId = grpId, CrtdBy = CrtdBy, CrtdDt = DateTime.UtcNow, } ); // add Aggents UpdateAgent(groupSetupModel.GrpAgents, grpId); // Add BulkRef data List <EppBulkRefTbl> bulkRefTbls = new List <EppBulkRefTbl>(); if (groupSetupModel.isFPPGActive) { AddFPPG(groupSetupModel.FPPG, "FPPG", grpId, bulkRefTbls); } if (groupSetupModel.isACC_HIActive) { AddACCHI(groupSetupModel.ACC_HI, "ACC_HI", grpId, bulkRefTbls); } if (groupSetupModel.isER_CIActive) { AddER_CI(groupSetupModel.ER_CI, "ER_CI", grpId, bulkRefTbls); } if (groupSetupModel.isVOL_CIActive) { AddVOL_CI(groupSetupModel.VOL_CI, "VOL_CI", grpId, bulkRefTbls); } if (groupSetupModel.isVGLActive) { AddVGL(groupSetupModel.VGL, "VGL", grpId, bulkRefTbls); } if (groupSetupModel.isBGLActive) { AddBGL(groupSetupModel.BGL, "BGL", grpId, bulkRefTbls); } if (groupSetupModel.isFPPIActive) { AddFPPI(groupSetupModel.FPPI, "FPPI", grpId, bulkRefTbls); } if (groupSetupModel.isHIActive) { AddHI(groupSetupModel.HI, "HI", grpId, bulkRefTbls); } if (bulkRefTbls.Count > 0) { _unitofWork.eppBulkRefTblRepository.AddRange(bulkRefTbls); } var id = _unitofWork.Complete().Result; return(Ok($"Group No. {groupSetupModel.GrpNbr} saved successfully.")); }catch (Exception ex) { throw ex; } }