public async System.Threading.Tasks.Task <ActionResult> TravelCover(int?cid, int?PcId) { string apikey = null; if (Session["ApiKey"] != null) { apikey = Session["ApiKey"].ToString(); } else { return(RedirectToAction("AgentLogin", "Login")); } var Policyincllist = Session["Policyinclustions"] as List <SessionModel>; TravelCover TravelCover = new TravelCover(); CommonUseFunctionClass cmn = new CommonUseFunctionClass(); TravelCover.NewSections = new List <string>(); if (Session["Policyinclustions"] != null) { List <SessionModel> PolicyInclustions = new List <SessionModel>(); TravelCover.PolicyInclusions = new List <SessionModel>(); TravelCover.PolicyInclusions = Policyincllist; TravelCover.NewSections = cmn.NewSectionHome(TravelCover.PolicyInclusions); if (Policyincllist != null) { if (Policyincllist.Exists(p => p.name == "Travel")) { if (Session["unId"] == null && Session["profileId"] == null) { Session["unId"] = Policyincllist.Where(p => p.name == "Travel").Select(p => p.UnitId).First(); Session["profileId"] = Policyincllist.Where(p => p.name == "Travel").Select(p => p.ProfileId).First(); } } else { return(RedirectToAction("DisclosureDetails", "Disclosure", new { cid = cid, PcId = PcId })); } } } else { RedirectToAction("PolicyInclustions", "Customer", new { cid = cid }); } NewPolicyDetailsClass Tmodel = new NewPolicyDetailsClass(); if (cid != null && cid.HasValue && cid > 0) { ViewBag.cid = cid; TravelCover.CustomerId = cid.Value; } List <SelectListItem> ExcTcList = new List <SelectListItem>(); ExcTcList = Tmodel.excessRate(); var db = new MasterDataEntities(); TravelCover.PolicyInclusion = new List <usp_GetUnit_Result>(); ViewEditPolicyDetails unitdetails = new ViewEditPolicyDetails(); var policyinclusions = db.usp_GetUnit(null, PcId, null).ToList(); TravelCover.TravellerscoveredObj = new TravellersToBeCovered(); TravelCover.TravellerscoveredObj.EiId = 61429; TravelCover.DataofbirthObj = new DataOfBirthsTC(); TravelCover.DataofbirthObj.EiId = 61431; TravelCover.NumbertravelersObj = new NumberOfTravelers(); TravelCover.NumbertravelersObj.EiId = 61433; TravelCover.YourtripObj = new YourTrips(); TravelCover.YourtripObj.EiId = 61437; TravelCover.WintersportObj = new WinterSports(); TravelCover.WintersportObj.EiId = 61441; TravelCover.ExcessObj = new ExcessesTC(); TravelCover.ExcessObj.EiId = 61443; TravelCover.ExcessObj.ExcessList = ExcTcList; TravelCover.TravellerscoveredGObj = new TravellersToBeCoveredG(); TravelCover.TravellerscoveredGObj.EiId = 61463; TravelCover.DataofbirthGObj = new DataOfBirthsTCG(); TravelCover.DataofbirthGObj.EiId = 61465; string policyid = null; bool policyinclusion = policyinclusions.Exists(p => p.Name == "Travel"); HttpClient hclient = new HttpClient(); string url = System.Configuration.ConfigurationManager.AppSettings["APIURL"]; hclient.BaseAddress = new Uri(url); hclient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); int unid = 0; int profileid = 0; if (Session["unId"] != null && Session["profileId"] != null) { unid = Convert.ToInt32(Session["unId"]); profileid = Convert.ToInt32(Session["profileId"]); } if (PcId != null && PcId.HasValue) { TravelCover.ExistingPolicyInclustions = policyinclusions; TravelCover.PolicyInclusion = policyinclusions; TravelCover.NewSections = cmn.NewSectionP(policyinclusions); if (Session["unId"] != null && Session["profileId"] != null) { unid = Convert.ToInt32(Session["unId"]); profileid = Convert.ToInt32(Session["profileId"]); } else { return(RedirectToAction("DisclosureDetails", "Disclosure", new { cid = cid, PcId = PcId })); } //int sectionId = policyinclusions.Where(p => p.Name == "Home Contents" && p.UnitNumber == unid).Select(p => p.UnId).FirstOrDefault(); //int? profileunid = policyinclusions.Where(p => p.Name == "Home Contents" && p.ProfileUnId == profileid).Select(p => p.ProfileUnId).FirstOrDefault(); HttpResponseMessage getunit = await hclient.GetAsync("UnitDetails?ApiKey=" + apikey + "&Action=Existing&SectionName=&SectionUnId=" + unid + "&ProfileUnId=" + profileid); var EmpResponse = getunit.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); } } else { if (PcId == null && Session["unId"] == null && Session["profileId"] == null) { HttpResponseMessage Res = await hclient.GetAsync("UnitDetails?ApiKey=" + apikey + "&Action=New&SectionName=Travel&SectionUnId=&ProfileUnId="); var EmpResponse = Res.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); if (unitdetails.ErrorMessage != null && unitdetails.ErrorMessage.Count() > 0) { bool exists = TravelCover.PolicyInclusions.Exists(p => p.name == "Travel"); if (exists == true) { List <SessionModel> values = new List <SessionModel>(); values = (List <SessionModel>)Session["Policyinclustions"]; for (int k = 0; k < values.Count(); k++) { if (values[k].name == "Travel" && values[k].UnitId == null && values[k].ProfileId == null) { values.RemoveAt(k); } } Session["Policyinclustions"] = values; } var errormessage = "First please provide cover for Home Buildings."; if (unitdetails.ErrorMessage.Contains(errormessage)) { TempData["Error"] = errormessage; return(RedirectToAction("HomeDescription", "RuralLifeStyle", new { cid = cid, PcId = PcId })); } } if (unitdetails != null && unitdetails.SectionData != null) { Session["unId"] = unitdetails.SectionData.UnId; Session["profileId"] = unitdetails.SectionData.ProfileUnId; if (Policyincllist != null && Policyincllist.Exists(p => p.name == "Travel")) { var policyhomelist = Policyincllist.FindAll(p => p.name == "Travel").ToList(); if (policyhomelist != null && policyhomelist.Count() > 0) { if (Policyincllist.FindAll(p => p.name == "Travel").Exists(p => p.UnitId == null)) { Policyincllist.FindAll(p => p.name == "Travel").Where(p => p.UnitId == null).First().UnitId = unitdetails.SectionData.UnId; } if (Policyincllist.FindAll(p => p.name == "Travel").Exists(p => p.ProfileId == null)) { Policyincllist.FindAll(p => p.name == "Travel").Where(p => p.ProfileId == null).First().ProfileId = unitdetails.SectionData.ProfileUnId; } } else { Policyincllist.FindAll(p => p.name == "Travel").First().UnitId = unitdetails.SectionData.UnId; Policyincllist.FindAll(p => p.name == "Travel").First().ProfileId = unitdetails.SectionData.ProfileUnId; } TravelCover.PolicyInclusions = Policyincllist; Session["Policyinclustions"] = Policyincllist; } } } } else if (PcId == null && Session["unId"] != null && Session["profileId"] != null) { HttpResponseMessage getunit = await hclient.GetAsync("UnitDetails?ApiKey=" + apikey + "&Action=Existing&SectionName=&SectionUnId=" + unid + "&ProfileUnId=" + profileid); var EmpResponse = getunit.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); if (unitdetails != null && unitdetails.SectionData != null) { Session["unId"] = unitdetails.SectionData.UnId; Session["profileId"] = unitdetails.SectionData.ProfileUnId; } } } } if (unitdetails != null) { if (unitdetails.SectionData != null && unitdetails.SectionData.ValueData != null) { if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == TravelCover.DataofbirthObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == TravelCover.DataofbirthObj.EiId).Select(p => p.Value).FirstOrDefault(); TravelCover.DataofbirthObj.Dataofbirth = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == TravelCover.ExcessObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == TravelCover.ExcessObj.EiId).Select(p => p.Value).FirstOrDefault(); TravelCover.ExcessObj.Excess = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == TravelCover.TravellerscoveredObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == TravelCover.TravellerscoveredObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && !string.IsNullOrEmpty(val)) { TravelCover.TravellerscoveredObj.Travellerscovered = val; } if (unitdetails.SectionData.ValueData.Select(p => p.Element.ElId == TravelCover.TravellerscoveredObj.EiId).Count() > 1) { List <ValueDatas> elmnts = new List <ValueDatas>(); var TravellerscoveredList = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == TravelCover.TravellerscoveredObj.EiId).Select(p => p.Element.ItId).ToList(); for (int i = 0; i < TravellerscoveredList.Count(); i++) { ValueDatas vds = new ValueDatas(); vds.Element = new Elements(); vds.Element.ElId = 61429; vds.Element.ItId = TravellerscoveredList[i]; vds.Value = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == TravelCover.TravellerscoveredObj.EiId && p.Element.ItId == TravellerscoveredList[i]).Select(p => p.Value).FirstOrDefault(); elmnts.Add(vds); } TravelCover.TravellerscoveredObjList = elmnts; } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == TravelCover.DataofbirthObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == TravelCover.DataofbirthObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && !string.IsNullOrEmpty(val)) { TravelCover.DataofbirthObj.Dataofbirth = val; } if (unitdetails.SectionData.ValueData.Select(p => p.Element.ElId == TravelCover.DataofbirthObj.EiId).Count() > 1) { List <ValueDatas> elmnts = new List <ValueDatas>(); var DataofbirthList = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == TravelCover.DataofbirthObj.EiId).Select(p => p.Element.ItId).ToList(); for (int i = 0; i < DataofbirthList.Count(); i++) { ValueDatas vds = new ValueDatas(); vds.Element = new Elements(); vds.Element.ElId = 61431; vds.Element.ItId = DataofbirthList[i]; vds.Value = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == TravelCover.DataofbirthObj.EiId && p.Element.ItId == DataofbirthList[i]).Select(p => p.Value).FirstOrDefault(); elmnts.Add(vds); } TravelCover.DataofbirthObjList = elmnts; } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == TravelCover.TravellerscoveredGObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == TravelCover.TravellerscoveredGObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && !string.IsNullOrEmpty(val)) { TravelCover.TravellerscoveredGObj.Travellerscovered = val; } if (unitdetails.SectionData.ValueData.Select(p => p.Element.ElId == TravelCover.TravellerscoveredGObj.EiId).Count() > 1) { List <ValueDatas> elmnts = new List <ValueDatas>(); var TravellerscoveredGList = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == TravelCover.TravellerscoveredGObj.EiId).Select(p => p.Element.ItId).ToList(); for (int i = 0; i < TravellerscoveredGList.Count(); i++) { ValueDatas vds = new ValueDatas(); vds.Element = new Elements(); vds.Element.ElId = 61463; vds.Element.ItId = TravellerscoveredGList[i]; vds.Value = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == TravelCover.TravellerscoveredGObj.EiId && p.Element.ItId == TravellerscoveredGList[i]).Select(p => p.Value).FirstOrDefault(); elmnts.Add(vds); } TravelCover.TravellerscoveredGObjList = elmnts; } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == TravelCover.DataofbirthGObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == TravelCover.DataofbirthGObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && !string.IsNullOrEmpty(val)) { TravelCover.DataofbirthGObj.Dataofbirth = val; } if (unitdetails.SectionData.ValueData.Select(p => p.Element.ElId == TravelCover.DataofbirthGObj.EiId).Count() > 1) { List <ValueDatas> elmnts = new List <ValueDatas>(); var DataofbirthGList = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == TravelCover.DataofbirthGObj.EiId).Select(p => p.Element.ItId).ToList(); for (int i = 0; i < DataofbirthGList.Count(); i++) { ValueDatas vds = new ValueDatas(); vds.Element = new Elements(); vds.Element.ElId = 61465; vds.Element.ItId = DataofbirthGList[i]; vds.Value = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == TravelCover.DataofbirthGObj.EiId && p.Element.ItId == DataofbirthGList[i]).Select(p => p.Value).FirstOrDefault(); elmnts.Add(vds); } TravelCover.DataofbirthGObjList = elmnts; } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == TravelCover.TravellerscoveredObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == TravelCover.TravellerscoveredObj.EiId).Select(p => p.Value).FirstOrDefault(); TravelCover.TravellerscoveredObj.Travellerscovered = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == TravelCover.WintersportObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == TravelCover.WintersportObj.EiId).Select(p => p.Value).FirstOrDefault(); TravelCover.WintersportObj.Wintersport = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == TravelCover.YourtripObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == TravelCover.YourtripObj.EiId).Select(p => p.Value).FirstOrDefault(); TravelCover.YourtripObj.Yourtrip = val; } } } if (unitdetails != null && unitdetails.ReferralList != null) { TravelCover.ReferralList = unitdetails.ReferralList; TravelCover.ReferralList.Replace("  ", ""); TravelCover.Referels = new List <string>(); string[] delim = { "<br/>" }; string[] spltd = TravelCover.ReferralList.Split(delim, StringSplitOptions.None); if (spltd != null && spltd.Count() > 0) { for (int i = 0; i < spltd.Count(); i++) { TravelCover.Referels.Add(spltd[i].Replace("  ", " ")); } } } if (cid != null) { TravelCover.CustomerId = cid.Value; } if (PcId != null && PcId > 0) { TravelCover.PcId = PcId; } Session["Controller"] = "Travel"; Session["ActionName"] = "TravelCover"; return(View(TravelCover)); }
public async System.Threading.Tasks.Task <ActionResult> Valuables(int?cid, int?PcId) { string apikey = null; ValuablesHC ValuablesHC = new ValuablesHC(); CommonUseFunctionClass cmn = new CommonUseFunctionClass(); ValuablesHC.NewSections = new List <string>(); if (Session["ApiKey"] != null) { apikey = Session["ApiKey"].ToString(); } else { return(RedirectToAction("AgentLogin", "Login")); } var Policyincllist = Session["Policyinclustions"] as List <SessionModel>; if (Session["Policyinclustions"] != null) { ValuablesHC.PolicyInclusions = new List <SessionModel>(); ValuablesHC.PolicyInclusions = Policyincllist; if (Policyincllist != null) { //var Policyincllist = Session["Policyinclustions"] as List<SessionModel>; // var Suburb = new List<KeyValuePair<string, string>>(); // List<SelectListItem> listItems = new List<SelectListItem>(); ValuablesHC.NewSections = cmn.NewSectionHome(ValuablesHC.PolicyInclusions); if (Policyincllist != null) { if (Policyincllist.Exists(p => p.name == "Valuables")) { } else if (Policyincllist.Exists(p => p.name == "Farm Property")) { return(RedirectToAction("FarmContents", "Farm", new { cid = cid })); } else if (Policyincllist.Exists(p => p.name == "Liability")) { return(RedirectToAction("LiabilityCover", "Liabilities", new { cid = cid })); } else if (Policyincllist.Exists(p => p.name == "Motor" || p.name == "Motors")) { return(RedirectToAction("VehicleDescription", "MotorCover", new { cid = cid })); } else if (Policyincllist.Exists(p => p.name == "Boat")) { return(RedirectToAction("BoatDetails", "Boat", new { cid = cid })); } else if (Policyincllist.Exists(p => p.name == "Pet" || p.name == "Pets")) { return(RedirectToAction("PetsCover", "Pets", new { cid = cid })); } else if (Policyincllist.Exists(p => p.name == "Travel")) { return(RedirectToAction("TravelCover", "Travel", new { cid = cid })); } if (Policyincllist.Exists(p => p.name == "Valuables")) { if (Session["unId"] == null && Session["profileId"] == null) { Session["unId"] = Policyincllist.Where(p => p.name == "Valuables").Select(p => p.UnitId).First(); Session["profileId"] = Policyincllist.Where(p => p.name == "Valuables").Select(p => p.ProfileId).First(); } } else { return(RedirectToAction("DisclosureDetails", "Disclosure", new { cid = cid, PcId = PcId })); } //else //{ // return RedirectToAction("PremiumDetails", "Customer", new { cid = cid, PcId = PcId }); //} } } } else { RedirectToAction("PolicyInclustions", "Customer", new { CustomerId = cid, type = 1029 }); } MasterDataEntities db = new MasterDataEntities(); NewPolicyDetailsClass HCmodel = new NewPolicyDetailsClass(); List <SelectListItem> HCList = new List <SelectListItem>(); HCList = HCmodel.excessRate(); ViewEditPolicyDetails unitdetails = new ViewEditPolicyDetails(); var policyinclusions = db.usp_GetUnit(null, PcId, null).ToList(); ValuablesHC.PolicyInclusion = new List <usp_GetUnit_Result>(); if (PcId != null && PcId.HasValue && PcId > 0) { ValuablesHC.PolicyInclusion = policyinclusions; } //var suburblist = db.IT_Master_GetSuburbList().ToList(); //ValuablesHC.SubUrb = suburblist.Where(s => !string.IsNullOrEmpty(s)).Select(s => new SelectListItem() { Text = s, Value = s }).ToList(); if (cid != null) { ViewBag.cid = cid; ValuablesHC.CustomerId = cid.Value; } else { ViewBag.cid = ValuablesHC.CustomerId; } ValuablesHC.AddressObj = new Addresses(); ValuablesHC.LocationObj = new LocationNew(); ValuablesHC.UnspecificObj = new Unspecifics(); ValuablesHC.UnspecificObj.EiId = 60383; ValuablesHC.DescriptionObj = new Descriptions(); ValuablesHC.DescriptionObj.EiId = 60391; ValuablesHC.SuminsuredObj = new SumInsures(); ValuablesHC.SuminsuredObj.EiId = 60393; ValuablesHC.TotalcoverObj = new TotalCovers(); ValuablesHC.TotalcoverObj.EiId = 0; ValuablesHC.ExcesspayObj = new ExcessesPay(); ValuablesHC.ExcesspayObj.ExcessList = HCList; ValuablesHC.ExcesspayObj.EiId = 60399; string policyid = null; bool policyinclusion = policyinclusions.Exists(p => p.Name == "Valuables"); HttpClient hclient = new HttpClient(); string url = System.Configuration.ConfigurationManager.AppSettings["APIURL"]; hclient.BaseAddress = new Uri(url); hclient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); if (PcId != null && PcId.HasValue) { int?unid = null; int?profileid = null; if (Session["unId"] != null && Session["profileId"] != null) { unid = Convert.ToInt32(Session["unId"]); profileid = Convert.ToInt32(Session["profileId"]); Session["unId"] = unid; Session["profileId"] = profileid; } else { if (policyinclusions.Exists(p => p.Name == "Valuables")) { unid = policyinclusions.Where(p => p.Name == "Valuables").Select(p => p.UnId).FirstOrDefault(); profileid = policyinclusions.Where(p => p.Name == "Valuables").Select(p => p.UnId).FirstOrDefault(); } else { return(RedirectToAction("FarmContents", "Farm", new { cid = cid, PcId = PcId })); } } ValuablesHC.NewSections = cmn.NewSectionP(policyinclusions); if (unid == null || unid == 0) { unid = unitdetails.SectionData.UnId; profileid = unitdetails.SectionData.ProfileUnId; } ValuablesHC.ExistingPolicyInclustions = policyinclusions; //int sectionId = policyinclusions.Where(p => p.Name == "Home Contents" && p.UnitNumber == unid).Select(p => p.UnId).FirstOrDefault(); //int? profileunid = policyinclusions.Where(p => p.Name == "Home Contents" && p.ProfileUnId == profileid).Select(p => p.ProfileUnId).FirstOrDefault(); HttpResponseMessage getunit = await hclient.GetAsync("UnitDetails?ApiKey=" + apikey + "&Action=Existing&SectionName=&SectionUnId=" + unid + "&ProfileUnId=" + profileid); var EmpResponse = getunit.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); } } else if (PcId == null && Session["unId"] != null && (Session["profileId"] != null)) { int unid = Convert.ToInt32(Session["unId"]); int profileid = Convert.ToInt32(Session["profileId"]); HttpResponseMessage getunit = await hclient.GetAsync("UnitDetails?ApiKey=" + apikey + "&Action=Existing&SectionName=&SectionUnId=" + unid + "&ProfileUnId=" + profileid); var EmpResponse = getunit.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); } } else { int HprofileId = -1; if (Session["HprofileId"] != null) { HprofileId = Convert.ToInt32(Session["HprofileId"]); } HttpResponseMessage Res = await hclient.GetAsync("UnitDetails?ApiKey=" + apikey + "&Action=New&SectionName=Valuables&SectionUnId=&ProfileUnId=" + HprofileId); var EmpResponse = Res.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); if (unitdetails.ErrorMessage != null && unitdetails.ErrorMessage.Count() > 0) { bool exists = ValuablesHC.PolicyInclusions.Exists(p => p.name == "Valuables"); if (exists == true) { List <SessionModel> values = new List <SessionModel>(); values = (List <SessionModel>)Session["Policyinclustions"]; for (int k = 0; k < values.Count(); k++) { if (values[k].name == "Valuables" && values[k].UnitId == null && values[k].ProfileId == null) { values.RemoveAt(k); } } Session["Policyinclustions"] = values; } var errormessage = "First please provide cover for Home Buildings."; if (unitdetails.ErrorMessage.Contains(errormessage)) { TempData["Error"] = errormessage; return(RedirectToAction("HomeDescription", "RuralLifeStyle", new { cid = cid, PcId = PcId })); } } if (Policyincllist != null && Policyincllist.Exists(p => p.name == "Valuables")) { var policyhomelist = Policyincllist.FindAll(p => p.name == "Valuables").ToList(); if (policyhomelist != null && policyhomelist.Count() > 0) { if (Policyincllist.FindAll(p => p.name == "Valuables").Exists(p => p.UnitId == null)) { Policyincllist.FindAll(p => p.name == "Valuables").Where(p => p.UnitId == null).First().UnitId = unitdetails.SectionData.UnId; } if (Policyincllist.FindAll(p => p.name == "Valuables").Exists(p => p.ProfileId == null)) { Policyincllist.FindAll(p => p.name == "Valuables").Where(p => p.ProfileId == null).First().ProfileId = unitdetails.SectionData.ProfileUnId; } } else { Policyincllist.FindAll(p => p.name == "Valuables").First().UnitId = unitdetails.SectionData.UnId; Policyincllist.FindAll(p => p.name == "Valuables").First().ProfileId = unitdetails.SectionData.ProfileUnId; } ValuablesHC.PolicyInclusions = Policyincllist; Session["Policyinclustions"] = Policyincllist; } if (unitdetails != null && unitdetails.SectionData != null) { Session["unId"] = unitdetails.SectionData.UnId; Session["profileId"] = unitdetails.SectionData.ProfileUnId; } } } if (unitdetails != null) { if (unitdetails.SectionData != null) { if (unitdetails != null && unitdetails.SectionData != null && unitdetails.SectionData.AddressData != null) { if (unitdetails.SectionData.AddressData != null) { ValuablesHC.AddressObj.Address = unitdetails.SectionData.AddressData.AddressLine1 + ", " + unitdetails.SectionData.AddressData.Suburb + " ," + unitdetails.SectionData.AddressData.State + ", " + unitdetails.SectionData.AddressData.Postcode; } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == ValuablesHC.SuminsuredObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == ValuablesHC.SuminsuredObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && !string.IsNullOrEmpty(val)) { ValuablesHC.SuminsuredObj.Suminsured = val; } if (unitdetails.SectionData.ValueData.Select(p => p.Element.ElId == ValuablesHC.SuminsuredObj.EiId).Count() > 1) { List <ValueDatas> elmnts = new List <ValueDatas>(); var suminsuredList = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == ValuablesHC.SuminsuredObj.EiId).Select(p => p.Element.ItId).ToList(); for (int i = 0; i < suminsuredList.Count(); i++) { ValueDatas vds = new ValueDatas(); vds.Element = new Elements(); vds.Element.ElId = 60393; vds.Element.ItId = suminsuredList[i]; vds.Value = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == ValuablesHC.SuminsuredObj.EiId && p.Element.ItId == suminsuredList[i]).Select(p => p.Value).FirstOrDefault(); elmnts.Add(vds); } ValuablesHC.SuminsuredObjList = elmnts; } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == ValuablesHC.DescriptionObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == ValuablesHC.DescriptionObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && !string.IsNullOrEmpty(val)) { ValuablesHC.DescriptionObj.Description = val; } if (unitdetails.SectionData.ValueData.Select(p => p.Element.ElId == ValuablesHC.DescriptionObj.EiId).Count() > 1) { List <ValueDatas> elmnts = new List <ValueDatas>(); var descriptionList = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == ValuablesHC.DescriptionObj.EiId).Select(p => p.Element.ItId).ToList(); for (int i = 0; i < descriptionList.Count(); i++) { ValueDatas vds = new ValueDatas(); vds.Element = new Elements(); vds.Element.ElId = 60391; vds.Element.ItId = descriptionList[i]; vds.Value = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == ValuablesHC.DescriptionObj.EiId && p.Element.ItId == descriptionList[i]).Select(p => p.Value).FirstOrDefault(); elmnts.Add(vds); } ValuablesHC.DescriptionObjList = elmnts; } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == ValuablesHC.LocationObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == ValuablesHC.LocationObj.EiId).Select(p => p.Value).FirstOrDefault(); ValuablesHC.LocationObj.Location = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == ValuablesHC.ExcesspayObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == ValuablesHC.ExcesspayObj.EiId).Select(p => p.Value).FirstOrDefault(); ValuablesHC.ExcesspayObj.Excess = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == ValuablesHC.TotalcoverObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == ValuablesHC.TotalcoverObj.EiId).Select(p => p.Value).FirstOrDefault(); ValuablesHC.TotalcoverObj.Totalcover = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == ValuablesHC.UnspecificObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == ValuablesHC.UnspecificObj.EiId).Select(p => p.Value).FirstOrDefault(); ValuablesHC.UnspecificObj.Unspecific = val; } } } if (unitdetails.ReferralList != null) { ValuablesHC.ReferralList = unitdetails.ReferralList; ValuablesHC.ReferralList.Replace("  ", ""); ValuablesHC.Referels = new List <string>(); string[] delim = { "<br/>" }; string[] spltd = ValuablesHC.ReferralList.Split(delim, StringSplitOptions.None); if (spltd != null && spltd.Count() > 0) { for (int i = 0; i < spltd.Count(); i++) { ValuablesHC.Referels.Add(spltd[i].Replace("  ", " ")); } } } if (cid != null) { ValuablesHC.CustomerId = cid.Value; } if (PcId != null && PcId > 0) { ValuablesHC.PcId = PcId; } Session["Controller"] = "HomeContentValuable"; Session["ActionName"] = "Valuables"; return(View(ValuablesHC)); }
public async System.Threading.Tasks.Task <ActionResult> Valuables(int?cid, int?PcId) { ViewEditPolicyDetails unitdetails = new ViewEditPolicyDetails(); string ApiKey = null; if (Session["ApiKey"] != null) { ApiKey = Session["ApiKey"].ToString(); } else { return(RedirectToAction("AgentLogin", "Login")); } var Policyincllist = new List <SessionModel>(); FPValuables FPValuables = new FPValuables(); if (Session["Policyinclustions"] != null) { Policyincllist = Session["Policyinclustions"] as List <SessionModel>; if (Policyincllist != null) { if (Policyincllist != null) { if (Policyincllist.Exists(p => p.name == "Valuables")) { } else if (Policyincllist.Exists(p => p.name == "Motor")) { return(RedirectToAction("VehicleDescription", "FarmMotors", new { cid = cid, PcId = PcId })); } if (Policyincllist.Exists(p => p.name == "Valuables")) { if (Session["unId"] == null && Session["profileId"] == null) { Session["unId"] = Policyincllist.Where(p => p.name == "Valuables").Select(p => p.UnitId).First(); Session["profileId"] = Policyincllist.Where(p => p.name == "Valuables").Select(p => p.ProfileId).First(); } } else { return(RedirectToAction("DisclosureDetails", "Disclosure", new { cid = cid, PcId = PcId })); } } } } else { RedirectToAction("PolicyInclustions", "Customer", new { CustomerId = cid, type = 1021 }); } ViewBag.cid = cid; if (cid != null) { FPValuables.CustomerId = cid.Value; } NewPolicyDetailsClass commonModel = new NewPolicyDetailsClass(); List <SelectListItem> DescriptionSpeciItemsList = new List <SelectListItem>(); DescriptionSpeciItemsList = commonModel.descriptionListFC(); List <SelectListItem> ValuablesexcessToPay = new List <SelectListItem>(); ValuablesexcessToPay = commonModel.excessRate(); FPValuables.CoverUnspecifiedValuablesObj = new CoverForUnspecifiedValuables(); FPValuables.CoverUnspecifiedValuablesObj.EiId = 63725; FPValuables.SpecifiedItemDescriptionObj = new SpecifiedItemDescription(); FPValuables.SpecifiedItemDescriptionObj.SpecItemDescriptionList = DescriptionSpeciItemsList; FPValuables.SpecifiedItemDescriptionObj.EiId = 63733; FPValuables.SpecifiedItemSumInsuredObj = new SpecifiedItemSumInsured(); FPValuables.SpecifiedItemSumInsuredObj.EiId = 63735; FPValuables.ExcessValuablesObj = new ExcessValuables(); FPValuables.ExcessValuablesObj.ExcessList = ValuablesexcessToPay; FPValuables.ExcessValuablesObj.EiId = 63741; var db = new MasterDataEntities(); string policyid = null; HttpClient hclient = new HttpClient(); string url = System.Configuration.ConfigurationManager.AppSettings["APIURL"]; hclient.BaseAddress = new Uri(url); hclient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); int unid = 0; int?profileid = 0; int Fprofileid = 0; if (Session["unId"] != null && Session["ProfileId"] != null) { unid = Convert.ToInt32(Session["unId"]); profileid = Convert.ToInt32(Session["profileId"]); } if (Session["FProfileId"] != null) { Fprofileid = Convert.ToInt32(Session["FprofileId"]); } if (Session["Policyinclustions"] != null) { FPValuables.PolicyInclusions = Policyincllist; } if (PcId != null && PcId.HasValue && PcId > 0) { var policyinclusions = db.usp_GetUnit(null, PcId, null).ToList(); FPValuables.PolicyInclusion = new List <usp_GetUnit_Result>(); if (PcId != null && PcId.HasValue && PcId > 0) { FPValuables.PolicyInclusion = policyinclusions; } FPValuables.PolicyInclusions = new List <SessionModel>(); if (PcId != null && PcId > 0) { policyid = PcId.ToString(); FPValuables.PolicyId = policyid; } bool policyinclusion = policyinclusions.Exists(p => p.Name == "Valuables"); if (policyinclusion == true && PcId != null && PcId.HasValue) { unid = policyinclusions.Where(p => p.Name == "Valuables").Select(p => p.UnId).FirstOrDefault(); profileid = policyinclusions.Where(p => p.Name == "Valuables").Select(p => p.ProfileUnId).FirstOrDefault(); HttpResponseMessage getunit = await hclient.GetAsync("UnitDetails?ApiKey=" + ApiKey + "&Action=Existing&SectionName=&SectionUnId=" + unid + "&ProfileUnId=" + profileid); var EmpResponse = getunit.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); } } else { return(RedirectToAction("VehicleDescription", "FarmMotors", new { cid = cid, PcId = PcId })); } } else { if (PcId == null && Session["unId"] == null && Session["profileId"] == null) { HttpResponseMessage Res = await hclient.GetAsync("UnitDetails?ApiKey=" + ApiKey + "&Action=New&SectionName=Valuables&SectionUnId=&ProfileUnId="); var EmpResponse = Res.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); if (unitdetails != null && unitdetails.SectionData != null) { Session["unId"] = unitdetails.SectionData.UnId; Session["FprofileId"] = unitdetails.SectionData.ProfileUnId; Session["profileId"] = unitdetails.SectionData.ProfileUnId; if (Policyincllist != null && Policyincllist.Exists(p => p.name == "Valuables")) { var policyhomelist = Policyincllist.FindAll(p => p.name == "Valuables").ToList(); if (policyhomelist != null && policyhomelist.Count() > 0) { Policyincllist.FindAll(p => p.name == "Valuables").Where(p => p.UnitId == null).First().UnitId = unitdetails.SectionData.UnId; Policyincllist.FindAll(p => p.name == "Valuables").Where(p => p.ProfileId == null).First().ProfileId = unitdetails.SectionData.ProfileUnId; } else { Policyincllist.FindAll(p => p.name == "Valuables").First().UnitId = unitdetails.SectionData.UnId; Policyincllist.FindAll(p => p.name == "Valuables").First().ProfileId = unitdetails.SectionData.ProfileUnId; } } } } } else { if (PcId == null && Session["unId"] != null && (Session["profileId"] != null || (Fprofileid != null && Fprofileid < 0))) { if (profileid == null || profileid == 0) { profileid = Fprofileid; } HttpResponseMessage getunit = await hclient.GetAsync("UnitDetails?ApiKey=" + ApiKey + "&Action=Existing&SectionName=&SectionUnId=" + unid + "&ProfileUnId=" + profileid); var EmpResponse = getunit.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); if (unitdetails != null && unitdetails.SectionData != null) { Session["unId"] = unitdetails.SectionData.UnId; Session["profileId"] = unitdetails.SectionData.ProfileUnId; Session["FprofileId"] = unitdetails.SectionData.ProfileUnId; } } } } } if (unitdetails != null) { if (unitdetails.ProfileData != null) { if (unitdetails.ProfileData.ValueData.Exists(p => p.Element.ElId == FPValuables.CoverUnspecifiedValuablesObj.EiId)) { string val = unitdetails.ProfileData.ValueData.Where(p => p.Element.ElId == FPValuables.CoverUnspecifiedValuablesObj.EiId).Select(p => p.Value).FirstOrDefault(); FPValuables.CoverUnspecifiedValuablesObj.CoverUnspecifiedValuables = val; } if (unitdetails.ProfileData.ValueData.Exists(p => p.Element.ElId == FPValuables.ExcessValuablesObj.EiId)) { string val = unitdetails.ProfileData.ValueData.Where(p => p.Element.ElId == FPValuables.ExcessValuablesObj.EiId).Select(p => p.Value).FirstOrDefault(); FPValuables.ExcessValuablesObj.Excess = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPValuables.SpecifiedItemDescriptionObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPValuables.SpecifiedItemDescriptionObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && !string.IsNullOrEmpty(val)) { FPValuables.SpecifiedItemDescriptionObj.ItemDescription = val; } if (unitdetails.SectionData.ValueData.Select(p => p.Element.ElId == FPValuables.SpecifiedItemDescriptionObj.EiId).Count() > 1) { List <ValueDatas> elmnts = new List <ValueDatas>(); var ItemDescriptionList = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPValuables.SpecifiedItemDescriptionObj.EiId).Select(p => p.Element.ItId).ToList(); for (int i = 0; i < ItemDescriptionList.Count(); i++) { ValueDatas vds = new ValueDatas(); vds.Element = new Elements(); vds.Element.ElId = 63733; vds.Element.ItId = ItemDescriptionList[i]; vds.Value = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPValuables.SpecifiedItemDescriptionObj.EiId && p.Element.ItId == ItemDescriptionList[i]).Select(p => p.Value).FirstOrDefault(); elmnts.Add(vds); } FPValuables.SpecifiedItemDescriptionList = elmnts; } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPValuables.SpecifiedItemSumInsuredObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPValuables.SpecifiedItemSumInsuredObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && !string.IsNullOrEmpty(val)) { FPValuables.SpecifiedItemSumInsuredObj.ItemSumInsured = val; } if (unitdetails.SectionData.ValueData.Select(p => p.Element.ElId == FPValuables.SpecifiedItemSumInsuredObj.EiId).Count() > 1) { List <ValueDatas> elmnts = new List <ValueDatas>(); var ItemSumInsuredList = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPValuables.SpecifiedItemSumInsuredObj.EiId).Select(p => p.Element.ItId).ToList(); for (int i = 0; i < ItemSumInsuredList.Count(); i++) { ValueDatas vds = new ValueDatas(); vds.Element = new Elements(); vds.Element.ElId = 63735; vds.Element.ItId = ItemSumInsuredList[i]; vds.Value = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPValuables.SpecifiedItemSumInsuredObj.EiId && p.Element.ItId == ItemSumInsuredList[i]).Select(p => p.Value).FirstOrDefault(); elmnts.Add(vds); } FPValuables.SpecifiedItemSumInsuredList = elmnts; } } } } if (cid != null && cid.HasValue && cid > 0) { FPValuables.CustomerId = cid.Value; } if (PcId != null && PcId > 0) { FPValuables.PcId = PcId; } Session["Controller"] = "FarmPolicyValuables"; Session["ActionName"] = "Valuables"; return(View(FPValuables)); }
public async System.Threading.Tasks.Task <ActionResult> PetsCover(int?cid, int?PcId) { string apikey = null; NewPolicyDetailsClass petsmodel = new NewPolicyDetailsClass(); ViewEditPolicyDetails unitdetails = new ViewEditPolicyDetails(); Pets Pets = new Pets(); List <SessionModel> PolicyInclustions = new List <SessionModel>(); var Policyincllist = new List <SessionModel>(); if (Session["ApiKey"] != null) { apikey = Session["ApiKey"].ToString(); } else { return(RedirectToAction("AgentLogin", "Login")); } CommonUseFunctionClass cmn = new CommonUseFunctionClass(); Pets.NewSections = new List <string>(); if (Session["Policyinclustions"] != null) { Policyincllist = Session["Policyinclustions"] as List <SessionModel>; Pets.PolicyInclusions = new List <SessionModel>(); Pets.PolicyInclusions = Policyincllist; Pets.NewSections = cmn.NewSectionHome(Pets.PolicyInclusions); if (Policyincllist != null) { if (Policyincllist.Exists(p => p.name == "Pet" || p.name == "Pets")) { if (Session["unId"] == null && Session["profileId"] == null) { Session["unId"] = Policyincllist.Where(p => p.name == "Pet" || p.name == "Pets").Select(p => p.UnitId).First(); Session["profileId"] = Policyincllist.Where(p => p.name == "Pet" || p.name == "Pets").Select(p => p.ProfileId).First(); } } else { if (Policyincllist.Exists(p => p.name == "Travel")) { return(RedirectToAction("TravelCover", "Travel", new { cid = cid, PcId = PcId })); } else { return(RedirectToAction("DisclosureDetails", "Disclosure", new { cid = cid, PcId = PcId })); } } } } else { RedirectToAction("PolicyInclustions", "Customer", new { CustomerId = cid }); } var db = new MasterDataEntities(); var policyinclusions = db.usp_GetUnit(null, PcId, null).ToList(); List <SelectListItem> petsBreedslist = new List <SelectListItem>(); petsBreedslist = petsmodel.breedListDog(); Pets.SpeciesObj = new Speciesed(); Pets.SpeciesObj.EiId = 61331; Pets.BreedObj = new Breeds(); Pets.BreedObj.BreedList = petsBreedslist; Pets.BreedObj.EiId = 61333; Pets.OtherbreedObj = new OtherBreeds(); Pets.OtherbreedObj.EiId = 61337; Pets.NameObj = new Names(); Pets.NameObj.EiId = 61339; Pets.DatebirthObj = new DateOfBirth(); Pets.DatebirthObj.EiId = 61341; Pets.PreexistingObj = new PreExistings(); Pets.PreexistingObj.EiId = 61343; Pets.DescriptionillnessObj = new DescriptionOfIllness(); Pets.DescriptionillnessObj.EiId = 61345; Pets.AnnualcoverlimitObj = new AnnualCoverLimits(); Pets.AnnualcoverlimitObj.EiId = 61347; Pets.ExcessPetObj = new ExcessPets(); Pets.ExcessPetObj.EiId = 61349; Pets.BoardingfeeObj = new BoardingFees(); Pets.BoardingfeeObj.EiId = 61365; Pets.AnnuallimitbfObj = new AnnualLimitsBF(); Pets.AnnuallimitbfObj.EiId = 61367; Pets.DeathillnessObj = new DeathFromIllness(); Pets.DeathillnessObj.EiId = 61369; Pets.AnnuallimitdtObj = new AnnualLimitsDT(); Pets.AnnuallimitdtObj.EiId = 61371; Pets.DeathinjuryObj = new DeathFromInjury(); Pets.DeathinjuryObj.EiId = 61373; Pets.AnnuallimitijObj = new AnnualLimitsIJ(); Pets.AnnuallimitijObj.EiId = 61375; List <SelectListItem> sepclist = new List <SelectListItem>(); sepclist.Add(new SelectListItem { Text = "Dog", Value = "1" }); sepclist.Add(new SelectListItem { Text = "Cat", Value = "2" }); Pets.SpeciesObj.SpeciesList = sepclist; List <SelectListItem> ExcList = new List <SelectListItem>(); ExcList.Add(new SelectListItem { Text = "$250", Value = "1" }); Pets.ExcessPetObj.ExcessList = ExcList; Pets.CustomerId = cid ?? 0; string policyid = null; bool policyinclusion = policyinclusions.Exists(p => p.Name == "Pet"); HttpClient hclient = new HttpClient(); string url = System.Configuration.ConfigurationManager.AppSettings["APIURL"]; hclient.BaseAddress = new Uri(url); hclient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); int unid = 0; int profileid = 0; if (Session["unId"] != null) { unid = Convert.ToInt32(Session["unId"]); } if (Session["profileId"] != null) { profileid = Convert.ToInt32(Session["profileId"]); } if (PcId != null && PcId.HasValue) { Pets.PolicyInclusion = policyinclusions; Pets.ExistingPolicyInclustions = policyinclusions; Pets.NewSections = cmn.NewSectionP(policyinclusions); if (Session["unId"] != null && Session["profileId"] != null) { unid = Convert.ToInt32(Session["unId"]); profileid = Convert.ToInt32(Session["profileId"]); } else { if (policyinclusions.Exists(p => p.Name == "Pets")) { unid = policyinclusions.Where(p => p.Name == "Pets").Select(p => p.UnId).FirstOrDefault(); profileid = policyinclusions.Where(p => p.Name == "Pets").Select(p => p.UnId).FirstOrDefault(); } else { return(RedirectToAction("TravelCover", "Travel", new { cid = cid, PcId = PcId })); } } //int sectionId = policyinclusions.Where(p => p.Name == "Home Contents" && p.UnitNumber == unid).Select(p => p.UnId).FirstOrDefault(); //int? profileunid = policyinclusions.Where(p => p.Name == "Home Contents" && p.ProfileUnId == profileid).Select(p => p.ProfileUnId).FirstOrDefault(); HttpResponseMessage getunit = await hclient.GetAsync("UnitDetails?ApiKey=" + apikey + "&Action=Existing&SectionName=&SectionUnId=" + unid + "&ProfileUnId=" + profileid); var EmpResponse = getunit.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); } } else { if (PcId == null && Session["unId"] == null && (Session["profileId"] == null || profileid == 0)) { HttpResponseMessage Res = await hclient.GetAsync("UnitDetails?ApiKey=" + apikey + "&Action=New&SectionName=Pets&SectionUnId=&ProfileUnId=0"); var EmpResponse = Res.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); if (unitdetails.ErrorMessage != null && unitdetails.ErrorMessage.Count() > 0) { bool exists = Pets.PolicyInclusions.Exists(p => p.name == "Pet"); if (exists == true) { List <SessionModel> values = new List <SessionModel>(); values = (List <SessionModel>)Session["Policyinclustions"]; for (int k = 0; k < values.Count(); k++) { if (values[k].name == "Pet" && values[k].UnitId == null && values[k].ProfileId == null) { values.RemoveAt(k); } } Session["Policyinclustions"] = values; } var errormessage = "First please provide cover for Home Buildings."; if (unitdetails.ErrorMessage.Contains(errormessage)) { TempData["Error"] = errormessage; return(RedirectToAction("HomeDescription", "RuralLifeStyle", new { cid = cid, PcId = PcId })); } } if (unitdetails != null && unitdetails.SectionData != null) { Session["unId"] = unitdetails.SectionData.UnId; Session["profileId"] = unitdetails.SectionData.ProfileUnId; if (Policyincllist != null && Policyincllist.Exists(p => p.name == "Pet")) { var policyhomelist = Policyincllist.FindAll(p => p.name == "Pet").ToList(); if (policyhomelist != null && policyhomelist.Count() > 0) { if (Policyincllist.FindAll(p => p.name == "Pet").Exists(p => p.UnitId == null)) { Policyincllist.FindAll(p => p.name == "Pet").Where(p => p.UnitId == null).First().UnitId = unitdetails.SectionData.UnId; } if (Policyincllist.FindAll(p => p.name == "Pet").Exists(p => p.ProfileId == null)) { Policyincllist.FindAll(p => p.name == "Pet").Where(p => p.ProfileId == null).First().ProfileId = unitdetails.SectionData.ProfileUnId; } } else { Policyincllist.FindAll(p => p.name == "Pet").First().UnitId = unitdetails.SectionData.UnId; Policyincllist.FindAll(p => p.name == "Pet").First().ProfileId = unitdetails.SectionData.ProfileUnId; } Pets.PolicyInclusions = Policyincllist; Session["Policyinclustions"] = Policyincllist; } } } } else if (PcId == null && Session["unId"] != null && Session["profileId"] != null) { HttpResponseMessage getunit = await hclient.GetAsync("UnitDetails?ApiKey=" + apikey + "&Action=Existing&SectionName=&SectionUnId=" + unid + "&ProfileUnId=" + profileid); var EmpResponse = getunit.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); } } } if (unitdetails != null) { if (unitdetails.SectionData != null && unitdetails.SectionData.ValueData != null) { if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == Pets.AnnualcoverlimitObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == Pets.AnnualcoverlimitObj.EiId).Select(p => p.Value).FirstOrDefault(); Pets.AnnualcoverlimitObj.Annualcoverlimit = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == Pets.AnnuallimitbfObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == Pets.AnnuallimitbfObj.EiId).Select(p => p.Value).FirstOrDefault(); Pets.AnnuallimitbfObj.Annuallimitbf = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == Pets.AnnuallimitdtObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == Pets.AnnuallimitdtObj.EiId).Select(p => p.Value).FirstOrDefault(); Pets.AnnuallimitdtObj.Annuallimit = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == Pets.AnnuallimitijObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == Pets.AnnuallimitijObj.EiId).Select(p => p.Value).FirstOrDefault(); Pets.AnnuallimitijObj.Annuallimitij = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == Pets.BoardingfeeObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == Pets.BoardingfeeObj.EiId).Select(p => p.Value).FirstOrDefault(); Pets.BoardingfeeObj.Boardingfee = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == Pets.BreedObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == Pets.BreedObj.EiId).Select(p => p.Value).FirstOrDefault(); Pets.BreedObj.Breed = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == Pets.DatebirthObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == Pets.DatebirthObj.EiId).Select(p => p.Value).FirstOrDefault(); Pets.DatebirthObj.Datebirth = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == Pets.DeathillnessObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == Pets.DeathillnessObj.EiId).Select(p => p.Value).FirstOrDefault(); Pets.DeathillnessObj.Deathillness = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == Pets.DeathinjuryObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == Pets.DeathinjuryObj.EiId).Select(p => p.Value).FirstOrDefault(); Pets.DeathinjuryObj.Deathinjury = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == Pets.DescriptionillnessObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == Pets.DescriptionillnessObj.EiId).Select(p => p.Value).FirstOrDefault(); Pets.DescriptionillnessObj.Descriptionillness = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == Pets.ExcessPetObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == Pets.ExcessPetObj.EiId).Select(p => p.Value).FirstOrDefault(); Pets.ExcessPetObj.Excess = val; } //if (unitdetails.ProfileData.ValueData.Exists(p => p.Element.ElId == Pets.ImposedpetsObj.EiId)) //{ // string val = unitdetails.ProfileData.ValueData.Where(p => p.Element.ElId == Pets.ImposedpetsObj.EiId).Select(p => p.Value).FirstOrDefault(); // Pets.ImposedpetsObj.Imposed = val; //} if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == Pets.NameObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == Pets.NameObj.EiId).Select(p => p.Value).FirstOrDefault(); Pets.NameObj.Name = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == Pets.OtherbreedObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == Pets.OtherbreedObj.EiId).Select(p => p.Value).FirstOrDefault(); Pets.OtherbreedObj.Otherbreed = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == Pets.PreexistingObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == Pets.PreexistingObj.EiId).Select(p => p.Value).FirstOrDefault(); Pets.PreexistingObj.Preexisting = val; } //if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == Pets.PremiumptsObj.EiId)) //{ // string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == Pets.PremiumptsObj.EiId).Select(p => p.Value).FirstOrDefault(); // Pets.PremiumptsObj.Premium = val; //} if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == Pets.SpeciesObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == Pets.SpeciesObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val == "2") { petsBreedslist = petsmodel.breedListCat(); Pets.BreedObj.BreedList = petsBreedslist; } else { petsBreedslist = petsmodel.breedListDog(); Pets.BreedObj.BreedList = petsBreedslist; } Pets.SpeciesObj.Species = val; } } } if (unitdetails != null && unitdetails.ReferralList != null) { Pets.ReferralList = unitdetails.ReferralList; Pets.ReferralList.Replace("  ", ""); Pets.Referels = new List <string>(); string[] delim = { "<br/>" }; string[] spltd = Pets.ReferralList.Split(delim, StringSplitOptions.None); if (spltd != null && spltd.Count() > 0) { for (int i = 0; i < spltd.Count(); i++) { Pets.Referels.Add(spltd[i].Replace("  ", " ")); } } } if (cid != null && cid > 0) { Pets.CustomerId = cid.Value; } if (PcId != null && PcId > 0) { Pets.PcId = PcId; } Session["Controller"] = "Pets"; Session["ActionName"] = "PetsCover"; return(View(Pets)); }
public async System.Threading.Tasks.Task <ActionResult> Livestock(int?cid, int?PcId) { NewPolicyDetailsClass commonModel = new NewPolicyDetailsClass(); List <SelectListItem> ClassofAnimalLivestock = new List <SelectListItem>(); ClassofAnimalLivestock = commonModel.ClassofAnimalLivestock(); List <SelectListItem> TypeofAnimalLivestock = new List <SelectListItem>(); TypeofAnimalLivestock = commonModel.TypeofAnimalLivestock(); List <SelectListItem> AgeofAnimalLivestock = new List <SelectListItem>(); AgeofAnimalLivestock = commonModel.AgeofAnimalLivestock(); List <SelectListItem> UseofAnimalLivestock = new List <SelectListItem>(); UseofAnimalLivestock = commonModel.UseofAnimalLivestock(); List <SelectListItem> excessToPayLivestock = new List <SelectListItem>(); excessToPayLivestock = commonModel.excessRate(); FPLivestock FPLivestock = new FPLivestock(); var db = new MasterDataEntities(); if (cid != null) { ViewBag.cid = cid; FPLivestock.CustomerId = cid.Value; } else { ViewBag.cid = FPLivestock.CustomerId; } ViewEditPolicyDetails unitdetails = new ViewEditPolicyDetails(); NewPolicyDetailsClass commonmethods = new NewPolicyDetailsClass(); string apikey = null; if (Session["apiKey"] != null) { apikey = Session["apiKey"].ToString(); FPLivestock.ApiKey = Session["apiKey"].ToString(); } else { return(RedirectToAction("AgentLogin", "Login")); } string policyid = null; var Policyincllist = Session["Policyinclustions"] as List <SessionModel>; if (PcId != null && PcId.HasValue && PcId > 0) { policyid = PcId.ToString(); FPLivestock.PolicyId = policyid; } else if (Session["Policyinclustions"] != null) { #region Policy Selected or not testing List <SessionModel> PolicyInclustions = new List <SessionModel>(); FPLivestock.PolicyInclusions = new List <SessionModel>(); FPLivestock.PolicyInclusions = Policyincllist; if (Policyincllist != null) { if (Policyincllist != null) { if (Policyincllist.Exists(p => p.name == "Livestock")) { } else if (Policyincllist.Exists(p => p.name == "Home Buildings")) { return(RedirectToAction("MainDetails", "FarmPolicyHome", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Home Contents")) { return(RedirectToAction("HomeContents", "FarmPolicyHomeContent", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Personal Liability")) { return(RedirectToAction("PersonalLiability", "FarmPolicyPersonalLiability", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Valuables")) { return(RedirectToAction("Valuables", "FarmPolicyValuables", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Motor")) { return(RedirectToAction("VehicleDescription", "FarmMotors", new { cid = cid, PcId = PcId })); } if (Policyincllist.Exists(p => p.name == "Livestock")) { if (Session["unId"] == null && Session["profileId"] == null) { Session["unId"] = Policyincllist.Where(p => p.name == "Livestock").Select(p => p.UnitId).First(); Session["profileId"] = Policyincllist.Where(p => p.name == "Livestock").Select(p => p.ProfileId).First(); } } else { return(RedirectToAction("DisclosureDetails", "Disclosure", new { cid = cid, PcId = PcId })); } } } #endregion } FPLivestock.ClassOfAnimalFPObj = new ClassOfAnimalFP(); FPLivestock.ClassOfAnimalFPObj.ClassOfAnimalList = ClassofAnimalLivestock; FPLivestock.ClassOfAnimalFPObj.EiId = 63321; FPLivestock.TypeOfAnimalFPObj = new TypeOfAnimalFP(); FPLivestock.TypeOfAnimalFPObj.TypeOfAnimalList = TypeofAnimalLivestock; FPLivestock.TypeOfAnimalFPObj.EiId = 63323; FPLivestock.BreedOfAnimalFPObj = new BreedOfAnimalFP(); FPLivestock.BreedOfAnimalFPObj.EiId = 63325; FPLivestock.AgeOfAnimalFPObj = new AgeOfAnimalFP(); FPLivestock.AgeOfAnimalFPObj.AgeOfAnimalList = AgeofAnimalLivestock; FPLivestock.AgeOfAnimalFPObj.EiId = 63327; FPLivestock.ColourOfAnimalFPObj = new ColourOfAnimalFP(); FPLivestock.ColourOfAnimalFPObj.EiId = 63329; FPLivestock.UseOfAnimalFPObj = new UseOfAnimalFP(); FPLivestock.UseOfAnimalFPObj.UseOfAnimalList = UseofAnimalLivestock; FPLivestock.UseOfAnimalFPObj.EiId = 63331; FPLivestock.DescBrandOfAnimalFPObj = new DescBrandOfAnimalFP(); FPLivestock.DescBrandOfAnimalFPObj.EiId = 63333; FPLivestock.DescMarksOfAnimalFPObj = new DescMarksOfAnimalFP(); FPLivestock.DescMarksOfAnimalFPObj.EiId = 63335; FPLivestock.OptSoundHealthofAnimalFPObj = new OptSoundHealthofAnimalFP(); FPLivestock.OptSoundHealthofAnimalFPObj.EiId = 63345; FPLivestock.DescSoundHealthofAnimalFPObj = new DescSoundHealthofAnimalFP(); FPLivestock.DescSoundHealthofAnimalFPObj.EiId = 63347; FPLivestock.OptDiseaseOfAnimalFPObj = new OptDiseaseOfAnimalFP(); FPLivestock.OptDiseaseOfAnimalFPObj.EiId = 63349; FPLivestock.DescDiseaseOfAnimalFPObj = new DescDiseaseOfAnimalFP(); FPLivestock.DescDiseaseOfAnimalFPObj.EiId = 63351; FPLivestock.OptAnimalSyndicatedFPObj = new OptAnimalSyndicatedFP(); FPLivestock.OptAnimalSyndicatedFPObj.EiId = 63353; FPLivestock.DescAnimalSyndicatedFPObj = new DescAnimalSyndicatedFP(); FPLivestock.DescAnimalSyndicatedFPObj.EiId = 11111; FPLivestock.SumInsuredLivestockFPObj = new SumInsuredLivestockFP(); FPLivestock.SumInsuredLivestockFPObj.EiId = 63355; FPLivestock.OptInfertilityFPObj = new OptInfertilityFP(); FPLivestock.OptInfertilityFPObj.EiId = 63359; FPLivestock.OptLossofUseLivestockFPObj = new OptLossofUseLivestockFP(); FPLivestock.OptLossofUseLivestockFPObj.EiId = 63361; FPLivestock.OptTheftLivestockFPObj = new OptTheftLivestockFP(); FPLivestock.OptTheftLivestockFPObj.EiId = 63363; FPLivestock.OptUnbornFoalFPObj = new OptUnbornFoalFP(); FPLivestock.OptUnbornFoalFPObj.EiId = 63365; FPLivestock.ExcessLivestockFPObj = new ExcessLivestockFP(); FPLivestock.ExcessLivestockFPObj.ExcessList = excessToPayLivestock; FPLivestock.ExcessLivestockFPObj.EiId = 63375; FPLivestock.NoOfContainersFPObj = new NoOfContainersFP(); FPLivestock.NoOfContainersFPObj.EiId = 63383; FPLivestock.MaxStrawsandAmpoulesFPObj = new MaxStrawsandAmpoulesFP(); FPLivestock.MaxStrawsandAmpoulesFPObj.EiId = 63385; FPLivestock.MaxValOneContainerFPObj = new MaxValOneContainerFP(); FPLivestock.MaxValOneContainerFPObj.EiId = 63387; FPLivestock.AnnualStrawsandAmpoulesFPObj = new AnnualStrawsandAmpoulesFP(); FPLivestock.AnnualStrawsandAmpoulesFPObj.EiId = 63389; FPLivestock.ExcessLivestockFPBObj = new ExcessLivestockFP(); FPLivestock.ExcessLivestockFPBObj.EiId = 63393; FPLivestock.CoverforsemenLSObj = new CoverforsemenLS(); FPLivestock.CoverforsemenLSObj.EiId = 63391; HttpClient hclient = new HttpClient(); string url = System.Configuration.ConfigurationManager.AppSettings["APIURL"]; hclient.BaseAddress = new Uri(url); hclient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); int unid = Convert.ToInt32(Session["unId"]); int?profileid = Convert.ToInt32(Session["profileId"]); if (PcId != null && PcId.HasValue) { var policyinclusions = db.usp_GetUnit(null, PcId, null).ToList(); FPLivestock.PolicyInclusion = new List <usp_GetUnit_Result>(); if (PcId != null && PcId.HasValue && PcId > 0) { FPLivestock.PolicyInclusion = policyinclusions; } FPLivestock.PolicyInclusions = new List <SessionModel>(); if (PcId != null && PcId > 0) { FPLivestock.PolicyId = PcId.ToString(); } bool policyinclusion = policyinclusions.Exists(p => p.Name == "Livestock"); if (policyinclusion == true && PcId != null && PcId.HasValue) { unid = policyinclusions.Where(p => p.Name == "Livestock").Select(p => p.UnId).FirstOrDefault(); profileid = policyinclusions.Where(p => p.Name == "Livestock").Select(p => p.ProfileUnId).FirstOrDefault(); HttpResponseMessage getunit = await hclient.GetAsync("UnitDetails?ApiKey=" + apikey + "&Action=Existing&SectionName=&SectionUnId=" + unid + "&ProfileUnId=" + profileid); var EmpResponse = getunit.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); } } else { return(RedirectToAction("MainDetails", "FarmPolicyHome", new { cid = cid, PcId = PcId })); } } else { if (PcId == null && Session["unId"] == null && Session["profileId"] == null) { HttpResponseMessage Res = await hclient.GetAsync("UnitDetails?ApiKey=" + apikey + "&Action=New&SectionName=Livestock&SectionUnId=&ProfileUnId=0"); var EmpResponse = Res.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); if (unitdetails != null && unitdetails.SectionData != null) { Session["unId"] = unitdetails.SectionData.UnId; Session["profileId"] = unitdetails.SectionData.ProfileUnId; } } } else if (PcId == null && Session["unId"] != null && Session["profileId"] != null) { HttpResponseMessage getunit = await hclient.GetAsync("UnitDetails?ApiKey=" + apikey + "&Action=Existing&SectionName=&SectionUnId=" + unid + "&ProfileUnId=" + profileid); var EmpResponse = getunit.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); if (unitdetails != null && unitdetails.SectionData != null) { Session["unId"] = unitdetails.SectionData.UnId; Session["profileId"] = unitdetails.SectionData.ProfileUnId; } } } } if (unitdetails != null) { if (unitdetails.SectionData != null && unitdetails.SectionData.ValueData != null) { if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPLivestock.ClassOfAnimalFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPLivestock.ClassOfAnimalFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPLivestock.ClassOfAnimalFPObj.ClassofAnimal = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPLivestock.TypeOfAnimalFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPLivestock.TypeOfAnimalFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPLivestock.TypeOfAnimalFPObj.TypeofAnimal = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPLivestock.BreedOfAnimalFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPLivestock.BreedOfAnimalFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPLivestock.BreedOfAnimalFPObj.BreedofAnimal = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPLivestock.AgeOfAnimalFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPLivestock.AgeOfAnimalFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPLivestock.AgeOfAnimalFPObj.AgeofAnimal = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPLivestock.ColourOfAnimalFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPLivestock.ColourOfAnimalFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPLivestock.ColourOfAnimalFPObj.ColourofAnimal = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPLivestock.UseOfAnimalFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPLivestock.UseOfAnimalFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPLivestock.UseOfAnimalFPObj.UseofAnimal = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPLivestock.DescBrandOfAnimalFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPLivestock.DescBrandOfAnimalFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPLivestock.DescBrandOfAnimalFPObj.BrandofAnimal = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPLivestock.DescMarksOfAnimalFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPLivestock.DescMarksOfAnimalFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPLivestock.DescMarksOfAnimalFPObj.MarkingsofAnimal = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPLivestock.OptSoundHealthofAnimalFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPLivestock.OptSoundHealthofAnimalFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPLivestock.OptSoundHealthofAnimalFPObj.HealthofAnimal = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPLivestock.DescSoundHealthofAnimalFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPLivestock.DescSoundHealthofAnimalFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPLivestock.DescSoundHealthofAnimalFPObj.Description = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPLivestock.OptDiseaseOfAnimalFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPLivestock.OptDiseaseOfAnimalFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPLivestock.OptDiseaseOfAnimalFPObj.DiseaseofAnimal = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPLivestock.DescDiseaseOfAnimalFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPLivestock.DescDiseaseOfAnimalFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPLivestock.DescDiseaseOfAnimalFPObj.Description = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPLivestock.OptAnimalSyndicatedFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPLivestock.OptAnimalSyndicatedFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPLivestock.OptAnimalSyndicatedFPObj.AnimalSyndicated = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPLivestock.DescAnimalSyndicatedFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPLivestock.DescAnimalSyndicatedFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPLivestock.DescAnimalSyndicatedFPObj.Description = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPLivestock.SumInsuredLivestockFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPLivestock.SumInsuredLivestockFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPLivestock.SumInsuredLivestockFPObj.SumInsured = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPLivestock.OptInfertilityFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPLivestock.OptInfertilityFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPLivestock.OptInfertilityFPObj.Infertility = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPLivestock.OptLossofUseLivestockFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPLivestock.OptLossofUseLivestockFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPLivestock.OptLossofUseLivestockFPObj.LossofUse = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPLivestock.OptTheftLivestockFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPLivestock.OptTheftLivestockFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPLivestock.OptTheftLivestockFPObj.TheftOption = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPLivestock.OptUnbornFoalFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPLivestock.OptUnbornFoalFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPLivestock.OptUnbornFoalFPObj.UnbornFoal = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPLivestock.ExcessLivestockFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPLivestock.ExcessLivestockFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPLivestock.ExcessLivestockFPObj.Excess = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPLivestock.NoOfContainersFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPLivestock.NoOfContainersFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPLivestock.NoOfContainersFPObj.NumberOfContainers = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPLivestock.MaxStrawsandAmpoulesFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPLivestock.MaxStrawsandAmpoulesFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPLivestock.MaxStrawsandAmpoulesFPObj.StrawAndAmpoules = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPLivestock.MaxValOneContainerFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPLivestock.MaxValOneContainerFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPLivestock.MaxValOneContainerFPObj.MaxValoneContainer = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPLivestock.AnnualStrawsandAmpoulesFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPLivestock.AnnualStrawsandAmpoulesFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPLivestock.AnnualStrawsandAmpoulesFPObj.AnnualStrawandAmpoules = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPLivestock.CoverforsemenLSObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPLivestock.CoverforsemenLSObj.EiId).Select(p => p.Value).FirstOrDefault(); FPLivestock.CoverforsemenLSObj.Coverforsemen = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPLivestock.ExcessLivestockFPBObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPLivestock.ExcessLivestockFPBObj.EiId).Select(p => p.Value).FirstOrDefault(); FPLivestock.ExcessLivestockFPBObj.Excess = val; } } } if (cid != null && cid.HasValue) { FPLivestock.CustomerId = cid.Value; } if (PcId != null && PcId.HasValue) { FPLivestock.PcId = PcId; } Session["Controller"] = "FarmPolicyLivestock"; Session["ActionName"] = "Livestock"; return(View(FPLivestock)); }
public async System.Threading.Tasks.Task <ActionResult> FarmContents(int?cid, int?PcId) { string ApiKey = null; if (Session["ApiKey"] != null) { ApiKey = Session["ApiKey"].ToString(); } else { return(RedirectToAction("AgentLogin", "Login")); } var Policyincllist = new List <SessionModel>(); if (Session["Policyinclustions"] != null) { Policyincllist = Session["Policyinclustions"] as List <SessionModel>; if (Policyincllist != null) { if (Policyincllist != null) { if (Policyincllist.Exists(p => p.name == "Mobile Farm Property")) { } else if (Policyincllist.Exists(p => p.name == "Burglary")) { return(RedirectToAction("Burglary", "FarmPolicyBurglary", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Farm Interuption")) { return(RedirectToAction("FarmInterruption", "FarmPolicyFarmInterruption", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Money")) { return(RedirectToAction("Money", "FarmPolicyMoney", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Farm Liability")) { return(RedirectToAction("FarmLiability", "FarmPolicyFarmLiability", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Machinery")) { return(RedirectToAction("Machinery", "FarmPolicyMachinery", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Electronics")) { return(RedirectToAction("Electronics", "FarmPolicyElectronics", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Transit")) { return(RedirectToAction("Transit", "FarmPolicyTransit", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Livestock")) { return(RedirectToAction("Livestock", "FarmPolicyLivestock", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Home Buildings")) { return(RedirectToAction("MainDetails", "FarmPolicyHome", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Home Contents")) { return(RedirectToAction("HomeContents", "FarmPolicyHomeContent", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Personal Liability")) { return(RedirectToAction("PersonalLiability", "FarmPolicyPersonalLiability", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Valuables")) { return(RedirectToAction("Valuables", "FarmPolicyValuables", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Motor")) { return(RedirectToAction("VehicleDescription", "FarmMotors", new { cid = cid, PcId = PcId })); } if (Policyincllist.Exists(p => p.name == "Mobile Farm Property")) { if (Session["unId"] == null && Session["profileId"] == null) { Session["unId"] = Policyincllist.Where(p => p.name == "Mobile Farm Property").Select(p => p.UnitId).First(); Session["profileId"] = Policyincllist.Where(p => p.name == "Mobile Farm Property").Select(p => p.ProfileId).First(); } } else { return(RedirectToAction("DisclosureDetails", "Disclosure", new { cid = cid, PcId = PcId })); } } } } else { RedirectToAction("PolicyInclustions", "Customer", new { CustomerId = cid, type = 1021 }); } ViewEditPolicyDetails unitdetails = new ViewEditPolicyDetails(); NewPolicyDetailsClass commonModel = new NewPolicyDetailsClass(); List <SelectListItem> desList = new List <SelectListItem>(); desList = commonModel.descriptionLS(); List <SelectListItem> excessforUMPay = new List <SelectListItem>(); excessforUMPay = commonModel.excessRate(); MobileFarmContents MobileFarmContents = new MobileFarmContents(); #region Farm Contents details MobileFarmContents.FarmContentsSumInsuredFPObj = new FarmContentsSumInsuredFP(); MobileFarmContents.FarmContentsSumInsuredFPObj.EiId = 62403; MobileFarmContents.OptPortableItemsFarmContentFPObj = new OptPortableItemsFarmContentFP(); MobileFarmContents.OptPortableItemsFarmContentFPObj.EiId = 60405; MobileFarmContents.ExcessFarmContentFPObj = new ExcessFarmContentFP(); MobileFarmContents.ExcessFarmContentFPObj.ExcessList = excessforUMPay; MobileFarmContents.ExcessFarmContentFPObj.EiId = 62407; #endregion #region Farm Machinery MobileFarmContents.FPUnspecifiedMachineryFMObj = new FPUnspecifiedMachineryFM(); MobileFarmContents.FPUnspecifiedMachineryFMObj.EiId = 62423; MobileFarmContents.FPExcessforUMFMObj = new FPExcessforUMFM(); MobileFarmContents.FPExcessforUMFMObj.ExcessUMList = excessforUMPay; MobileFarmContents.FPExcessforUMFMObj.EiId = 62425; MobileFarmContents.FPDescriptionsFMObj = new FPDescriptionsFM(); MobileFarmContents.FPDescriptionsFMObj.EiId = 62431; MobileFarmContents.FPYearFMObj = new FPYearFM(); MobileFarmContents.FPYearFMObj.EiId = 62433; MobileFarmContents.FPSerialNumberFMObj = new FPSerialNumberFM(); MobileFarmContents.FPSerialNumberFMObj.EiId = 62435; MobileFarmContents.FPExcessFMObj = new FPExcessFM(); MobileFarmContents.FPExcessFMObj.ExcessList = excessforUMPay; MobileFarmContents.FPExcessFMObj.EiId = 62437; MobileFarmContents.FPSumOfInsuredFMObj = new FPSumOfInsuredFM(); MobileFarmContents.FPSumOfInsuredFMObj.EiId = 62439; #endregion #region Livestock MobileFarmContents.FPDescriptionLivestockObj = new FPDescriptionLivestock(); MobileFarmContents.FPDescriptionLivestockObj.DescriptionList = desList; MobileFarmContents.FPDescriptionLivestockObj.EiId = 62467; MobileFarmContents.FPNumberOfAnimalsLivestockObj = new FPNumberOfAnimalsLivestock(); MobileFarmContents.FPNumberOfAnimalsLivestockObj.EiId = 62469; MobileFarmContents.FPSumInsuredPerAnimalsLivestockObj = new FPSumInsuredPerAnimalsLivestock(); MobileFarmContents.FPSumInsuredPerAnimalsLivestockObj.EiId = 62471; MobileFarmContents.FPTotalSumOfInsuredLivestockObj = new FPTotalSumOfInsuredLivestock(); MobileFarmContents.FPTotalSumOfInsuredLivestockObj.EiId = 62473; MobileFarmContents.OptDogAttackLivestockObj = new OptDogAttackLivestock(); MobileFarmContents.OptDogAttackLivestockObj.EiId = 62475; MobileFarmContents.FPExcessLivestockObj = new FPExcessLivestock(); MobileFarmContents.FPExcessLivestockObj.ExcessList = excessforUMPay; MobileFarmContents.FPExcessLivestockObj.EiId = 62477; #endregion #region Working Dogs Beehives MobileFarmContents.FPSumOfInsuredPerDogObj = new FPSumOfInsuredPerDog(); MobileFarmContents.FPSumOfInsuredPerDogObj.EiId = 62491; MobileFarmContents.FPNoOfWorkingDogsObj = new FPNoOfWorkingDogs(); MobileFarmContents.FPNoOfWorkingDogsObj.EiId = 62493; MobileFarmContents.FPTotalSumInsuredWDBObj = new FPTotalSumInsuredWDB(); MobileFarmContents.FPTotalSumInsuredWDBObj.EiId = 62495; MobileFarmContents.FPExcessWorkingDogsObj = new FPExcessWorkingDogs(); MobileFarmContents.FPExcessWorkingDogsObj.ExcessList = excessforUMPay; MobileFarmContents.FPExcessWorkingDogsObj.EiId = 62497; MobileFarmContents.FPBeehivesSumInsuredObj = new FPBeehivesSumInsured(); MobileFarmContents.FPBeehivesSumInsuredObj.EiId = 62503; MobileFarmContents.FPNumberOfHivesObj = new FPNumberOfHives(); MobileFarmContents.FPNumberOfHivesObj.EiId = 62505; MobileFarmContents.FPExcessBeehivesObj = new FPExcessBeehives(); MobileFarmContents.FPExcessBeehivesObj.ExcessList = excessforUMPay; MobileFarmContents.FPExcessBeehivesObj.EiId = 62507; #endregion if (cid != null) { ViewBag.cid = cid; MobileFarmContents.CustomerId = cid.Value; } else { ViewBag.cid = MobileFarmContents.CustomerId; } var db = new MasterDataEntities(); string policyid = null; HttpClient hclient = new HttpClient(); string url = System.Configuration.ConfigurationManager.AppSettings["APIURL"]; hclient.BaseAddress = new Uri(url); hclient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); int unid = 0; int?profileid = 0; int Fprofileid = 0; if (Session["unId"] != null && Session["ProfileId"] != null) { unid = Convert.ToInt32(Session["unId"]); profileid = Convert.ToInt32(Session["profileId"]); } if (Session["FProfileId"] != null) { Fprofileid = Convert.ToInt32(Session["FprofileId"]); } if (Session["Policyinclustions"] != null) { MobileFarmContents.PolicyInclusions = Policyincllist; } if (PcId != null && PcId.HasValue && PcId > 0) { var policyinclusions = db.usp_GetUnit(null, PcId, null).ToList(); MobileFarmContents.PolicyInclusion = new List <usp_GetUnit_Result>(); if (PcId != null && PcId.HasValue && PcId > 0) { MobileFarmContents.PolicyInclusion = policyinclusions; } MobileFarmContents.PolicyInclusions = new List <SessionModel>(); if (PcId != null && PcId > 0) { policyid = PcId.ToString(); MobileFarmContents.PolicyId = policyid; } bool policyinclusion = policyinclusions.Exists(p => p.Name == "Mobile Farm Property"); if (policyinclusion == true && PcId != null && PcId.HasValue) { unid = policyinclusions.Where(p => p.Name == "Mobile Farm Property").Select(p => p.UnId).FirstOrDefault(); profileid = policyinclusions.Where(p => p.Name == "Mobile Farm Property").Select(p => p.ProfileUnId).FirstOrDefault(); HttpResponseMessage getunit = await hclient.GetAsync("UnitDetails?ApiKey=" + ApiKey + "&Action=Existing&SectionName=&SectionUnId=" + unid + "&ProfileUnId=" + profileid); var EmpResponse = getunit.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); } } else { return(RedirectToAction("Burglary", "FarmPolicyBurglary", new { cid = cid, PcId = PcId })); } } else { if (PcId == null && Session["unId"] == null && Session["profileId"] == null) { HttpResponseMessage Res = await hclient.GetAsync("UnitDetails?ApiKey=" + ApiKey + "&Action=New&SectionName=Mobile Farm Property&SectionUnId=&ProfileUnId="); var EmpResponse = Res.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); if (unitdetails != null && unitdetails.SectionData != null) { if (unitdetails != null && unitdetails.ErrorMessage != null && unitdetails.ErrorMessage.Count() > 0 && unitdetails.Status == "Failure") { bool exists = MobileFarmContents.PolicyInclusions.Exists(p => p.name == "Mobile Farm Property"); if (exists == true) { List <SessionModel> values = new List <SessionModel>(); values = (List <SessionModel>)Session["Policyinclustions"]; for (int k = 0; k < values.Count(); k++) { if (values[k].name == "Mobile Farm Property" && values[k].UnitId == null && values[k].ProfileId == null) { values.RemoveAt(k); } } Session["Policyinclustions"] = values; } } Session["unId"] = unitdetails.SectionData.UnId; //Session["FprofileId"] = unitdetails.SectionData.ProfileUnId; Session["profileId"] = unitdetails.SectionData.ProfileUnId; if (Policyincllist != null && Policyincllist.Exists(p => p.name == "Mobile Farm Property")) { var policyhomelist = Policyincllist.FindAll(p => p.name == "Mobile Farm Property").ToList(); if (policyhomelist != null && policyhomelist.Count() > 0) { Policyincllist.FindAll(p => p.name == "Mobile Farm Property").Where(p => p.UnitId == null).First().UnitId = unitdetails.SectionData.UnId; Policyincllist.FindAll(p => p.name == "Mobile Farm Property").Where(p => p.ProfileId == null).First().ProfileId = unitdetails.SectionData.ProfileUnId; } else { Policyincllist.FindAll(p => p.name == "Mobile Farm Property").First().UnitId = unitdetails.SectionData.UnId; Policyincllist.FindAll(p => p.name == "Mobile Farm Property").First().ProfileId = unitdetails.SectionData.ProfileUnId; } } } } } else { if (PcId == null && Session["unId"] != null && (Session["profileId"] != null || (Fprofileid != null && Fprofileid < 0))) { if (profileid == null || profileid == 0) { profileid = Fprofileid; } HttpResponseMessage getunit = await hclient.GetAsync("UnitDetails?ApiKey=" + ApiKey + "&Action=Existing&SectionName=&SectionUnId=" + unid + "&ProfileUnId=" + profileid); var EmpResponse = getunit.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); if (unitdetails != null && unitdetails.SectionData != null) { Session["unId"] = unitdetails.SectionData.UnId; Session["FprofileId"] = unitdetails.SectionData.ProfileUnId; } } } } } if (unitdetails != null) { if (unitdetails.SectionData != null && unitdetails.SectionData.AddressData != null) { MobileFarmContents.AddressObj = new AddressForFP(); MobileFarmContents.LocationObj = new LocatioForFP(); MobileFarmContents.AddressObj.Address = unitdetails.SectionData.AddressData.AddressLine1; MobileFarmContents.LocationObj.Location = unitdetails.SectionData.AddressData.State + ", " + unitdetails.SectionData.AddressData.Suburb + ", " + unitdetails.SectionData.AddressData.Postcode; } if (unitdetails.SectionData != null && unitdetails.SectionData.ValueData != null) { if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == MobileFarmContents.FarmContentsSumInsuredFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == MobileFarmContents.FarmContentsSumInsuredFPObj.EiId).Select(p => p.Value).FirstOrDefault(); MobileFarmContents.FarmContentsSumInsuredFPObj.SumInsuredFC = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == MobileFarmContents.OptPortableItemsFarmContentFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == MobileFarmContents.OptPortableItemsFarmContentFPObj.EiId).Select(p => p.Value).FirstOrDefault(); MobileFarmContents.OptPortableItemsFarmContentFPObj.OptPortalableItems = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == MobileFarmContents.ExcessFarmContentFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == MobileFarmContents.ExcessFarmContentFPObj.EiId).Select(p => p.Value).FirstOrDefault(); MobileFarmContents.ExcessFarmContentFPObj.Excess = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == MobileFarmContents.FPUnspecifiedMachineryFMObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == MobileFarmContents.FPUnspecifiedMachineryFMObj.EiId).Select(p => p.Value).FirstOrDefault(); MobileFarmContents.FPUnspecifiedMachineryFMObj.UnspecifiedMachinery = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == MobileFarmContents.FPExcessforUMFMObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == MobileFarmContents.FPExcessforUMFMObj.EiId).Select(p => p.Value).FirstOrDefault(); MobileFarmContents.FPExcessforUMFMObj.Excess = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == MobileFarmContents.FPDescriptionsFMObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == MobileFarmContents.FPDescriptionsFMObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && !string.IsNullOrEmpty(val)) { MobileFarmContents.FPDescriptionsFMObj.DescriptionFM = val; } if (unitdetails.SectionData.ValueData.Select(p => p.Element.ElId == MobileFarmContents.FPDescriptionsFMObj.EiId).Count() > 1) { List <ValueDatas> elmnts = new List <ValueDatas>(); var FPDescriptionsList = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == MobileFarmContents.FPDescriptionsFMObj.EiId).Select(p => p.Element.ItId).ToList(); for (int i = 0; i < FPDescriptionsList.Count(); i++) { ValueDatas vds = new ValueDatas(); vds.Element = new Elements(); vds.Element.ElId = 62431; vds.Element.ItId = FPDescriptionsList[i]; vds.Value = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == MobileFarmContents.FPDescriptionsFMObj.EiId && p.Element.ItId == FPDescriptionsList[i]).Select(p => p.Value).FirstOrDefault(); elmnts.Add(vds); } MobileFarmContents.FPDescriptionsFMList = elmnts; } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == MobileFarmContents.FPYearFMObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == MobileFarmContents.FPYearFMObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && !string.IsNullOrEmpty(val)) { MobileFarmContents.FPYearFMObj.YearFM = val; } if (unitdetails.SectionData.ValueData.Select(p => p.Element.ElId == MobileFarmContents.FPYearFMObj.EiId).Count() > 1) { List <ValueDatas> elmnts = new List <ValueDatas>(); var FPYearList = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == MobileFarmContents.FPYearFMObj.EiId).Select(p => p.Element.ItId).ToList(); for (int i = 0; i < FPYearList.Count(); i++) { ValueDatas vds = new ValueDatas(); vds.Element = new Elements(); vds.Element.ElId = 62433; vds.Element.ItId = FPYearList[i]; vds.Value = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == MobileFarmContents.FPYearFMObj.EiId && p.Element.ItId == FPYearList[i]).Select(p => p.Value).FirstOrDefault(); elmnts.Add(vds); } MobileFarmContents.FPYearFMList = elmnts; } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == MobileFarmContents.FPSerialNumberFMObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == MobileFarmContents.FPSerialNumberFMObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && !string.IsNullOrEmpty(val)) { MobileFarmContents.FPSerialNumberFMObj.SerialNumberFM = val; } if (unitdetails.SectionData.ValueData.Select(p => p.Element.ElId == MobileFarmContents.FPSerialNumberFMObj.EiId).Count() > 1) { List <ValueDatas> elmnts = new List <ValueDatas>(); var FPSerialNumberList = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == MobileFarmContents.FPSerialNumberFMObj.EiId).Select(p => p.Element.ItId).ToList(); for (int i = 0; i < FPSerialNumberList.Count(); i++) { ValueDatas vds = new ValueDatas(); vds.Element = new Elements(); vds.Element.ElId = 62435; vds.Element.ItId = FPSerialNumberList[i]; vds.Value = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == MobileFarmContents.FPSerialNumberFMObj.EiId && p.Element.ItId == FPSerialNumberList[i]).Select(p => p.Value).FirstOrDefault(); elmnts.Add(vds); } MobileFarmContents.FPSerialNumberFMList = elmnts; } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == MobileFarmContents.FPExcessFMObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == MobileFarmContents.FPExcessFMObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && !string.IsNullOrEmpty(val)) { MobileFarmContents.FPExcessFMObj.Excess = val; } if (unitdetails.SectionData.ValueData.Select(p => p.Element.ElId == MobileFarmContents.FPExcessFMObj.EiId).Count() > 1) { List <ValueDatas> elmnts = new List <ValueDatas>(); var FPExcessList = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == MobileFarmContents.FPExcessFMObj.EiId).Select(p => p.Element.ItId).ToList(); for (int i = 0; i < FPExcessList.Count(); i++) { ValueDatas vds = new ValueDatas(); vds.Element = new Elements(); vds.Element.ElId = 62437; vds.Element.ItId = FPExcessList[i]; vds.Value = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == MobileFarmContents.FPExcessFMObj.EiId && p.Element.ItId == FPExcessList[i]).Select(p => p.Value).FirstOrDefault(); elmnts.Add(vds); } MobileFarmContents.FPExcessFMList = elmnts; } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == MobileFarmContents.FPSumOfInsuredFMObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == MobileFarmContents.FPSumOfInsuredFMObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && !string.IsNullOrEmpty(val)) { MobileFarmContents.FPSumOfInsuredFMObj.SuminsuredFM = val; } if (unitdetails.SectionData.ValueData.Select(p => p.Element.ElId == MobileFarmContents.FPSumOfInsuredFMObj.EiId).Count() > 1) { List <ValueDatas> elmnts = new List <ValueDatas>(); var FPSumOfInsuredList = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == MobileFarmContents.FPSumOfInsuredFMObj.EiId).Select(p => p.Element.ItId).ToList(); for (int i = 0; i < FPSumOfInsuredList.Count(); i++) { ValueDatas vds = new ValueDatas(); vds.Element = new Elements(); vds.Element.ElId = 62439; vds.Element.ItId = FPSumOfInsuredList[i]; vds.Value = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == MobileFarmContents.FPSumOfInsuredFMObj.EiId && p.Element.ItId == FPSumOfInsuredList[i]).Select(p => p.Value).FirstOrDefault(); elmnts.Add(vds); } MobileFarmContents.FPSumOfInsuredFMList = elmnts; } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == MobileFarmContents.FPDescriptionLivestockObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == MobileFarmContents.FPDescriptionLivestockObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && !string.IsNullOrEmpty(val)) { MobileFarmContents.FPDescriptionLivestockObj.Description = val; } if (unitdetails.SectionData.ValueData.Select(p => p.Element.ElId == MobileFarmContents.FPDescriptionLivestockObj.EiId).Count() > 1) { List <ValueDatas> elmnts = new List <ValueDatas>(); var FPDLivestockList = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == MobileFarmContents.FPDescriptionLivestockObj.EiId).Select(p => p.Element.ItId).ToList(); for (int i = 0; i < FPDLivestockList.Count(); i++) { ValueDatas vds = new ValueDatas(); vds.Element = new Elements(); vds.Element.ElId = 62467; vds.Element.ItId = FPDLivestockList[i]; vds.Value = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == MobileFarmContents.FPDescriptionLivestockObj.EiId && p.Element.ItId == FPDLivestockList[i]).Select(p => p.Value).FirstOrDefault(); elmnts.Add(vds); } MobileFarmContents.FPDescriptionLivestockList = elmnts; } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == MobileFarmContents.FPNumberOfAnimalsLivestockObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == MobileFarmContents.FPNumberOfAnimalsLivestockObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && !string.IsNullOrEmpty(val)) { MobileFarmContents.FPNumberOfAnimalsLivestockObj.NumberOfanimals = val; } if (unitdetails.SectionData.ValueData.Select(p => p.Element.ElId == MobileFarmContents.FPNumberOfAnimalsLivestockObj.EiId).Count() > 1) { List <ValueDatas> elmnts = new List <ValueDatas>(); var FPNMLivestockList = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == MobileFarmContents.FPNumberOfAnimalsLivestockObj.EiId).Select(p => p.Element.ItId).ToList(); for (int i = 0; i < FPNMLivestockList.Count(); i++) { ValueDatas vds = new ValueDatas(); vds.Element = new Elements(); vds.Element.ElId = 62469; vds.Element.ItId = FPNMLivestockList[i]; vds.Value = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == MobileFarmContents.FPNumberOfAnimalsLivestockObj.EiId && p.Element.ItId == FPNMLivestockList[i]).Select(p => p.Value).FirstOrDefault(); elmnts.Add(vds); } MobileFarmContents.FPNumberOfAnimalsLivestockList = elmnts; } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == MobileFarmContents.FPNumberOfAnimalsLivestockObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == MobileFarmContents.FPSumInsuredPerAnimalsLivestockObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && !string.IsNullOrEmpty(val)) { MobileFarmContents.FPSumInsuredPerAnimalsLivestockObj.SumInsuredPerAnimal = val; } if (unitdetails.SectionData.ValueData.Select(p => p.Element.ElId == MobileFarmContents.FPSumInsuredPerAnimalsLivestockObj.EiId).Count() > 1) { List <ValueDatas> elmnts = new List <ValueDatas>(); var FPSPALivestockList = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == MobileFarmContents.FPSumInsuredPerAnimalsLivestockObj.EiId).Select(p => p.Element.ItId).ToList(); for (int i = 0; i < FPSPALivestockList.Count(); i++) { ValueDatas vds = new ValueDatas(); vds.Element = new Elements(); vds.Element.ElId = 62471; vds.Element.ItId = FPSPALivestockList[i]; vds.Value = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == MobileFarmContents.FPSumInsuredPerAnimalsLivestockObj.EiId && p.Element.ItId == FPSPALivestockList[i]).Select(p => p.Value).FirstOrDefault(); elmnts.Add(vds); } MobileFarmContents.FPSumInsuredPerAnimalsLivestockList = elmnts; } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == MobileFarmContents.FPTotalSumOfInsuredLivestockObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == MobileFarmContents.FPTotalSumOfInsuredLivestockObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && !string.IsNullOrEmpty(val)) { MobileFarmContents.FPTotalSumOfInsuredLivestockObj.TotalSumOfInsured = val; } if (unitdetails.SectionData.ValueData.Select(p => p.Element.ElId == MobileFarmContents.FPTotalSumOfInsuredLivestockObj.EiId).Count() > 1) { List <ValueDatas> elmnts = new List <ValueDatas>(); var FPTSLivestockList = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == MobileFarmContents.FPTotalSumOfInsuredLivestockObj.EiId).Select(p => p.Element.ItId).ToList(); for (int i = 0; i < FPTSLivestockList.Count(); i++) { ValueDatas vds = new ValueDatas(); vds.Element = new Elements(); vds.Element.ElId = 62473; vds.Element.ItId = FPTSLivestockList[i]; vds.Value = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == MobileFarmContents.FPTotalSumOfInsuredLivestockObj.EiId && p.Element.ItId == FPTSLivestockList[i]).Select(p => p.Value).FirstOrDefault(); elmnts.Add(vds); } MobileFarmContents.FPTotalSumOfInsuredLivestockList = elmnts; } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == MobileFarmContents.OptDogAttackLivestockObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == MobileFarmContents.OptDogAttackLivestockObj.EiId).Select(p => p.Value).FirstOrDefault(); MobileFarmContents.OptDogAttackLivestockObj.OptDogAttack = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == MobileFarmContents.FPExcessLivestockObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == MobileFarmContents.FPExcessLivestockObj.EiId).Select(p => p.Value).FirstOrDefault(); MobileFarmContents.FPExcessLivestockObj.Excess = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == MobileFarmContents.FPSumOfInsuredPerDogObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == MobileFarmContents.FPSumOfInsuredPerDogObj.EiId).Select(p => p.Value).FirstOrDefault(); MobileFarmContents.FPSumOfInsuredPerDogObj.SumInsuredPerDog = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == MobileFarmContents.FPNoOfWorkingDogsObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == MobileFarmContents.FPNoOfWorkingDogsObj.EiId).Select(p => p.Value).FirstOrDefault(); MobileFarmContents.FPNoOfWorkingDogsObj.NoOfWorkingDogs = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == MobileFarmContents.FPTotalSumInsuredWDBObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == MobileFarmContents.FPTotalSumInsuredWDBObj.EiId).Select(p => p.Value).FirstOrDefault(); MobileFarmContents.FPTotalSumInsuredWDBObj.TotalSumInsured = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == MobileFarmContents.FPExcessWorkingDogsObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == MobileFarmContents.FPExcessWorkingDogsObj.EiId).Select(p => p.Value).FirstOrDefault(); MobileFarmContents.FPExcessWorkingDogsObj.Excess = val; } } } if (cid != null && cid.HasValue) { MobileFarmContents.CustomerId = cid.Value; } if (PcId != null && PcId.HasValue) { MobileFarmContents.PcId = PcId; } Session["Controller"] = "FarmPolicyMobileFarm"; Session["ActionName"] = "FarmContents"; return(View(MobileFarmContents)); }
public async System.Threading.Tasks.Task <ActionResult> Electronics(int?cid, int?PcId) { NewPolicyDetailsClass commonModel = new NewPolicyDetailsClass(); List <SelectListItem> ElectronicItemTypeofUnit = new List <SelectListItem>(); ElectronicItemTypeofUnit = commonModel.ElectronicTypeOfUnit(); List <SelectListItem> excessToPayElectronics = new List <SelectListItem>(); excessToPayElectronics = commonModel.excessRate(); FPElectronics FPElectronics = new FPElectronics(); var db = new MasterDataEntities(); if (cid != null) { ViewBag.cid = cid; FPElectronics.CustomerId = cid.Value; } else { ViewBag.cid = FPElectronics.CustomerId; } ViewEditPolicyDetails unitdetails = new ViewEditPolicyDetails(); NewPolicyDetailsClass commonmethods = new NewPolicyDetailsClass(); string apikey = null; string ApiKey = null; if (Session["ApiKey"] != null) { ApiKey = Session["ApiKey"].ToString(); } else { return(RedirectToAction("AgentLogin", "Login")); } var Policyincllist = new List <SessionModel>(); if (Session["Policyinclustions"] != null) { Policyincllist = Session["Policyinclustions"] as List <SessionModel>; if (Policyincllist != null) { if (Policyincllist != null) { if (Policyincllist.Exists(p => p.name == "Electronics")) { } else if (Policyincllist.Exists(p => p.name == "Transit")) { return(RedirectToAction("Transit", "FarmPolicyTransit", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Livestock")) { return(RedirectToAction("Livestock", "FarmPolicyLivestock", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Home Buildings")) { return(RedirectToAction("MainDetails", "FarmPolicyHome", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Home Contents")) { return(RedirectToAction("HomeContents", "FarmPolicyHomeContent", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Personal Liability")) { return(RedirectToAction("PersonalLiability", "FarmPolicyPersonalLiability", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Valuables")) { return(RedirectToAction("Valuables", "FarmPolicyValuables", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Motor")) { return(RedirectToAction("VehicleDescription", "FarmMotors", new { cid = cid, PcId = PcId })); } if (Policyincllist.Exists(p => p.name == "Electronics")) { if (Session["unId"] == null && Session["profileId"] == null) { Session["unId"] = Policyincllist.Where(p => p.name == "Electronics").Select(p => p.UnitId).First(); Session["profileId"] = Policyincllist.Where(p => p.name == "Electronics").Select(p => p.ProfileId).First(); } } else { return(RedirectToAction("DisclosureDetails", "Disclosure", new { cid = cid, PcId = PcId })); } } } } else { RedirectToAction("PolicyInclustions", "Customer", new { CustomerId = cid, type = 1021 }); } FPElectronics.TypeOfUnitFPObj = new TypeOfUnitFP(); FPElectronics.TypeOfUnitFPObj.ElectronicsTypeofUnitList = ElectronicItemTypeofUnit; FPElectronics.TypeOfUnitFPObj.EiId = 63161; FPElectronics.MakeAndModelFPObj = new MakeAndModelFP(); FPElectronics.MakeAndModelFPObj.EiId = 63163; FPElectronics.SerialNumberFPObj = new SerialNumberFP(); FPElectronics.SerialNumberFPObj.EiId = 63165; FPElectronics.NoOfUnitsFPObj = new NoOfUnitsFP(); FPElectronics.NoOfUnitsFPObj.EiId = 63167; FPElectronics.OptPortableItemsFPObj = new OptPortableItemsFP(); FPElectronics.OptPortableItemsFPObj.EiId = 63169; FPElectronics.SumInsuredPerUnitFPObj = new SumInsuredPerUnitFP(); FPElectronics.SumInsuredPerUnitFPObj.EiId = 63171; FPElectronics.TotalSumInsuredFPObj = new TotalSumInsuredFP(); FPElectronics.TotalSumInsuredFPObj.EiId = 63173; FPElectronics.ExcessElectronicsFPObj = new ExcessElectronicsFP(); FPElectronics.ExcessElectronicsFPObj.ExcessList = excessToPayElectronics; FPElectronics.ExcessElectronicsFPObj.EiId = 63177; FPElectronics.CoverLossOfDataFPObj = new CoverLossOfDataFP(); FPElectronics.CoverLossOfDataFPObj.EiId = 63189; FPElectronics.ExcessCoverLossOfDataFPObj = new ExcessCoverLossOfDataFP(); FPElectronics.ExcessCoverLossOfDataFPObj.ExcessList = excessToPayElectronics; FPElectronics.ExcessCoverLossOfDataFPObj.EiId = 63191; FPElectronics.AddressObj = new AddressEAddress(); FPElectronics.AddressObj.EiId = 0; HttpClient hclient = new HttpClient(); string url = System.Configuration.ConfigurationManager.AppSettings["APIURL"]; hclient.BaseAddress = new Uri(url); hclient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); int unid = 0; int profileid = 0; int Fprofileid = 0; if (Session["unId"] != null && Session["ProfileId"] != null) { unid = Convert.ToInt32(Session["unId"]); profileid = Convert.ToInt32(Session["profileId"]); } if (Session["FProfileId"] != null) { Fprofileid = Convert.ToInt32(Session["FprofileId"]); } if (Session["Policyinclustions"] != null) { FPElectronics.PolicyInclusions = Policyincllist; } if (PcId != null && PcId.HasValue) { var policyinclusions = db.usp_GetUnit(null, PcId, null).ToList(); FPElectronics.PolicyInclusion = new List <usp_GetUnit_Result>(); if (PcId != null && PcId.HasValue && PcId > 0) { FPElectronics.PolicyInclusion = policyinclusions; } FPElectronics.PolicyInclusions = new List <SessionModel>(); if (PcId != null && PcId > 0) { FPElectronics.PolicyId = PcId.ToString(); } bool policyinclusion = policyinclusions.Exists(p => p.Name == "Electronics"); if (policyinclusion == true && PcId != null && PcId.HasValue) { int sectionId = policyinclusions.Where(p => p.Name == "Electronics").Select(p => p.UnId).FirstOrDefault(); int?profileunid = policyinclusions.Where(p => p.Name == "Electronics").Select(p => p.ProfileUnId).FirstOrDefault(); HttpResponseMessage getunit = await hclient.GetAsync("UnitDetails?ApiKey=" + apikey + "&Action=Existing&SectionName=&SectionUnId=" + sectionId + "&ProfileUnId=" + profileunid); var EmpResponse = getunit.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); } } else { return(RedirectToAction("Transit", "FarmPolicyTransit", new { cid = cid, PcId = PcId })); } } else { if (PcId == null && Session["unId"] == null && Session["profileId"] == null) { HttpResponseMessage Res = await hclient.GetAsync("UnitDetails?ApiKey=" + ApiKey + "&Action=New&SectionName=Electronics&SectionUnId=&ProfileUnId=0"); var EmpResponse = Res.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); if (unitdetails != null && unitdetails.SectionData != null) { Session["unId"] = unitdetails.SectionData.UnId; Session["profileId"] = unitdetails.SectionData.ProfileUnId; } } } else if (PcId == null && Session["unId"] != null && Session["profileId"] != null) { HttpResponseMessage getunit = await hclient.GetAsync("UnitDetails?ApiKey=" + apikey + "&Action=Existing&SectionName=&SectionUnId=" + unid + "&ProfileUnId=" + profileid); var EmpResponse = getunit.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); if (unitdetails != null && unitdetails.SectionData != null) { Session["unId"] = unitdetails.SectionData.UnId; Session["profileId"] = unitdetails.SectionData.ProfileUnId; } } } } if (unitdetails != null) { if (unitdetails.SectionData != null && unitdetails.SectionData.ValueData != null) { if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPElectronics.TypeOfUnitFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPElectronics.TypeOfUnitFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPElectronics.TypeOfUnitFPObj.TypeofUnit = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPElectronics.MakeAndModelFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPElectronics.MakeAndModelFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPElectronics.MakeAndModelFPObj.MakeandModel = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPElectronics.SerialNumberFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPElectronics.SerialNumberFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPElectronics.SerialNumberFPObj.SerialNumber = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPElectronics.NoOfUnitsFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPElectronics.NoOfUnitsFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPElectronics.NoOfUnitsFPObj.NoOfUnits = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPElectronics.OptPortableItemsFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPElectronics.OptPortableItemsFPObj.EiId).Select(p => p.Value).FirstOrDefault(); // FPElectronics.OptPortableItemsFPObj.PortableItemsOption = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPElectronics.SumInsuredPerUnitFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPElectronics.SumInsuredPerUnitFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPElectronics.SumInsuredPerUnitFPObj.SumInsuredPerUnit = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPElectronics.TotalSumInsuredFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPElectronics.TotalSumInsuredFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPElectronics.TotalSumInsuredFPObj.TotalSumInsured = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPElectronics.ExcessElectronicsFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPElectronics.ExcessElectronicsFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPElectronics.ExcessElectronicsFPObj.Excess = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPElectronics.CoverLossOfDataFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPElectronics.CoverLossOfDataFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPElectronics.CoverLossOfDataFPObj.CoverLossofData = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPElectronics.ExcessCoverLossOfDataFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPElectronics.ExcessCoverLossOfDataFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPElectronics.ExcessCoverLossOfDataFPObj.Excess = val; } } if (unitdetails.SectionData != null && unitdetails.SectionData.AddressData != null) { if (unitdetails.SectionData.AddressData != null) { FPElectronics.AddressObj.Address = unitdetails.SectionData.AddressData.AddressLine1 + ", " + unitdetails.SectionData.AddressData.Suburb + " ," + unitdetails.SectionData.AddressData.State + ", " + unitdetails.SectionData.AddressData.Postcode; } } } if (cid != null && cid.HasValue) { FPElectronics.CustomerId = cid.Value; } if (PcId != null && PcId.HasValue) { FPElectronics.PcId = PcId; } Session["Controller"] = "FarmPolicyElectronics"; Session["ActionName"] = "Electronics"; return(View(FPElectronics)); }
public async System.Threading.Tasks.Task <ActionResult> MainDetails(int?cid, int?PcId) { NewPolicyDetailsClass commonmethods = new NewPolicyDetailsClass(); List <SelectListItem> ExternalWallsMadeList = new List <SelectListItem>(); ExternalWallsMadeList = commonmethods.ExternalWallsMadeList(); List <SelectListItem> IsRoofMadeOfList = new List <SelectListItem>(); IsRoofMadeOfList = commonmethods.RoofMadesList(); HB2HomeDescription HB2HomeDescription = new HB2HomeDescription(); var db = new MasterDataEntities(); if (cid != null) { ViewBag.cid = cid; HB2HomeDescription.CustomerId = cid.Value; } else { ViewBag.cid = HB2HomeDescription.CustomerId; } ViewEditPolicyDetails unitdetails = new ViewEditPolicyDetails(); string apikey = null; if (Session["apiKey"] != null) { apikey = Session["apiKey"].ToString(); HB2HomeDescription.ApiKey = Session["apiKey"].ToString(); } else { return(RedirectToAction("AgentLogin", "Login")); } string policyid = null; List <SessionModel> PolicyInclustions = new List <SessionModel>(); if (PcId != null && PcId.HasValue && PcId > 0) { policyid = PcId.ToString(); HB2HomeDescription.PolicyId = policyid; } else if (Session["Policyinclustions"] != null) { #region Policy Selected or not testing HB2HomeDescription.PolicyInclusions = new List <SessionModel>(); var Policyincllist = Session["Policyinclustions"] as List <SessionModel>; HB2HomeDescription.PolicyInclusions = Policyincllist; if (Policyincllist != null) { if (Policyincllist.Exists(p => p.name == "Home Buildings")) { } else if (Policyincllist.Exists(p => p.name == "Home Contents")) { return(RedirectToAction("HomeContents", "FarmPolicyHomeContent", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Personal Liability")) { return(RedirectToAction("PersonalLiability", "FarmPolicyPersonalLiability", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Valuables")) { return(RedirectToAction("Valuables", "FarmPolicyValuables", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Motor")) { return(RedirectToAction("VehicleDescription", "FarmMotors", new { cid = cid, PcId = PcId })); } if (Policyincllist.Exists(p => p.name == "Home Buildings")) { if (Session["unId"] == null && Session["profileId"] == null) { Session["unId"] = Policyincllist.Where(p => p.name == "Home Buildings").Select(p => p.UnitId).First(); Session["profileId"] = Policyincllist.Where(p => p.name == "Home Buildings").Select(p => p.ProfileId).First(); } } else { return(RedirectToAction("DisclosureDetails", "Disclosure", new { cid = cid, PcId = PcId })); } } #endregion } #region homeDescription HB2HomeDescription.LocationObj = new Locations(); HB2HomeDescription.LocationObj.EiId = 60133; HB2HomeDescription.LocationObj.Location = ""; HB2HomeDescription.IsbuildinglocatedObj = new IsBuildingLocateds(); HB2HomeDescription.IsbuildinglocatedObj.EiId = 62067; HB2HomeDescription.DescribeaddressObj = new DescribeAddresses(); HB2HomeDescription.DescribeaddressObj.EiId = 0; HB2HomeDescription.locatedfarmObj = new locatedOnAFarm(); HB2HomeDescription.locatedfarmObj.EiId = 62069; HB2HomeDescription.TypeOfBuildingObj = new TypeOfBuilding(); HB2HomeDescription.TypeOfBuildingObj.EiId = 62081; HB2HomeDescription.DescribeBuildingObj = new DescribeBuilding(); HB2HomeDescription.DescribeBuildingObj.EiId = 62083; HB2HomeDescription.AreapropertyObj = new Areapropertys(); HB2HomeDescription.AreapropertyObj.Areaproperty = 62089; #endregion #region Constrution Details HB2HomeDescription.ExtwallsmadeObj = new ExtWallsMades(); HB2HomeDescription.ExtwallsmadeObj.ExtwallsmadeList = ExternalWallsMadeList; HB2HomeDescription.ExtwallsmadeObj.EiId = 62085; HB2HomeDescription.DescribeexternalwallsObj = new Describeexternalwalls(); HB2HomeDescription.DescribeexternalwallsObj.EiId = 62087; HB2HomeDescription.RoofmadeObj = new RoofMades(); HB2HomeDescription.RoofmadeObj.RoofmadeList = IsRoofMadeOfList; HB2HomeDescription.RoofmadeObj.EiId = 62089; HB2HomeDescription.DescribeRoofMadeOffObj = new DescribeRoofMadeof(); HB2HomeDescription.DescribeRoofMadeOffObj.EiId = 62091; HB2HomeDescription.YearofBuiltObj = new YearOfBuilt(); HB2HomeDescription.YearofBuiltObj.EiId = 62093; HB2HomeDescription.LastRewiredObj = new LastRewired(); HB2HomeDescription.LastRewiredObj.EiId = 62095; HB2HomeDescription.LastReplumbedObj = new LastReplumbed(); HB2HomeDescription.LastReplumbedObj.EiId = 62097; HB2HomeDescription.WatertightObj = new Watertights(); HB2HomeDescription.WatertightObj.EiId = 62099; HB2HomeDescription.HeritagelegislationObj = new HeritageLegislations(); HB2HomeDescription.HeritagelegislationObj.EiId = 62109; HB2HomeDescription.UnderconstructionObj = new UnderConstructions(); HB2HomeDescription.UnderconstructionObj.EiId = 62111; HB2HomeDescription.DomesticdwellingObj = new DomesticDwellings(); HB2HomeDescription.DomesticdwellingObj.EiId = 62113; HB2HomeDescription.UnrepaireddamageObj = new UnrepairedDamage(); HB2HomeDescription.UnrepaireddamageObj.EiId = 62115; HB2HomeDescription.RustDamageObj = new RustDamage(); HB2HomeDescription.RustDamageObj.EiId = 62090; #endregion #region Occupancy Details HB2HomeDescription.WholivesObj = new WhoLives(); HB2HomeDescription.WholivesObj.EiId = 62127; HB2HomeDescription.WholivesObj.Wholives = 0; HB2HomeDescription.IsbuildingObj = new IsBuildings(); HB2HomeDescription.IsbuildingObj.EiId = 62129; HB2HomeDescription.IsbuildingObj.Isbuilding = 0; HB2HomeDescription.ConsecutivedayObj = new Consecutivedays(); HB2HomeDescription.ConsecutivedayObj.EiId = 62131; HB2HomeDescription.ConsecutivedayObj.Consecutiveday = 0; HB2HomeDescription.IsusedbusinessObj = new IsusedBusinesses(); HB2HomeDescription.IsusedbusinessObj.EiId = 62133; HB2HomeDescription.DescribebusinessObj = new DescribeBusinesses(); HB2HomeDescription.DescribebusinessObj.EiId = 62135; #endregion #region Interested Parties HB2HomeDescription.LocationObjs = new Locations(); HB2HomeDescription.LocationObjs.EiId = 62189; HB2HomeDescription.NameInstitutionsObj = new NameOfInstitutionsRls(); HB2HomeDescription.NameInstitutionsObj.EiId = 62187; #endregion #region Home Building HB2HomeDescription.CoverhomebuildingObj = new CoverHomeBuildings(); HB2HomeDescription.CoverhomebuildingObj.EiId = 63459; HB2HomeDescription.CostforRebuildingObj = new CostForRebuilding(); HB2HomeDescription.CostforRebuildingObj.EiId = 63461; HB2HomeDescription.ClaimfreeperiodObj = new ClaimFreePeriods(); HB2HomeDescription.ClaimfreeperiodObj.EiId = 63471; HB2HomeDescription.ExcessObj = new Excesses(); HB2HomeDescription.ExcessObj.EiId = 63473; HB2HomeDescription.WindowCoveringsObj = new WindowCoverings(); HB2HomeDescription.WindowCoveringsObj.EiId = 63465; HB2HomeDescription.ProtectionCoverObj = new MortgageeProtectionCover(); HB2HomeDescription.ProtectionCoverObj.EiId = 63467; #endregion HttpClient hclient = new HttpClient(); string url = System.Configuration.ConfigurationManager.AppSettings["APIURL"]; hclient.BaseAddress = new Uri(url); hclient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); int unid = Convert.ToInt32(Session["unId"]); int?profileid = Convert.ToInt32(Session["profileId"]); if (PcId != null && PcId.HasValue) { var policyinclusions = db.usp_GetUnit(null, PcId, null).ToList(); HB2HomeDescription.PolicyInclusion = new List <usp_GetUnit_Result>(); if (PcId != null && PcId.HasValue && PcId > 0) { HB2HomeDescription.PolicyInclusion = policyinclusions; } HB2HomeDescription.PolicyInclusions = new List <SessionModel>(); if (PcId != null && PcId > 0) { HB2HomeDescription.PolicyId = PcId.ToString(); } bool policyinclusion = policyinclusions.Exists(p => p.Name == "Home Buildings"); if (policyinclusion == true && PcId != null && PcId.HasValue) { unid = policyinclusions.Where(p => p.Name == "Home Buildings").Select(p => p.UnId).FirstOrDefault(); profileid = policyinclusions.Where(p => p.Name == "Home Buildings").Select(p => p.ProfileUnId).FirstOrDefault(); HttpResponseMessage getunit = await hclient.GetAsync("UnitDetails?ApiKey=" + apikey + "&Action=Existing&SectionName=&SectionUnId=" + unid + "&ProfileUnId=" + profileid); var EmpResponse = getunit.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); } } else { return(RedirectToAction("HomeContents", "FarmPolicyHomeContent", new { cid = cid, PcId = PcId })); } } else { if (PcId == null && Session["unId"] == null && Session["profileId"] == null) { HttpResponseMessage Res = await hclient.GetAsync("UnitDetails?ApiKey=" + apikey + "&Action=New&SectionName=Home Buildings&SectionUnId=&ProfileUnId=0"); var EmpResponse = Res.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); if (unitdetails != null && unitdetails.SectionData != null) { Session["unId"] = unitdetails.SectionData.UnId; Session["profileId"] = unitdetails.SectionData.ProfileUnId; } } } else if (PcId == null && Session["unId"] != null && Session["profileId"] != null) { HttpResponseMessage getunit = await hclient.GetAsync("UnitDetails?ApiKey=" + apikey + "&Action=Existing&SectionName=&SectionUnId=" + unid + "&ProfileUnId=" + profileid); var EmpResponse = getunit.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); if (unitdetails != null && unitdetails.SectionData != null) { Session["unId"] = unitdetails.SectionData.UnId; Session["profileId"] = unitdetails.SectionData.ProfileUnId; } } } } if (unitdetails != null) { if (unitdetails.SectionData != null && unitdetails.SectionData.ValueData != null) { if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == HB2HomeDescription.ExtwallsmadeObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == HB2HomeDescription.ExtwallsmadeObj.EiId).Select(p => p.Value).FirstOrDefault(); HB2HomeDescription.ExtwallsmadeObj.Extwallsmade = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == HB2HomeDescription.IsbuildinglocatedObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == HB2HomeDescription.IsbuildinglocatedObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && !string.IsNullOrEmpty(val)) { HB2HomeDescription.IsbuildinglocatedObj.Isbuildinglocated = Convert.ToInt32(val); } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == HB2HomeDescription.locatedfarmObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == HB2HomeDescription.locatedfarmObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && !string.IsNullOrEmpty(val)) { HB2HomeDescription.locatedfarmObj.locatedonafarm = val; } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == HB2HomeDescription.TypeOfBuildingObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == HB2HomeDescription.TypeOfBuildingObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && !string.IsNullOrEmpty(val)) { HB2HomeDescription.TypeOfBuildingObj.Typeofbuilding = val; } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == HB2HomeDescription.DescribeBuildingObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == HB2HomeDescription.DescribeBuildingObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && !string.IsNullOrEmpty(val)) { HB2HomeDescription.DescribeBuildingObj.Describebuilding = val; } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == HB2HomeDescription.NameInstitutionsObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == HB2HomeDescription.NameInstitutionsObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && !string.IsNullOrEmpty(val)) { HB2HomeDescription.NameInstitutionsObj.Name = val; } if (unitdetails.SectionData.ValueData.Select(p => p.Element.ElId == HB2HomeDescription.NameInstitutionsObj.EiId).Count() > 1) { List <ValueDatas> elmnts = new List <ValueDatas>(); var institutelist = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == HB2HomeDescription.NameInstitutionsObj.EiId).Select(p => p.Element.ItId).ToList(); for (int i = 0; i < institutelist.Count(); i++) { ValueDatas vds = new ValueDatas(); vds.Element = new Elements(); vds.Element.ElId = 62187; vds.Element.ItId = institutelist[i]; vds.Value = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == HB2HomeDescription.NameInstitutionsObj.EiId && p.Element.ItId == institutelist[i]).Select(p => p.Value).FirstOrDefault(); elmnts.Add(vds); } HB2HomeDescription.NameInstitutionsObjList = elmnts; } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == HB2HomeDescription.LocationObjs.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == HB2HomeDescription.LocationObjs.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && !string.IsNullOrEmpty(val)) { HB2HomeDescription.LocationObjs.Location = val; } if (unitdetails.SectionData.ValueData.Select(p => p.Element.ElId == HB2HomeDescription.LocationObjs.EiId).Count() > 1) { List <ValueDatas> elmntsts = new List <ValueDatas>(); var institutelst = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == HB2HomeDescription.LocationObjs.EiId).Select(p => p.Element.ItId).ToList(); for (int i = 0; i < institutelst.Count(); i++) { ValueDatas vds = new ValueDatas(); vds.Element = new Elements(); vds.Element.ElId = 62189; vds.Element.ItId = institutelst[i]; vds.Value = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == HB2HomeDescription.LocationObjs.EiId && p.Element.ItId == institutelst[i]).Select(p => p.Value).FirstOrDefault(); elmntsts.Add(vds); } HB2HomeDescription.LocationObjsList = elmntsts; } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == HB2HomeDescription.ConsecutivedayObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == HB2HomeDescription.ConsecutivedayObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && val != "0" && !string.IsNullOrEmpty(val)) { HB2HomeDescription.ConsecutivedayObj.Consecutiveday = Convert.ToInt32(val); } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == HB2HomeDescription.DescribeaddressObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == HB2HomeDescription.DescribeaddressObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && val != "0" && !string.IsNullOrEmpty(val)) { HB2HomeDescription.DescribeaddressObj.Describeaddress = Convert.ToInt32(val); } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == HB2HomeDescription.DescribebusinessObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == HB2HomeDescription.DescribebusinessObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && val != "0" && !string.IsNullOrEmpty(val)) { HB2HomeDescription.DescribebusinessObj.Describebusiness = val; } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == HB2HomeDescription.DescribeexternalwallsObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == HB2HomeDescription.DescribeexternalwallsObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && val != "0" && !string.IsNullOrEmpty(val)) { HB2HomeDescription.DescribeexternalwallsObj.Describeexternalwall = val; } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == HB2HomeDescription.DescribeRoofMadeOffObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == HB2HomeDescription.DescribeRoofMadeOffObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && val != "0" && !string.IsNullOrEmpty(val)) { HB2HomeDescription.DescribeRoofMadeOffObj.DescribeRoofMade = val; } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == HB2HomeDescription.RoofmadeObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == HB2HomeDescription.RoofmadeObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && val != "0" && !string.IsNullOrEmpty(val)) { HB2HomeDescription.RoofmadeObj.Roofmade = val; } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == HB2HomeDescription.RustDamageObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == HB2HomeDescription.RustDamageObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && !string.IsNullOrEmpty(val)) { HB2HomeDescription.RustDamageObj.RustDamages = Convert.ToInt32(val); } else { HB2HomeDescription.RustDamageObj.RustDamages = -1; } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == HB2HomeDescription.DomesticdwellingObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == HB2HomeDescription.DomesticdwellingObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && val != "0" && !string.IsNullOrEmpty(val)) { if (val == "1") { HB2HomeDescription.DomesticdwellingObj.Domesticdwelling = 1; } else if (val == "0") { HB2HomeDescription.DomesticdwellingObj.Domesticdwelling = 0; } else { HB2HomeDescription.DomesticdwellingObj.Domesticdwelling = -1; } } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == HB2HomeDescription.LastRewiredObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == HB2HomeDescription.LastRewiredObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && val != "0" && !string.IsNullOrEmpty(val)) { HB2HomeDescription.LastRewiredObj.Rewired = val; } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == HB2HomeDescription.LastReplumbedObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == HB2HomeDescription.LastReplumbedObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && val != "0" && !string.IsNullOrEmpty(val)) { HB2HomeDescription.LastReplumbedObj.Replumbed = val; } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == HB2HomeDescription.ExtwallsmadeObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == HB2HomeDescription.ExtwallsmadeObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && val != "0" && !string.IsNullOrEmpty(val)) { HB2HomeDescription.ExtwallsmadeObj.Extwallsmade = val; } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == HB2HomeDescription.HeritagelegislationObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == HB2HomeDescription.HeritagelegislationObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && val != "0" && !string.IsNullOrEmpty(val)) { if (val == "0") { HB2HomeDescription.HeritagelegislationObj.Heritagelegislation = 0; } else if (val == "1") { HB2HomeDescription.HeritagelegislationObj.Heritagelegislation = 1; } else { HB2HomeDescription.HeritagelegislationObj.Heritagelegislation = -1; } } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == HB2HomeDescription.IsusedbusinessObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == HB2HomeDescription.IsusedbusinessObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && val != "0" && !string.IsNullOrEmpty(val)) { HB2HomeDescription.IsusedbusinessObj.Isusedbusiness = Convert.ToInt32(val); } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == HB2HomeDescription.UnderconstructionObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == HB2HomeDescription.UnderconstructionObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && val != "0" && !string.IsNullOrEmpty(val)) { if (val == "0") { HB2HomeDescription.UnderconstructionObj.Underconstruction = 0; } else if (val == "1") { HB2HomeDescription.UnderconstructionObj.Underconstruction = 1; } else { HB2HomeDescription.UnderconstructionObj.Underconstruction = -1; } } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == HB2HomeDescription.WatertightObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == HB2HomeDescription.WatertightObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && val != "0" && !string.IsNullOrEmpty(val)) { if (val == "0") { HB2HomeDescription.WatertightObj.Watertight = 0; } else if (val == "1") { HB2HomeDescription.WatertightObj.Watertight = 1; } else { HB2HomeDescription.WatertightObj.Watertight = -1; } } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == HB2HomeDescription.WholivesObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == HB2HomeDescription.WholivesObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && val != "2" && !string.IsNullOrEmpty(val)) { HB2HomeDescription.WholivesObj.Wholives = Convert.ToInt32(val); } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == HB2HomeDescription.YearofBuiltObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == HB2HomeDescription.YearofBuiltObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && val != "0" && !string.IsNullOrEmpty(val)) { HB2HomeDescription.YearofBuiltObj.YearBuilt = val; } } } if (unitdetails.SectionData != null && unitdetails.SectionData.ValueData != null) { if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == HB2HomeDescription.ClaimfreeperiodObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == HB2HomeDescription.ClaimfreeperiodObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && (val == "0" || val == "1" || val == "2")) { HB2HomeDescription.ClaimfreeperiodObj.Claimfreeperiod = Convert.ToInt32(val); } } else { HB2HomeDescription.ClaimfreeperiodObj.Claimfreeperiod = -1; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == HB2HomeDescription.CostforRebuildingObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == HB2HomeDescription.CostforRebuildingObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && val != "0" && !string.IsNullOrEmpty(val)) { HB2HomeDescription.CostforRebuildingObj.CostforRebuilding = Convert.ToInt32(val); } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == HB2HomeDescription.ExcessObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == HB2HomeDescription.ExcessObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && val != "0" && !string.IsNullOrEmpty(val)) { HB2HomeDescription.ExcessObj.Excess = val; } } if (unitdetails.SectionData.AddressData != null) { string address = unitdetails.SectionData.AddressData.AddressLine1 + ", " + unitdetails.SectionData.AddressData.Suburb + ", " + unitdetails.SectionData.AddressData.State + ", " + unitdetails.SectionData.AddressData.Postcode; HB2HomeDescription.addressCom = address; } } } if (cid != null && cid.HasValue) { HB2HomeDescription.CustomerId = cid.Value; } if (PcId != null && PcId.HasValue) { HB2HomeDescription.PcId = PcId; } Session["Controller"] = "FarmPolicyHome"; Session["ActionName"] = "MainDetails"; return(View(HB2HomeDescription)); }
public async System.Threading.Tasks.Task <ActionResult> HomeContents(int?cid, int?PcId) { NewPolicyDetailsClass commonModel = new NewPolicyDetailsClass(); List <SelectListItem> DescriptionListHomeContents = new List <SelectListItem>(); DescriptionListHomeContents = commonModel.descriptionListFC(); FPHomeContents FPHomeContents = new FPHomeContents(); string ApiKey = null; if (Session["ApiKey"] != null) { ApiKey = Session["ApiKey"].ToString(); } else { return(RedirectToAction("AgentLogin", "Login")); } var Policyincllist = new List <SessionModel>(); FPValuables FPValuables = new FPValuables(); if (Session["Policyinclustions"] != null) { Policyincllist = Session["Policyinclustions"] as List <SessionModel>; if (Policyincllist != null) { if (Policyincllist != null) { if (Policyincllist.Exists(p => p.name == "Home Content" || p.name == "Home Contents")) { } else if (Policyincllist.Exists(p => p.name == "Personal Liability")) { return(RedirectToAction("PersonalLiability", "FarmPolicyPersonalLiability", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Valuables")) { return(RedirectToAction("Valuables", "FarmPolicyValuables", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Motor")) { return(RedirectToAction("VehicleDescription", "FarmMotors", new { cid = cid, PcId = PcId })); } if (Policyincllist.Exists(p => p.name == "Home Content" || p.name == "Home Contents")) { if (Session["unId"] == null && Session["profileId"] == null) { Session["unId"] = Policyincllist.Where(p => p.name == "Home Content" || p.name == "Home Contents").Select(p => p.UnitId).First(); Session["profileId"] = Policyincllist.Where(p => p.name == "Home Content" || p.name == "Home Contents").Select(p => p.ProfileId).First(); } } else { return(RedirectToAction("DisclosureDetails", "Disclosure", new { cid = cid, PcId = PcId })); } } } } else { RedirectToAction("PolicyInclustions", "Customer", new { CustomerId = cid, type = 1021 }); } if (cid != null && cid > 0) { ViewBag.cid = cid; FPHomeContents.CustomerId = cid.Value; } ViewEditPolicyDetails unitdetails = new ViewEditPolicyDetails(); FPHomeContents.CoveroptionFPObj = new CoverOptionFP(); FPHomeContents.CoveroptionFPObj.EiId = 63549; FPHomeContents.UnspecifiedFPObj = new UnspecifiedFP(); FPHomeContents.UnspecifiedFPObj.EiId = 63551; FPHomeContents.DescriptionFPObj = new DescriptionsFP(); FPHomeContents.DescriptionFPObj.DescriptionList = DescriptionListHomeContents; FPHomeContents.DescriptionFPObj.EiId = 63563; FPHomeContents.SumInsuredFPObj = new SumInsuredFP(); FPHomeContents.SumInsuredFPObj.EiId = 63565; FPHomeContents.ClaimperiodFPObj = new ClaimFreePeriodFP(); FPHomeContents.ClaimperiodFPObj.EiId = 63579; FPHomeContents.ExcessFPHContentObj = new ExcessFPHContent(); FPHomeContents.ExcessFPHContentObj.EiId = 63581; FPHomeContents.discountFPObj = new NoClaimDiscountFP(); FPHomeContents.discountFPObj.EiId = 63587; FPHomeContents.AgediscountObj = new AgeDiscountFP(); FPHomeContents.AgediscountObj.EiId = 63591; var db = new MasterDataEntities(); string policyid = null; if (cid != null) { ViewBag.cid = cid; FPHomeContents.CustomerId = cid.Value; } else { ViewBag.cid = FPHomeContents.CustomerId; } HttpClient hclient = new HttpClient(); string url = System.Configuration.ConfigurationManager.AppSettings["APIURL"]; hclient.BaseAddress = new Uri(url); hclient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); int unid = 0; int?profileid = 0; int Fprofileid = 0; if (Session["unId"] != null && Session["ProfileId"] != null) { unid = Convert.ToInt32(Session["unId"]); profileid = Convert.ToInt32(Session["profileId"]); } if (Session["FProfileId"] != null) { Fprofileid = Convert.ToInt32(Session["FprofileId"]); } if (Session["Policyinclustions"] != null) { FPHomeContents.PolicyInclusions = Policyincllist; } if (PcId != null && PcId.HasValue && PcId > 0) { var policyinclusions = db.usp_GetUnit(null, PcId, null).ToList(); FPHomeContents.PolicyInclusion = new List <usp_GetUnit_Result>(); if (PcId != null && PcId.HasValue && PcId > 0) { FPHomeContents.PolicyInclusion = policyinclusions; } FPHomeContents.PolicyInclusions = new List <SessionModel>(); if (PcId != null && PcId > 0) { policyid = PcId.ToString(); FPHomeContents.PolicyId = policyid; } bool policyinclusion = policyinclusions.Exists(p => p.Name == "Home Contents"); if (policyinclusion == true && PcId != null && PcId.HasValue) { unid = policyinclusions.Where(p => p.Name == "Home Contents").Select(p => p.UnId).FirstOrDefault(); profileid = policyinclusions.Where(p => p.Name == "Home Contents").Select(p => p.ProfileUnId).FirstOrDefault(); HttpResponseMessage getunit = await hclient.GetAsync("UnitDetails?ApiKey=" + ApiKey + "&Action=Existing&SectionName=&SectionUnId=" + unid + "&ProfileUnId=" + profileid); var EmpResponse = getunit.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); } } else { return(RedirectToAction("PersonalLiability", "FarmPolicyPersonalLiability", new { cid = cid, PcId = PcId })); } } else { if (PcId == null && Session["unId"] == null && Session["profileId"] == null) { HttpResponseMessage Res = await hclient.GetAsync("UnitDetails?ApiKey=" + ApiKey + "&Action=New&SectionName=Home Contents&SectionUnId=&ProfileUnId=-1"); var EmpResponse = Res.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); if (unitdetails != null && unitdetails.SectionData != null) { Session["unId"] = unitdetails.SectionData.UnId; Session["FprofileId"] = unitdetails.SectionData.ProfileUnId; Session["profileId"] = unitdetails.SectionData.ProfileUnId; if (Policyincllist != null && Policyincllist.Exists(p => p.name == "Home Contents")) { var policyhomelist = Policyincllist.FindAll(p => p.name == "Home Contents").ToList(); if (policyhomelist != null && policyhomelist.Count() > 0) { Policyincllist.FindAll(p => p.name == "Home Contents").Where(p => p.UnitId == null).First().UnitId = unitdetails.SectionData.UnId; Policyincllist.FindAll(p => p.name == "Home Contents").Where(p => p.ProfileId == null).First().ProfileId = unitdetails.SectionData.ProfileUnId; } else { Policyincllist.FindAll(p => p.name == "Home Contents").First().UnitId = unitdetails.SectionData.UnId; Policyincllist.FindAll(p => p.name == "Home Contents").First().ProfileId = unitdetails.SectionData.ProfileUnId; } } } } } else { if (PcId == null && Session["unId"] != null && (Session["profileId"] != null || (Fprofileid != null && Fprofileid < 0))) { if (profileid == null || profileid == 0) { profileid = Fprofileid; } HttpResponseMessage getunit = await hclient.GetAsync("UnitDetails?ApiKey=" + ApiKey + "&Action=Existing&SectionName=&SectionUnId=" + unid + "&ProfileUnId=" + profileid); var EmpResponse = getunit.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); if (unitdetails != null && unitdetails.SectionData != null) { Session["unId"] = unitdetails.SectionData.UnId; Session["FprofileId"] = unitdetails.SectionData.ProfileUnId; } } } } } if (unitdetails != null) { if (unitdetails.SectionData != null && unitdetails.SectionData.ValueData != null) { if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPHomeContents.CoveroptionFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPHomeContents.CoveroptionFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPHomeContents.CoveroptionFPObj.Coveroption = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPHomeContents.UnspecifiedFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPHomeContents.UnspecifiedFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPHomeContents.UnspecifiedFPObj.Unspecified = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPHomeContents.DescriptionFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPHomeContents.DescriptionFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPHomeContents.DescriptionFPObj.Description = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPHomeContents.ExcessFPHContentObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPHomeContents.ExcessFPHContentObj.EiId).Select(p => p.Value).FirstOrDefault(); FPHomeContents.ExcessFPHContentObj.Excess = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPHomeContents.ClaimperiodFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPHomeContents.ClaimperiodFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPHomeContents.ClaimperiodFPObj.Claimfreeperiod = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPHomeContents.discountFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPHomeContents.discountFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPHomeContents.discountFPObj.discount = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPHomeContents.AgediscountObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPHomeContents.AgediscountObj.EiId).Select(p => p.Value).FirstOrDefault(); FPHomeContents.AgediscountObj.Agediscount = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPHomeContents.SumInsuredFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPHomeContents.SumInsuredFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPHomeContents.SumInsuredFPObj.SumInsured = val; } } } if (cid != null && cid.HasValue) { FPHomeContents.CustomerId = cid.Value; } if (PcId != null && PcId.HasValue) { FPHomeContents.PcId = PcId; } Session["Controller"] = "FarmPolicyHomeContent"; Session["ActionName"] = "HomeContents"; return(View(FPHomeContents)); }
public async System.Threading.Tasks.Task <ActionResult> Money(int?cid, int?PcId) { NewPolicyDetailsClass commonModel = new NewPolicyDetailsClass(); List <SelectListItem> FPMoneyExcessToPay = new List <SelectListItem>(); FPMoneyExcessToPay = commonModel.excessRate(); FPMoney FPMoney = new FPMoney(); var db = new MasterDataEntities(); if (cid != null) { ViewBag.cid = cid; FPMoney.CustomerId = cid.Value; } else { ViewBag.cid = FPMoney.CustomerId; } ViewEditPolicyDetails unitdetails = new ViewEditPolicyDetails(); NewPolicyDetailsClass commonmethods = new NewPolicyDetailsClass(); string apikey = null; if (Session["apiKey"] != null) { apikey = Session["apiKey"].ToString(); FPMoney.ApiKey = Session["apiKey"].ToString(); } else { return(RedirectToAction("AgentLogin", "Login")); } string policyid = null; List <SessionModel> PolicyInclustions = new List <SessionModel>(); if (PcId != null && PcId.HasValue && PcId > 0) { policyid = PcId.ToString(); FPMoney.PolicyId = policyid; } else if (Session["Policyinclustions"] != null) { #region Policy Selected or not testing FPMoney.PolicyInclusions = new List <SessionModel>(); var Policyincllist = Session["Policyinclustions"] as List <SessionModel>; FPMoney.PolicyInclusions = Policyincllist; if (Policyincllist != null) { if (Policyincllist.Exists(p => p.name == "Money")) { } else if (Policyincllist.Exists(p => p.name == "Farm Liability")) { return(RedirectToAction("FarmLiability", "FarmPolicyFarmLiability", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Machinery")) { return(RedirectToAction("Machinery", "FarmPolicyMachinery", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Electronics")) { return(RedirectToAction("Electronics", "FarmPolicyElectronics", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Transit")) { return(RedirectToAction("Transit", "FarmPolicyTransit", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Livestock")) { return(RedirectToAction("Livestock", "FarmPolicyLivestock", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Home Buildings")) { return(RedirectToAction("MainDetails", "FarmPolicyHome", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Home Contents")) { return(RedirectToAction("HomeContents", "FarmPolicyHomeContent", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Personal Liability")) { return(RedirectToAction("PersonalLiability", "FarmPolicyPersonalLiability", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Valuables")) { return(RedirectToAction("Valuables", "FarmPolicyValuables", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Motor")) { return(RedirectToAction("VehicleDescription", "FarmMotors", new { cid = cid, PcId = PcId })); } if (Policyincllist.Exists(p => p.name == "Money")) { if (Session["unId"] == null && Session["profileId"] == null) { Session["unId"] = Policyincllist.Where(p => p.name == "Money").Select(p => p.UnitId).First(); Session["profileId"] = Policyincllist.Where(p => p.name == "Money").Select(p => p.ProfileId).First(); } } else { return(RedirectToAction("DisclosureDetails", "Disclosure", new { cid = cid, PcId = PcId })); } } #endregion } FPMoney.AtTheLocationObj = new AtTheLocation(); FPMoney.AtTheLocationObj.EiId = 62791; FPMoney.LockedSafeAtLocationObj = new LockedSafeAtLocation(); FPMoney.LockedSafeAtLocationObj.EiId = 62795; FPMoney.BankorOtherFinanInstObj = new BankorOtherFinanInst(); FPMoney.BankorOtherFinanInstObj.EiId = 62799; FPMoney.ExcessFPMoneyObj = new ExcessFPMoney(); FPMoney.ExcessFPMoneyObj.ExcessList = FPMoneyExcessToPay; FPMoney.ExcessFPMoneyObj.EiId = 62801; FPMoney.AddressObj = new AddressMnAddress(); FPMoney.AddressObj.EiId = 0; HttpClient hclient = new HttpClient(); string url = System.Configuration.ConfigurationManager.AppSettings["APIURL"]; hclient.BaseAddress = new Uri(url); hclient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); int unid = Convert.ToInt32(Session["unId"]); int?profileid = Convert.ToInt32(Session["profileId"]); if (PcId != null && PcId.HasValue) { var policyinclusions = db.usp_GetUnit(null, PcId, null).ToList(); FPMoney.PolicyInclusion = new List <usp_GetUnit_Result>(); if (PcId != null && PcId.HasValue && PcId > 0) { FPMoney.PolicyInclusion = policyinclusions; } FPMoney.PolicyInclusions = new List <SessionModel>(); if (PcId != null && PcId > 0) { policyid = PcId.ToString(); FPMoney.PolicyId = policyid; } bool policyinclusion = policyinclusions.Exists(p => p.Name == "Money"); if (policyinclusion == true && PcId != null && PcId.HasValue) { unid = policyinclusions.Where(p => p.Name == "Money").Select(p => p.UnId).FirstOrDefault(); profileid = policyinclusions.Where(p => p.Name == "Money").Select(p => p.ProfileUnId).FirstOrDefault(); HttpResponseMessage getunit = await hclient.GetAsync("UnitDetails?ApiKey=" + apikey + "&Action=Existing&SectionName=&SectionUnId=" + unid + "&ProfileUnId=" + profileid); var EmpResponse = getunit.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); } } else { return(RedirectToAction("FarmLiability", "FarmPolicyFarmLiability", new { cid = cid, PcId = PcId })); } } else { if (PcId == null && Session["unId"] == null && Session["profileId"] == null) { HttpResponseMessage Res = await hclient.GetAsync("UnitDetails?ApiKey=" + apikey + "&Action=New&SectionName=Money&SectionUnId=&ProfileUnId=-1"); var EmpResponse = Res.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); if (unitdetails != null && unitdetails.SectionData != null) { Session["unId"] = unitdetails.SectionData.UnId; Session["profileId"] = unitdetails.SectionData.ProfileUnId; } } } else if (PcId == null && Session["unId"] != null && Session["profileId"] != null) { HttpResponseMessage getunit = await hclient.GetAsync("UnitDetails?ApiKey=" + apikey + "&Action=Existing&SectionName=&SectionUnId=" + unid + "&ProfileUnId=" + profileid); var EmpResponse = getunit.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); if (unitdetails != null && unitdetails.SectionData != null) { Session["unId"] = unitdetails.SectionData.UnId; Session["profileId"] = unitdetails.SectionData.ProfileUnId; } } } } if (unitdetails != null) { if (unitdetails.SectionData != null && unitdetails.SectionData.ValueData != null) { if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPMoney.AtTheLocationObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPMoney.AtTheLocationObj.EiId).Select(p => p.Value).FirstOrDefault(); FPMoney.AtTheLocationObj.atLocation = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPMoney.LockedSafeAtLocationObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPMoney.LockedSafeAtLocationObj.EiId).Select(p => p.Value).FirstOrDefault(); FPMoney.LockedSafeAtLocationObj.lockedsafeatlocation = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPMoney.BankorOtherFinanInstObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPMoney.BankorOtherFinanInstObj.EiId).Select(p => p.Value).FirstOrDefault(); FPMoney.BankorOtherFinanInstObj.bankorotherFinanInst = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPMoney.ExcessFPMoneyObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPMoney.ExcessFPMoneyObj.EiId).Select(p => p.Value).FirstOrDefault(); FPMoney.ExcessFPMoneyObj.Excess = val; } } if (unitdetails.SectionData != null && unitdetails.SectionData.AddressData != null) { if (unitdetails.SectionData.AddressData != null) { FPMoney.AddressObj.Address = unitdetails.SectionData.AddressData.AddressLine1 + ", " + unitdetails.SectionData.AddressData.Suburb + " ," + unitdetails.SectionData.AddressData.State + ", " + unitdetails.SectionData.AddressData.Postcode; } } } if (cid != null && cid.HasValue) { FPMoney.CustomerId = cid.Value; } if (PcId != null && PcId.HasValue) { FPMoney.PcId = PcId; } Session["Controller"] = "FarmPolicyMoney"; Session["ActionName"] = "Money"; return(View(FPMoney)); }
public async System.Threading.Tasks.Task <ActionResult> PersonalLiability(int?cid, int?PcId) { NewPolicyDetailsClass commonModel = new NewPolicyDetailsClass(); List <SelectListItem> PersonalLiabilityexcessToPay = new List <SelectListItem>(); PersonalLiability PersonalLiability = new PersonalLiability(); var db = new MasterDataEntities(); if (cid != null) { ViewBag.cid = cid; PersonalLiability.CustomerId = cid.Value; } else { ViewBag.cid = PersonalLiability.CustomerId; } ViewEditPolicyDetails unitdetails = new ViewEditPolicyDetails(); NewPolicyDetailsClass commonmethods = new NewPolicyDetailsClass(); string apikey = null; if (Session["apiKey"] != null) { apikey = Session["apiKey"].ToString(); PersonalLiability.ApiKey = Session["apiKey"].ToString(); } else { return(RedirectToAction("AgentLogin", "Login")); } string policyid = null; List <SessionModel> PolicyInclustions = new List <SessionModel>(); if (PcId != null && PcId.HasValue && PcId > 0) { policyid = PcId.ToString(); PersonalLiability.PolicyId = policyid; } else if (Session["Policyinclustions"] != null) { #region Policy Selected or not testing PersonalLiability.PolicyInclusions = new List <SessionModel>(); var Policyincllist = Session["Policyinclustions"] as List <SessionModel>; PersonalLiability.PolicyInclusions = Policyincllist; if (Policyincllist != null) { if (Policyincllist.Exists(p => p.name == "Personal Liability")) { } else if (Policyincllist.Exists(p => p.name == "Valuables")) { return(RedirectToAction("Valuables", "FarmPolicyValuables", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Motor")) { return(RedirectToAction("VehicleDescription", "FarmMotors", new { cid = cid, PcId = PcId })); } if (Policyincllist.Exists(p => p.name == "Personal Liability")) { if (Session["unId"] == null && Session["profileId"] == null) { Session["unId"] = Policyincllist.Where(p => p.name == "Personal Liability").Select(p => p.UnitId).First(); Session["profileId"] = Policyincllist.Where(p => p.name == "Personal Liability").Select(p => p.ProfileId).First(); } } else { return(RedirectToAction("DisclosureDetails", "Disclosure", new { cid = cid, PcId = PcId })); } } #endregion } PersonalLiability.LimitindemnityObj = new LimitOfIndemnity(); PersonalLiability.LimitindemnityObj.EiId = 63663; PersonalLiability.ExcessplObj = new ExcessPL(); PersonalLiability.ExcessplObj.ExcessList = PersonalLiabilityexcessToPay; PersonalLiability.ExcessplObj.EiId = 63667; HttpClient hclient = new HttpClient(); string url = System.Configuration.ConfigurationManager.AppSettings["APIURL"]; hclient.BaseAddress = new Uri(url); hclient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); int unid = Convert.ToInt32(Session["unId"]); int?profileid = Convert.ToInt32(Session["profileId"]); if (PcId != null && PcId.HasValue) { var policyinclusions = db.usp_GetUnit(null, PcId, null).ToList(); PersonalLiability.PolicyInclusion = new List <usp_GetUnit_Result>(); if (PcId != null && PcId.HasValue && PcId > 0) { PersonalLiability.PolicyInclusion = policyinclusions; } PersonalLiability.PolicyInclusions = new List <SessionModel>(); if (PcId != null && PcId > 0) { policyid = PcId.ToString(); PersonalLiability.PolicyId = policyid; } bool policyinclusion = policyinclusions.Exists(p => p.Name == "Home Contents"); if (policyinclusion == true && PcId != null && PcId.HasValue) { unid = policyinclusions.Where(p => p.Name == "Home Contents").Select(p => p.UnId).FirstOrDefault(); profileid = policyinclusions.Where(p => p.Name == "Home Contents").Select(p => p.ProfileUnId).FirstOrDefault(); HttpResponseMessage getunit = await hclient.GetAsync("UnitDetails?ApiKey=" + apikey + "&Action=Existing&SectionName=&SectionUnId=" + unid + "&ProfileUnId=" + profileid); var EmpResponse = getunit.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); } } else { return(RedirectToAction("Valuables", "FarmPolicyValuables", new { cid = cid, PcId = PcId })); } } else { if (PcId == null && Session["unId"] == null && Session["profileId"] == null) { HttpResponseMessage Res = await hclient.GetAsync("UnitDetails?ApiKey=" + apikey + "&Action=New&SectionName=Personal Liability&SectionUnId=&ProfileUnId=0"); var EmpResponse = Res.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); if (unitdetails != null && unitdetails.SectionData != null) { Session["unId"] = unitdetails.SectionData.UnId; Session["profileId"] = unitdetails.SectionData.ProfileUnId; } } } else if (PcId == null && Session["unId"] != null && Session["profileId"] != null) { HttpResponseMessage getunit = await hclient.GetAsync("UnitDetails?ApiKey=" + apikey + "&Action=Existing&SectionName=&SectionUnId=" + unid + "&ProfileUnId=" + profileid); var EmpResponse = getunit.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); if (unitdetails != null && unitdetails.SectionData != null) { Session["unId"] = unitdetails.SectionData.UnId; Session["profileId"] = unitdetails.SectionData.ProfileUnId; } } } } if (unitdetails != null) { if (unitdetails.SectionData != null && unitdetails.SectionData.ValueData != null) { if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == PersonalLiability.LimitindemnityObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == PersonalLiability.LimitindemnityObj.EiId).Select(p => p.Value).FirstOrDefault(); PersonalLiability.LimitindemnityObj.Limitindemnity = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == PersonalLiability.ExcessplObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == PersonalLiability.ExcessplObj.EiId).Select(p => p.Value).FirstOrDefault(); PersonalLiability.ExcessplObj.Excess = val; } } } if (cid != null && cid.HasValue) { PersonalLiability.CustomerId = cid.Value; } if (PcId != null && PcId.HasValue) { PersonalLiability.PcId = PcId; } Session["Controller"] = "FarmPolicyPersonalLiability"; Session["ActionName"] = "PersonalLiability"; return(View(PersonalLiability)); }
public async System.Threading.Tasks.Task <ActionResult> LiabilityCover(int?cid, int?PcId) { LiabilityCover LiabilityCover = new LiabilityCover(); if (cid.HasValue && cid > 0) { ViewBag.cid = cid; LiabilityCover.CustomerId = cid.Value; } string apikey = ""; if (Session["ApiKey"] != null) { apikey = Session["ApiKey"].ToString(); } else { return(RedirectToAction("AgentLogin", "Login")); } var Policyincllist = Session["Policyinclustions"] as List <SessionModel>; CommonUseFunctionClass cmn = new CommonUseFunctionClass(); LiabilityCover.NewSections = new List <string>(); if (Session["Policyinclustions"] != null) { List <SessionModel> PolicyInclustions = new List <SessionModel>(); LiabilityCover.PolicyInclusions = new List <SessionModel>(); LiabilityCover.PolicyInclusions = Policyincllist; LiabilityCover.NewSections = cmn.NewSectionHome(LiabilityCover.PolicyInclusions); if (Policyincllist != null) { //var Policyincllist = Session["Policyinclustions"] as List<SessionModel>; // var Suburb = new List<KeyValuePair<string, string>>(); // List<SelectListItem> listItems = new List<SelectListItem>(); if (Policyincllist != null) { if (Policyincllist.Exists(p => p.name == "Liability")) { } else { if (Policyincllist.Exists(p => p.name == "Motor" || p.name == "Motors")) { return(RedirectToAction("VehicleDescription", "MotorCover", new { cid = cid })); } else if (Policyincllist.Exists(p => p.name == "Boat")) { return(RedirectToAction("BoatDetails", "Boat", new { cid = cid })); } else if (Policyincllist.Exists(p => p.name == "Pet" || p.name == "Pets")) { return(RedirectToAction("PetsCover", "Pets", new { cid = cid })); } else if (Policyincllist.Exists(p => p.name == "Travel")) { return(RedirectToAction("TravelCover", "Travel", new { cid = cid })); } if (Policyincllist.Exists(p => p.name == "Liability")) { if (Session["unId"] == null && Session["profileId"] == null) { Session["unId"] = Policyincllist.Where(p => p.name == "Liability").Select(p => p.UnitId).First(); Session["profileId"] = Policyincllist.Where(p => p.name == "Liability").Select(p => p.ProfileId).First(); } } else { return(RedirectToAction("DisclosureDetails", "Disclosure", new { cid = cid, PcId = PcId })); } } } } } //else //{ // RedirectToAction("PolicyInclustions", "Customer", new { CustomerId = cid,type=1 }); //} var db = new MasterDataEntities(); ViewEditPolicyDetails unitdetails = new ViewEditPolicyDetails(); unitdetails.AddressData = new List <AddressData>(); var policyinclusions = db.usp_GetUnit(null, PcId, null).ToList(); LiabilityCover.FarmliabiltyObj = new FarmLiabiltys(); LiabilityCover.FarmliabiltyObj.EiId = 60691; LiabilityCover.LimitindemnityObj = new LimitofIndemnity(); LiabilityCover.LimitindemnityObj.EiId = 60671; LiabilityCover.FarmingactivitiesObj = new Farmingactivities(); LiabilityCover.FarmingactivitiesObj.EiId = 60673; LiabilityCover.FarmProduceObj = new ProductsCoveredFP(); LiabilityCover.FarmProduceObj.EiId = 60675; LiabilityCover.ExcessLCObj = new ExcessLC(); LiabilityCover.ExcessLCObj.EiId = 60681; List <SelectListItem> ExcList = new List <SelectListItem>(); ExcList.Add(new SelectListItem { Text = "$250", Value = "1" }); LiabilityCover.ExcessLCObj.ExcessList = ExcList; string policyid = null; bool policyinclusion = policyinclusions.Exists(p => p.Name == "Liability"); HttpClient hclient = new HttpClient(); string url = System.Configuration.ConfigurationManager.AppSettings["APIURL"]; hclient.BaseAddress = new Uri(url); hclient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); if (PcId != null && PcId.HasValue) { int?unid = null; int?profileid = null; if (Session["unId"] != null && Session["profileId"] != null) { unid = Convert.ToInt32(Session["unId"]); profileid = Convert.ToInt32(Session["profileId"]); } else { if (policyinclusions.Exists(p => p.Name == "Liability")) { unid = policyinclusions.Where(p => p.Name == "Liability").Select(p => p.UnId).FirstOrDefault(); profileid = policyinclusions.Where(p => p.Name == "Liability").Select(p => p.UnId).FirstOrDefault(); } else { return(RedirectToAction("VehicleDescription", "MotorCover", new { cid = cid, PcId = PcId })); } } LiabilityCover.NewSections = cmn.NewSectionP(policyinclusions); if (unid == null || unid == 0) { unid = unitdetails.SectionData.UnId; profileid = unitdetails.SectionData.ProfileUnId; } LiabilityCover.PolicyInclusion = policyinclusions; LiabilityCover.ExistingPolicyInclustions = policyinclusions; //int sectionId = policyinclusions.Where(p => p.Name == "Home Contents" && p.UnitNumber == unid).Select(p => p.UnId).FirstOrDefault(); //int? profileunid = policyinclusions.Where(p => p.Name == "Home Contents" && p.ProfileUnId == profileid).Select(p => p.ProfileUnId).FirstOrDefault(); HttpResponseMessage getunit = await hclient.GetAsync("UnitDetails?ApiKey=" + apikey + "&Action=Existing&SectionName=&SectionUnId=" + unid + "&ProfileUnId=" + profileid); var EmpResponse = getunit.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); } } else { int HprofileId = 0; int unid = 0; int profileid = 0; if (Session["unId"] != null && Session["profileId"] != null) { unid = Convert.ToInt32(Session["unId"]); profileid = Convert.ToInt32(Session["profileId"]); } if (Session["HProfileId"] != null) { HprofileId = Convert.ToInt32(Session["HprofileId"]); } if (HprofileId != null && HprofileId < 0 && unid != null && unid < 0) { HttpResponseMessage Res = await hclient.GetAsync("UnitDetails?ApiKey=" + apikey + "&Action=Existing&SectionName=&SectionUnId=" + unid + "&ProfileUnId=" + profileid); var EmpResponse = Res.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); if (unitdetails != null && unitdetails.SectionData != null) { Session["unId"] = unitdetails.SectionData.UnId; Session["profileId"] = unitdetails.SectionData.ProfileUnId; } } } else { HttpResponseMessage Res = await hclient.GetAsync("UnitDetails?ApiKey=" + apikey + "&Action=New&SectionName=Liability&SectionUnId=&ProfileUnId=" + HprofileId); var EmpResponse = Res.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); if (unitdetails != null && unitdetails.SectionData != null) { Session["unId"] = unitdetails.SectionData.UnId; Session["profileId"] = unitdetails.SectionData.ProfileUnId; if (Policyincllist != null && Policyincllist.Exists(p => p.name == "Liability")) { var policyhomelist = Policyincllist.FindAll(p => p.name == "Liability").ToList(); if (policyhomelist != null && policyhomelist.Count() > 0) { if (Policyincllist.FindAll(p => p.name == "Liability").Exists(p => p.UnitId == null)) { Policyincllist.FindAll(p => p.name == "Liability").Where(p => p.UnitId == null).First().UnitId = unitdetails.SectionData.UnId; } if (Policyincllist.FindAll(p => p.name == "Liability").Exists(p => p.ProfileId == null)) { Policyincllist.FindAll(p => p.name == "Liability").Where(p => p.ProfileId == null).First().ProfileId = unitdetails.SectionData.ProfileUnId; } } else { Policyincllist.FindAll(p => p.name == "Liability").First().UnitId = unitdetails.SectionData.UnId; Policyincllist.FindAll(p => p.name == "Liability").First().ProfileId = unitdetails.SectionData.ProfileUnId; } LiabilityCover.PolicyInclusions = Policyincllist; Session["Policyinclustions"] = Policyincllist; } } } } } if (unitdetails != null) { if (unitdetails.SectionData != null && unitdetails.SectionData.ValueData != null) { if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == LiabilityCover.ExcessLCObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == LiabilityCover.ExcessLCObj.EiId).Select(p => p.Value).FirstOrDefault(); LiabilityCover.ExcessLCObj.Excess = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == LiabilityCover.FarmliabiltyObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == LiabilityCover.FarmliabiltyObj.EiId).Select(p => p.Value).FirstOrDefault(); LiabilityCover.FarmliabiltyObj.Farmliabilty = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == LiabilityCover.LimitindemnityObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == LiabilityCover.LimitindemnityObj.EiId).Select(p => p.Value).FirstOrDefault(); LiabilityCover.LimitindemnityObj.Limitindemnity = Convert.ToInt32(val); } else { //if (Session["CoverAmount"]!=null) //{ LiabilityCover.LimitindemnityObj.Limitindemnity = 3000000; //} } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == LiabilityCover.FarmingactivitiesObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == LiabilityCover.FarmingactivitiesObj.EiId).Select(p => p.Value).FirstOrDefault(); LiabilityCover.FarmingactivitiesObj.Activities = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == LiabilityCover.FarmProduceObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == LiabilityCover.FarmProduceObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val == "1") { LiabilityCover.FarmProduceObj.Farmproduce = true; LiabilityCover.allproducts = "1"; } else if (val == "2") { LiabilityCover.FarmProduceObj.Farmproduce = true; LiabilityCover.allproducts = "2"; } else if (val == "1,2") { LiabilityCover.FarmProduceObj.Farmproduce = true; LiabilityCover.allproducts = "1,2"; } else if (val == "0") { LiabilityCover.FarmProduceObj.Farmproduce = false; LiabilityCover.allproducts = "0"; } } } } if (unitdetails != null && unitdetails.ReferralList != null) { LiabilityCover.ReferralList = unitdetails.ReferralList; LiabilityCover.ReferralList.Replace("  ", ""); LiabilityCover.Referels = new List <string>(); string[] delim = { "<br/>" }; string[] spltd = LiabilityCover.ReferralList.Split(delim, StringSplitOptions.None); if (spltd != null && spltd.Count() > 0) { for (int i = 0; i < spltd.Count(); i++) { LiabilityCover.Referels.Add(spltd[i].Replace("  ", " ")); } } } if (cid != null && cid.HasValue) { LiabilityCover.CustomerId = cid.Value; } if (PcId != null && PcId.HasValue) { LiabilityCover.PcId = PcId; } Session["Controller"] = "Liabilities"; Session["ActionName"] = "LiabilityCover"; return(View(LiabilityCover)); }
public async System.Threading.Tasks.Task <ActionResult> FarmDetails(int?cid, int?PcId) { string ApiKey = null; if (Session["ApiKey"] != null) { ApiKey = Session["ApiKey"].ToString(); } else { return(RedirectToAction("AgentLogin", "Login")); } var Policyincllist = new List <SessionModel>(); if (Session["Policyinclustions"] != null) { Policyincllist = Session["Policyinclustions"] as List <SessionModel>; if (Policyincllist != null) { if (Policyincllist != null) { if (Policyincllist.Exists(p => p.name == "Fixed Farm Property")) { } else if (Policyincllist.Exists(p => p.name == "Mobile Farm Property")) { return(RedirectToAction("FarmContents", "MobileFarm", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Burglary")) { return(RedirectToAction("Burglary", "FarmPolicyBurglary", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Farm Interuption")) { return(RedirectToAction("FarmInterruption", "FarmPolicyFarmInterruption", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Money")) { return(RedirectToAction("Money", "FarmPolicyMoney", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Farm Liability")) { return(RedirectToAction("FarmLiability", "FarmPolicyFarmLiability", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Machinery")) { return(RedirectToAction("Machinery", "FarmPolicyMachinery", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Electronics")) { return(RedirectToAction("Electronics", "FarmPolicyElectronics", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Transit")) { return(RedirectToAction("Transit", "FarmPolicyTransit", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Livestock")) { return(RedirectToAction("Livestock", "FarmPolicyLivestock", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Home Buildings")) { return(RedirectToAction("MainDetails", "FarmPolicyHome", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Home Contents")) { return(RedirectToAction("HomeContents", "FarmPolicyHomeContent", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Personal Liability")) { return(RedirectToAction("PersonalLiability", "FarmPolicyPersonalLiability", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Valuables")) { return(RedirectToAction("Valuables", "FarmPolicyValuables", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Motor")) { return(RedirectToAction("VehicleDescription", "FarmMotors", new { cid = cid, PcId = PcId })); } if (Policyincllist.Exists(p => p.name == "Fixed Farm Property")) { if (Session["unId"] == null && Session["profileId"] == null) { Session["unId"] = Policyincllist.Where(p => p.name == "Fixed Farm Property").Select(p => p.UnitId).First(); Session["profileId"] = Policyincllist.Where(p => p.name == "Fixed Farm Property").Select(p => p.ProfileId).First(); } } else { return(RedirectToAction("DisclosureDetails", "Disclosure", new { cid = cid, PcId = PcId })); } } } } else { RedirectToAction("PolicyInclustions", "Customer", new { CustomerId = cid, type = 1021 }); } ViewEditPolicyDetails unitdetails = new ViewEditPolicyDetails(); NewPolicyDetailsClass FarmDetailsmodel = new NewPolicyDetailsClass(); List <SelectListItem> constructionTypeList = new List <SelectListItem>(); constructionTypeList = FarmDetailsmodel.constructionType(); FarmDetails FarmDetails = new FarmDetails(); #region Farm location details FarmDetails.AddressObj = new AddressForFP(); FarmDetails.LocationObj = new LocatioForFP(); #endregion #region Farm Details FarmDetails.DescriptionFBObj = new DetailedDescription(); FarmDetails.DescriptionFBObj.EiId = 62255; FarmDetails.YearconstructedFBObj = new YearConstructedFB(); FarmDetails.YearconstructedFBObj.EiId = 62257; FarmDetails.ConstructionFBObj = new ConstructionFB(); FarmDetails.ConstructionFBObj.ConstructionHCList = constructionTypeList; FarmDetails.ConstructionFBObj.EiId = 62259; FarmDetails.ContaincoolroomObj = new ContainCoolroomFB(); FarmDetails.ContaincoolroomObj.EiId = 62261; FarmDetails.SuminsuredFBObj = new SumInsuredsFB(); FarmDetails.SuminsuredFBObj.EiId = 62263; FarmDetails.UnrepaireddamageObj = new UnrepairedDamageFS(); FarmDetails.UnrepaireddamageObj.EiId = 62309; FarmDetails.ExcessFBObj = new HarvestedCropsExcess(); FarmDetails.ExcessFBObj.EiId = 62315; FarmDetails.TypeoffarmObj = new typeoffarmInFP(); FarmDetails.TypeoffarmObj.EiId = 62005; FarmDetails.FarmsizeObj = new farmsizeInFP(); FarmDetails.FarmsizeObj.EiId = 62007; #endregion #region Farm Structures List <SelectListItem> ExcessRateList = new List <SelectListItem>(); ExcessRateList = FarmDetailsmodel.ExcessRateFS(); FarmDetails.SublimitObj = new SubLimitFarmFencing(); FarmDetails.SublimitObj.EiId = 62283; FarmDetails.TotalcoverObj = new TotalCoverFarmFencing(); FarmDetails.TotalcoverObj.EiId = 62287; FarmDetails.OtherstructurefcObj = new OtherFarmStructuresFC(); FarmDetails.OtherstructurefcObj.EiId = 62291; FarmDetails.RoofwallsObj = new RoofAndWallsFS(); FarmDetails.RoofwallsObj.EiId = 62297; //FarmStructures.UnrepaireddamageObj = new UnrepairedDamageFS(); //FarmStructures.UnrepaireddamageObj.EiId = 62309; FarmDetails.ExcesshcFSObj = new HarvestedCropsExcess(); FarmDetails.ExcesshcFSObj.ExcessHCList = ExcessRateList; FarmDetails.ExcesshcFSObj.EiId = 62315; #endregion #region HarvestedCrops List <SelectListItem> ExcessRateLists = new List <SelectListItem>(); ExcessRateLists = FarmDetailsmodel.excessRate(); FarmDetails.SuminsuredhcObj = new HarvestedCropsSumInsured(); FarmDetails.SuminsuredhcObj.EiId = 62329; FarmDetails.ExcesshcHCObj = new HarvestedCropsExcess(); FarmDetails.ExcesshcHCObj.ExcessHCList = ExcessRateLists; FarmDetails.ExcesshcHCObj.EiId = 62331; #endregion #region Interested Parties FarmDetails.PartynameObj = new InterestedPartyName(); FarmDetails.PartynameObj.EiId = 62345; FarmDetails.PartylocationObj = new InterestedPartyLocation(); FarmDetails.PartylocationObj.EiId = 62347; FarmDetails.TotalsuminsuredObj = new InterestedTotalSumInsured(); FarmDetails.TotalsuminsuredObj.EiId = 62349; #endregion if (cid != null) { ViewBag.cid = cid; FarmDetails.CustomerId = cid.Value; } else { ViewBag.cid = FarmDetails.CustomerId; } var db = new MasterDataEntities(); string policyid = null; HttpClient hclient = new HttpClient(); string url = System.Configuration.ConfigurationManager.AppSettings["APIURL"]; hclient.BaseAddress = new Uri(url); hclient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); int unid = 0; int profileid = 0; int Fprofileid = 0; if (Session["unId"] != null && Session["ProfileId"] != null) { unid = Convert.ToInt32(Session["unId"]); profileid = Convert.ToInt32(Session["profileId"]); } if (Session["FProfileId"] != null) { Fprofileid = Convert.ToInt32(Session["FprofileId"]); } if (Session["Policyinclustions"] != null) { FarmDetails.PolicyInclusions = Policyincllist; } if (PcId != null && PcId.HasValue && PcId > 0) { var policyinclusions = db.usp_GetUnit(null, PcId, null).ToList(); FarmDetails.PolicyInclusion = new List <usp_GetUnit_Result>(); if (PcId != null && PcId.HasValue && PcId > 0) { FarmDetails.PolicyInclusion = policyinclusions; } FarmDetails.PolicyInclusions = new List <SessionModel>(); if (PcId != null && PcId > 0) { policyid = PcId.ToString(); FarmDetails.PolicyId = policyid; } bool policyinclusion = policyinclusions.Exists(p => p.Name == "Fixed Farm Property"); if (policyinclusion == true && PcId != null && PcId.HasValue) { int sectionId = policyinclusions.Where(p => p.Name == "Fixed Farm Property" && p.UnitNumber == unid).Select(p => p.UnId).FirstOrDefault(); int?profileunid = policyinclusions.Where(p => p.Name == "Fixed Farm Property" && p.ProfileUnId == profileid).Select(p => p.ProfileUnId).FirstOrDefault(); HttpResponseMessage getunit = await hclient.GetAsync("UnitDetails?ApiKey=" + ApiKey + "&Action=Existing&SectionName=&SectionUnId=" + unid + "&ProfileUnId=" + profileid); var EmpResponse = getunit.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); } } } else { if (PcId == null && Session["unId"] == null && Session["profileId"] == null) { HttpResponseMessage Res = await hclient.GetAsync("UnitDetails?ApiKey=" + ApiKey + "&Action=New&SectionName=Fixed Farm Property&SectionUnId=&ProfileUnId="); var EmpResponse = Res.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); if (unitdetails != null && unitdetails.SectionData != null) { Session["unId"] = unitdetails.SectionData.UnId; Session["FprofileId"] = unitdetails.SectionData.ProfileUnId; Session["profileId"] = unitdetails.SectionData.ProfileUnId; if (Policyincllist != null && Policyincllist.Exists(p => p.name == "Fixed Farm Property")) { var policyhomelist = Policyincllist.FindAll(p => p.name == "Fixed Farm Property").ToList(); if (policyhomelist != null && policyhomelist.Count() > 0) { Policyincllist.FindAll(p => p.name == "Fixed Farm Property").Where(p => p.UnitId == null).First().UnitId = unitdetails.SectionData.UnId; Policyincllist.FindAll(p => p.name == "Fixed Farm Property").Where(p => p.ProfileId == null).First().ProfileId = unitdetails.SectionData.ProfileUnId; } else { Policyincllist.FindAll(p => p.name == "Fixed Farm Property").First().UnitId = unitdetails.SectionData.UnId; Policyincllist.FindAll(p => p.name == "Fixed Farm Property").First().ProfileId = unitdetails.SectionData.ProfileUnId; } } } } } else { if (PcId == null && Session["unId"] != null && (Session["profileId"] != null || (Fprofileid != null && Fprofileid < 0))) { if (profileid == null || profileid == 0) { profileid = Fprofileid; } HttpResponseMessage getunit = await hclient.GetAsync("UnitDetails?ApiKey=" + ApiKey + "&Action=Existing&SectionName=&SectionUnId=" + unid + "&ProfileUnId=" + profileid); var EmpResponse = getunit.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); if (unitdetails != null && unitdetails.SectionData != null) { Session["unId"] = unitdetails.SectionData.UnId; Session["FprofileId"] = unitdetails.SectionData.ProfileUnId; } } } } } if (unitdetails != null) { if (unitdetails.SectionData.AddressData != null) { FarmDetails.AddressObj = new AddressForFP(); FarmDetails.LocationObj = new LocatioForFP(); FarmDetails.AddressObj.Address = unitdetails.SectionData.AddressData.AddressLine1; FarmDetails.LocationObj.Location = unitdetails.SectionData.AddressData.State + ", " + unitdetails.SectionData.AddressData.Suburb + ", " + unitdetails.SectionData.AddressData.Postcode; //homebuilding.Postcode = unitdetails.AddressData.Select(p => p.Postcode).First(); // FarmDetails.Suburb = unitdetails.AddressData.Select(p => p.Suburb).First(); //for (int add = 0; add <= unitdetails.AddressData.Count(); add++) //{ // if(unitdetails.AddressData[add].Suburb=="LAMBTON") // { // homebuilding.Sub = "WA"; // } // // homebuilding.Sub = unitdetails.AddressData[add].Suburb; // homebuilding.LocationObj.Location = unitdetails.AddressData[add].AddressLine1; // homebuilding.Pincode = unitdetails.AddressData[add].Postcode; // break; //} } if (unitdetails.SectionData != null && unitdetails.SectionData.ValueData != null) { if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FarmDetails.DescriptionFBObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FarmDetails.DescriptionFBObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && !string.IsNullOrEmpty(val)) { FarmDetails.DescriptionFBObj.Description = val; } if (unitdetails.SectionData.ValueData.Select(p => p.Element.ElId == FarmDetails.DescriptionFBObj.EiId).Count() > 1) { List <ValueDatas> elmnts = new List <ValueDatas>(); var DescriptionFBList = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FarmDetails.DescriptionFBObj.EiId).Select(p => p.Element.ItId).ToList(); for (int i = 0; i < DescriptionFBList.Count(); i++) { ValueDatas vds = new ValueDatas(); vds.Element = new Elements(); vds.Element.ElId = 62255; vds.Element.ItId = DescriptionFBList[i]; vds.Value = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FarmDetails.DescriptionFBObj.EiId && p.Element.ItId == DescriptionFBList[i]).Select(p => p.Value).FirstOrDefault(); elmnts.Add(vds); } FarmDetails.DescriptionFBObjList = elmnts; } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FarmDetails.YearconstructedFBObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FarmDetails.YearconstructedFBObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && !string.IsNullOrEmpty(val)) { FarmDetails.YearconstructedFBObj.Year = val; } if (unitdetails.SectionData.ValueData.Select(p => p.Element.ElId == FarmDetails.YearconstructedFBObj.EiId).Count() > 1) { List <ValueDatas> elmnts = new List <ValueDatas>(); var YearconstructedFBList = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FarmDetails.YearconstructedFBObj.EiId).Select(p => p.Element.ItId).ToList(); for (int i = 0; i < YearconstructedFBList.Count(); i++) { ValueDatas vds = new ValueDatas(); vds.Element = new Elements(); vds.Element.ElId = 62257; vds.Element.ItId = YearconstructedFBList[i]; vds.Value = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FarmDetails.YearconstructedFBObj.EiId && p.Element.ItId == YearconstructedFBList[i]).Select(p => p.Value).FirstOrDefault(); elmnts.Add(vds); } FarmDetails.YearconstructedFBObjList = elmnts; } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FarmDetails.ConstructionFBObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FarmDetails.ConstructionFBObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && !string.IsNullOrEmpty(val)) { FarmDetails.ConstructionFBObj.Construction = val; } if (unitdetails.SectionData.ValueData.Select(p => p.Element.ElId == FarmDetails.ConstructionFBObj.EiId).Count() > 1) { List <ValueDatas> elmnts = new List <ValueDatas>(); var ConstructionFBList = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FarmDetails.ConstructionFBObj.EiId).Select(p => p.Element.ItId).ToList(); for (int i = 0; i < ConstructionFBList.Count(); i++) { ValueDatas vds = new ValueDatas(); vds.Element = new Elements(); vds.Element.ElId = 62259; vds.Element.ItId = ConstructionFBList[i]; vds.Value = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FarmDetails.ConstructionFBObj.EiId && p.Element.ItId == ConstructionFBList[i]).Select(p => p.Value).FirstOrDefault(); elmnts.Add(vds); } FarmDetails.ConstructionFBObjList = elmnts; } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FarmDetails.ContaincoolroomObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FarmDetails.ContaincoolroomObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null) { FarmDetails.ContaincoolroomObj.Coolroom = true; } else { FarmDetails.ContaincoolroomObj.Coolroom = false; } if (unitdetails.SectionData.ValueData.Select(p => p.Element.ElId == FarmDetails.ContaincoolroomObj.EiId).Count() > 1) { List <ValueDatas> elmnts = new List <ValueDatas>(); var ContaincoolroomFBList = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FarmDetails.ContaincoolroomObj.EiId).Select(p => p.Element.ItId).ToList(); for (int i = 0; i < ContaincoolroomFBList.Count(); i++) { ValueDatas vds = new ValueDatas(); vds.Element = new Elements(); vds.Element.ElId = 62261; vds.Element.ItId = ContaincoolroomFBList[i]; vds.Value = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FarmDetails.ContaincoolroomObj.EiId && p.Element.ItId == ContaincoolroomFBList[i]).Select(p => p.Value).FirstOrDefault(); elmnts.Add(vds); } FarmDetails.ContaincoolroomFBObjList = elmnts; } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FarmDetails.SuminsuredFBObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FarmDetails.SuminsuredFBObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && !string.IsNullOrEmpty(val)) { FarmDetails.SuminsuredFBObj.Suminsured = val; } if (unitdetails.SectionData.ValueData.Select(p => p.Element.ElId == FarmDetails.SuminsuredFBObj.EiId).Count() > 1) { List <ValueDatas> elmnts = new List <ValueDatas>(); var SuminsuredFBList = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FarmDetails.SuminsuredFBObj.EiId).Select(p => p.Element.ItId).ToList(); for (int i = 0; i < SuminsuredFBList.Count(); i++) { ValueDatas vds = new ValueDatas(); vds.Element = new Elements(); vds.Element.ElId = 62263; vds.Element.ItId = SuminsuredFBList[i]; vds.Value = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FarmDetails.SuminsuredFBObj.EiId && p.Element.ItId == SuminsuredFBList[i]).Select(p => p.Value).FirstOrDefault(); elmnts.Add(vds); } FarmDetails.SuminsuredFBObjList = elmnts; } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FarmDetails.ExcessFBObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FarmDetails.ExcessFBObj.EiId).Select(p => p.Value).FirstOrDefault(); FarmDetails.ExcessFBObj.Excess = val; } if (unitdetails.ProfileData.ValueData.Exists(p => p.Element.ElId == FarmDetails.FarmsizeObj.EiId)) { string val = unitdetails.ProfileData.ValueData.Where(p => p.Element.ElId == FarmDetails.FarmsizeObj.EiId).Select(p => p.Value).FirstOrDefault(); FarmDetails.FarmsizeObj.Farmsize = val; } if (unitdetails.ProfileData.ValueData.Exists(p => p.Element.ElId == FarmDetails.TypeoffarmObj.EiId)) { string val = unitdetails.ProfileData.ValueData.Where(p => p.Element.ElId == FarmDetails.TypeoffarmObj.EiId).Select(p => p.Value).FirstOrDefault(); FarmDetails.TypeoffarmObj.typeoffarm = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FarmDetails.ExcesshcFSObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FarmDetails.ExcesshcFSObj.EiId).Select(p => p.Value).FirstOrDefault(); FarmDetails.ExcesshcFSObj.Excess = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FarmDetails.ExcesshcHCObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FarmDetails.ExcesshcHCObj.EiId).Select(p => p.Value).FirstOrDefault(); FarmDetails.ExcesshcHCObj.Excess = val; } //if (unitdetails.ProfileData.ValueData.Exists(p => p.Element.ElId == FarmDetails.ExcesshcObjH.EiId)) //{ // string val = unitdetails.ProfileData.ValueData.Where(p => p.Element.ElId == FarmDetails.ExcesshcObjH.EiId).Select(p => p.Value).FirstOrDefault(); // FarmDetails.ExcesshcObjH.Excess = val; //} if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FarmDetails.OtherstructurefcObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FarmDetails.OtherstructurefcObj.EiId).Select(p => p.Value).FirstOrDefault(); FarmDetails.OtherstructurefcObj.Otherstructure = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FarmDetails.PartynameObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FarmDetails.PartynameObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && !string.IsNullOrEmpty(val)) { FarmDetails.PartynameObj.Name = val; } if (unitdetails.SectionData.ValueData.Select(p => p.Element.ElId == FarmDetails.PartynameObj.EiId).Count() > 1) { List <ValueDatas> elmnts = new List <ValueDatas>(); var PartynameFBList = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FarmDetails.PartynameObj.EiId).Select(p => p.Element.ItId).ToList(); for (int i = 0; i < PartynameFBList.Count(); i++) { ValueDatas vds = new ValueDatas(); vds.Element = new Elements(); vds.Element.ElId = 62345; vds.Element.ItId = PartynameFBList[i]; vds.Value = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FarmDetails.PartynameObj.EiId && p.Element.ItId == PartynameFBList[i]).Select(p => p.Value).FirstOrDefault(); elmnts.Add(vds); } FarmDetails.PartynameObjList = elmnts; } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FarmDetails.PartylocationObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FarmDetails.PartylocationObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && !string.IsNullOrEmpty(val)) { FarmDetails.PartylocationObj.Location = val; } if (unitdetails.SectionData.ValueData.Select(p => p.Element.ElId == FarmDetails.PartylocationObj.EiId).Count() > 1) { List <ValueDatas> elmnts = new List <ValueDatas>(); var PartylocationFBList = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FarmDetails.PartylocationObj.EiId).Select(p => p.Element.ItId).ToList(); for (int i = 0; i < PartylocationFBList.Count(); i++) { ValueDatas vds = new ValueDatas(); vds.Element = new Elements(); vds.Element.ElId = 62347; vds.Element.ItId = PartylocationFBList[i]; vds.Value = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FarmDetails.PartylocationObj.EiId && p.Element.ItId == PartylocationFBList[i]).Select(p => p.Value).FirstOrDefault(); elmnts.Add(vds); } FarmDetails.PartylocationObjList = elmnts; } } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FarmDetails.RoofwallsObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FarmDetails.RoofwallsObj.EiId).Select(p => p.Value).FirstOrDefault(); FarmDetails.RoofwallsObj.Roofwalls = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FarmDetails.SublimitObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FarmDetails.SublimitObj.EiId).Select(p => p.Value).FirstOrDefault(); FarmDetails.SublimitObj.Sublimit = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FarmDetails.SuminsuredhcObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FarmDetails.SuminsuredhcObj.EiId).Select(p => p.Value).FirstOrDefault(); FarmDetails.SuminsuredhcObj.Suminsured = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FarmDetails.TotalcoverObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FarmDetails.TotalcoverObj.EiId).Select(p => p.Value).FirstOrDefault(); FarmDetails.TotalcoverObj.Totalcover = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FarmDetails.UnrepaireddamageObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FarmDetails.UnrepaireddamageObj.EiId).Select(p => p.Value).FirstOrDefault(); FarmDetails.UnrepaireddamageObj.Unrepaireddamage = val; } } } if (cid != null && cid.HasValue && cid > 0) { FarmDetails.CustomerId = cid.Value; } if (PcId != null && PcId > 0) { FarmDetails.PcId = PcId; } Session["Controller"] = "FarmPolicyProperty"; Session["ActionName"] = "FarmDetails"; return(View(FarmDetails)); }
public async System.Threading.Tasks.Task <ActionResult> DisclosureDetails(int?cid, int?PcId) { string apikey = null; if (Session["Apikey"] != null) { apikey = Session["Apikey"].ToString(); } else { return(RedirectToAction("AgentLogin", "Login")); } DisclosureDetails DisclosureDetails = new DisclosureDetails(); DisclosureDetails.PrId = Convert.ToInt32(Session["PrId"]); if (cid.HasValue && cid > 0) { DisclosureDetails.CustomerId = cid.Value; } var db = new MasterDataEntities(); DisclosureDetails.PolicyInclusions = new List <SessionModel>(); var Policyincllist = Session["Policyinclustions"] as List <SessionModel>; DisclosureDetails.PolicyInclusions = Policyincllist; var policyinclusions = new List <usp_GetUnit_Result>(); if (PcId != null && PcId > 0) { policyinclusions = db.usp_GetUnit(null, PcId, null).ToList(); DisclosureDetails.PolicyInclusion = new List <usp_GetUnit_Result>(); DisclosureDetails.PolicyInclusion = policyinclusions; } DisclosureDetails.PcId = PcId; DisclosureDetails.PreviousinsurerObj = new PreviousInsurer(); DisclosureDetails.PreviousinsurerObj.EiId = 2019; DisclosureDetails.RenewpolicyObj = new RenewPolicy(); DisclosureDetails.RenewpolicyObj.EiId = 2007; DisclosureDetails.CriminaloffenceObj = new CriminalOffence(); DisclosureDetails.CriminaloffenceObj.EiId = 2008; DisclosureDetails.PrisonsentenceObj = new PrisonSentence(); DisclosureDetails.PrisonsentenceObj.EiId = 2009; DisclosureDetails.UndischargedObj = new Undischarged(); DisclosureDetails.UndischargedObj.EiId = 2010; DisclosureDetails.BankruptObj = new Bankrupts(); DisclosureDetails.BankruptObj.EiId = 2011; DisclosureDetails.DateObj = new DischargeDate(); DisclosureDetails.DateObj.EiId = 2027; DisclosureDetails.ImmediatedangerObj = new ImmediateDanger(); DisclosureDetails.ImmediatedangerObj.EiId = 2016; DisclosureDetails.DutydisclosureObj = new DutyOfDisclosure(); DisclosureDetails.DutydisclosureObj.EiId = 2018; DisclosureDetails.DetailsboxObj = new DetailsBox(); DisclosureDetails.DetailsboxObj.EiId = 415; ViewEditPolicyDetails unitdetails = new ViewEditPolicyDetails(); HttpClient hclient = new HttpClient(); string url = System.Configuration.ConfigurationManager.AppSettings["APIURL"]; hclient.BaseAddress = new Uri(url); hclient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage getunit = await hclient.GetAsync("DisclosureDetails?ApiKey=" + apikey); var EmpResponse = getunit.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); if (unitdetails.ValueData.Exists(p => p.Element.ElId == DisclosureDetails.DetailsboxObj.EiId)) { string val = unitdetails.ValueData.Where(p => p.Element.ElId == DisclosureDetails.DetailsboxObj.EiId).Select(p => p.Value).FirstOrDefault(); DisclosureDetails.DetailsboxObj.Details = val; } if (unitdetails.ValueData.Exists(p => p.Element.ElId == DisclosureDetails.BankruptObj.EiId)) { string val = unitdetails.ValueData.Where(p => p.Element.ElId == DisclosureDetails.BankruptObj.EiId).Select(p => p.Value).FirstOrDefault(); DisclosureDetails.BankruptObj.Bankrupt = val; } if (unitdetails.ValueData.Exists(p => p.Element.ElId == DisclosureDetails.CriminaloffenceObj.EiId)) { string val = unitdetails.ValueData.Where(p => p.Element.ElId == DisclosureDetails.CriminaloffenceObj.EiId).Select(p => p.Value).FirstOrDefault(); DisclosureDetails.CriminaloffenceObj.Offence = val; } if (unitdetails.ValueData.Exists(p => p.Element.ElId == DisclosureDetails.DateObj.EiId)) { string val = unitdetails.ValueData.Where(p => p.Element.ElId == DisclosureDetails.DateObj.EiId).Select(p => p.Value).FirstOrDefault(); DisclosureDetails.DateObj.Date = val; } if (unitdetails.ValueData.Exists(p => p.Element.ElId == DisclosureDetails.DutydisclosureObj.EiId)) { string val = unitdetails.ValueData.Where(p => p.Element.ElId == DisclosureDetails.DutydisclosureObj.EiId).Select(p => p.Value).FirstOrDefault(); DisclosureDetails.DutydisclosureObj.Dutydisclosure = val; } if (unitdetails.ValueData.Exists(p => p.Element.ElId == DisclosureDetails.ImmediatedangerObj.EiId)) { string val = unitdetails.ValueData.Where(p => p.Element.ElId == DisclosureDetails.ImmediatedangerObj.EiId).Select(p => p.Value).FirstOrDefault(); DisclosureDetails.ImmediatedangerObj.Danger = val; } if (unitdetails.ValueData.Exists(p => p.Element.ElId == DisclosureDetails.PreviousinsurerObj.EiId)) { string val = unitdetails.ValueData.Where(p => p.Element.ElId == DisclosureDetails.PreviousinsurerObj.EiId).Select(p => p.Value).FirstOrDefault(); DisclosureDetails.PreviousinsurerObj.Pinsurer = val; } if (unitdetails.ValueData.Exists(p => p.Element.ElId == DisclosureDetails.PrisonsentenceObj.EiId)) { string val = unitdetails.ValueData.Where(p => p.Element.ElId == DisclosureDetails.PrisonsentenceObj.EiId).Select(p => p.Value).FirstOrDefault(); DisclosureDetails.PrisonsentenceObj.Sentence = val; } if (unitdetails.ValueData.Exists(p => p.Element.ElId == DisclosureDetails.RenewpolicyObj.EiId)) { string val = unitdetails.ValueData.Where(p => p.Element.ElId == DisclosureDetails.RenewpolicyObj.EiId).Select(p => p.Value).FirstOrDefault(); DisclosureDetails.RenewpolicyObj.Rpolicy = val; } if (unitdetails.ValueData.Exists(p => p.Element.ElId == DisclosureDetails.UndischargedObj.EiId)) { string val = unitdetails.ValueData.Where(p => p.Element.ElId == DisclosureDetails.UndischargedObj.EiId).Select(p => p.Value).FirstOrDefault(); DisclosureDetails.UndischargedObj.Undischarge = val; } } if (Session["PrId"] != null) { DisclosureDetails.PrId = Convert.ToInt32(Session["PrId"]); } return(View(DisclosureDetails)); }
public async System.Threading.Tasks.Task <ActionResult> FarmLiability(int?cid, int?PcId) { NewPolicyDetailsClass commonModel = new NewPolicyDetailsClass(); List <SelectListItem> GLLimitOfIndemnity = new List <SelectListItem>(); GLLimitOfIndemnity = commonModel.LimitOfIndemnity(); List <SelectListItem> excessToPayFarmLiability = new List <SelectListItem>(); excessToPayFarmLiability = commonModel.excessRate(); List <SelectListItem> GLTypeOfAccommodation = new List <SelectListItem>(); GLTypeOfAccommodation = commonModel.TypeOfAccommodation(); FPFarmliability FPFarmliability = new FPFarmliability(); var db = new MasterDataEntities(); if (cid != null) { ViewBag.cid = cid; FPFarmliability.CustomerId = cid.Value; } else { ViewBag.cid = FPFarmliability.CustomerId; } ViewEditPolicyDetails unitdetails = new ViewEditPolicyDetails(); NewPolicyDetailsClass commonmethods = new NewPolicyDetailsClass(); string apikey = null; if (Session["apiKey"] != null) { apikey = Session["apiKey"].ToString(); FPFarmliability.ApiKey = Session["apiKey"].ToString(); } else { return(RedirectToAction("AgentLogin", "Login")); } string policyid = null; List <SessionModel> PolicyInclustions = new List <SessionModel>(); if (PcId != null && PcId.HasValue && PcId > 0) { policyid = PcId.ToString(); FPFarmliability.PolicyId = policyid; } else if (Session["Policyinclustions"] != null) { #region Policy Selected or not testing FPFarmliability.PolicyInclusions = new List <SessionModel>(); var Policyincllist = Session["Policyinclustions"] as List <SessionModel>; FPFarmliability.PolicyInclusions = Policyincllist; if (Policyincllist != null) { if (Policyincllist.Exists(p => p.name == "Farm Liability")) { } else if (Policyincllist.Exists(p => p.name == "Machinery")) { return(RedirectToAction("Machinery", "FarmPolicyMachinery", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Electronics")) { return(RedirectToAction("Electronics", "FarmPolicyElectronics", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Transit")) { return(RedirectToAction("Transit", "FarmPolicyTransit", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Livestock")) { return(RedirectToAction("Livestock", "FarmPolicyLivestock", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Home Buildings")) { return(RedirectToAction("MainDetails", "FarmPolicyHome", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Home Contents")) { return(RedirectToAction("HomeContents", "FarmPolicyHomeContent", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Personal Liability")) { return(RedirectToAction("PersonalLiability", "FarmPolicyPersonalLiability", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Valuables")) { return(RedirectToAction("Valuables", "FarmPolicyValuables", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Motor")) { return(RedirectToAction("VehicleDescription", "FarmMotors", new { cid = cid, PcId = PcId })); } if (Policyincllist.Exists(p => p.name == "Farm Liability")) { if (Session["unId"] == null && Session["profileId"] == null) { Session["unId"] = Policyincllist.Where(p => p.name == "Farm Liability").Select(p => p.UnitId).First(); Session["profileId"] = Policyincllist.Where(p => p.name == "Farm Liability").Select(p => p.ProfileId).First(); } } else { return(RedirectToAction("DisclosureDetails", "Disclosure", new { cid = cid, PcId = PcId })); } } #endregion } FPFarmliability.GenLiabilityLimitOfIndemnityFPObj = new GenLiabilityLimitOfIndemnityFP(); FPFarmliability.GenLiabilityLimitOfIndemnityFPObj.GLLimitOfIndemnityFPList = GLLimitOfIndemnity; FPFarmliability.GenLiabilityLimitOfIndemnityFPObj.EiId = 62871; FPFarmliability.ProdLiabilityLimitOfIndemnityFPObj = new ProdLiabilityLimitOfIndemnityFP(); FPFarmliability.ProdLiabilityLimitOfIndemnityFPObj.EiId = 62875; FPFarmliability.ListOfProductsSoldFPObj = new ListOfProductsSoldFP(); FPFarmliability.ListOfProductsSoldFPObj.EiId = 62877; FPFarmliability.OptPayingGuestFP = new OptPayingGuestFP(); FPFarmliability.OptPayingGuestFP.EiId = 62883; FPFarmliability.TypeOfAccomGuestsStayingInFPObj = new TypeOfAccomGuestsStayingInFP(); FPFarmliability.TypeOfAccomGuestsStayingInFPObj.TypeOfAccommodationGuestsStayingInList = GLTypeOfAccommodation; FPFarmliability.TypeOfAccomGuestsStayingInFPObj.EiId = 62887; FPFarmliability.DescriptionOfAccommodationFPObj = new DescriptionOfAccommodationFP(); FPFarmliability.DescriptionOfAccommodationFPObj.EiId = 62889; FPFarmliability.OptAccomComplyRegulationFPObj = new OptAccomComplyRegulationFP(); FPFarmliability.OptAccomComplyRegulationFPObj.EiId = 62899; FPFarmliability.OptHolidayFarmsFPObj = new OptHolidayFarmsFP(); FPFarmliability.OptHolidayFarmsFPObj.EiId = 62901; FPFarmliability.ExcessFPFarmLiabilityObj = new ExcessFPFarmLiability(); FPFarmliability.ExcessFPFarmLiabilityObj.ExcessList = excessToPayFarmLiability; FPFarmliability.ExcessFPFarmLiabilityObj.EiId = 62907; FPFarmliability.AddressObj = new AddressFLAddress(); FPFarmliability.AddressObj.EiId = 0; HttpClient hclient = new HttpClient(); string url = System.Configuration.ConfigurationManager.AppSettings["APIURL"]; hclient.BaseAddress = new Uri(url); hclient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); int unid = Convert.ToInt32(Session["unId"]); int?profileid = Convert.ToInt32(Session["profileId"]); if (PcId != null && PcId.HasValue) { var policyinclusions = db.usp_GetUnit(null, PcId, null).ToList(); FPFarmliability.PolicyInclusion = new List <usp_GetUnit_Result>(); if (PcId != null && PcId.HasValue && PcId > 0) { FPFarmliability.PolicyInclusion = policyinclusions; } FPFarmliability.PolicyInclusions = new List <SessionModel>(); if (PcId != null && PcId > 0) { policyid = PcId.ToString(); FPFarmliability.PolicyId = policyid; } bool policyinclusion = policyinclusions.Exists(p => p.Name == "Farm Liability"); if (policyinclusion == true && PcId != null && PcId.HasValue) { unid = policyinclusions.Where(p => p.Name == "Farm Liability").Select(p => p.UnId).FirstOrDefault(); profileid = policyinclusions.Where(p => p.Name == "Farm Liability").Select(p => p.ProfileUnId).FirstOrDefault(); HttpResponseMessage getunit = await hclient.GetAsync("UnitDetails?ApiKey=" + apikey + "&Action=Existing&SectionName=&SectionUnId=" + unid + "&ProfileUnId=" + profileid); var EmpResponse = getunit.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); } } else { return(RedirectToAction("Machinery", "FarmPolicyMachinery", new { cid = cid, PcId = PcId })); } } else { if (PcId == null && Session["unId"] == null && Session["profileId"] == null) { HttpResponseMessage Res = await hclient.GetAsync("UnitDetails?ApiKey=" + apikey + "&Action=New&SectionName=Farm Liability&SectionUnId=&ProfileUnId=0"); var EmpResponse = Res.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); if (unitdetails != null && unitdetails.SectionData != null) { if (unitdetails != null && unitdetails.ErrorMessage != null && unitdetails.ErrorMessage.Count() > 0 && unitdetails.Status == "Failure") { bool exists = FPFarmliability.PolicyInclusions.Exists(p => p.name == "Farm Liability"); if (exists == true) { List <SessionModel> values = new List <SessionModel>(); values = (List <SessionModel>)Session["Policyinclustions"]; for (int k = 0; k < values.Count(); k++) { if (values[k].name == "Farm Liability" && values[k].UnitId == null && values[k].ProfileId == null) { values.RemoveAt(k); } } Session["Policyinclustions"] = values; } } Session["unId"] = unitdetails.SectionData.UnId; Session["profileId"] = unitdetails.SectionData.ProfileUnId; } } } else if (PcId == null && Session["unId"] != null && Session["profileId"] != null) { HttpResponseMessage getunit = await hclient.GetAsync("UnitDetails?ApiKey=" + apikey + "&Action=Existing&SectionName=&SectionUnId=" + unid + "&ProfileUnId=" + profileid); var EmpResponse = getunit.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); if (unitdetails != null && unitdetails.SectionData != null) { Session["unId"] = unitdetails.SectionData.UnId; Session["profileId"] = unitdetails.SectionData.ProfileUnId; } } } } if (unitdetails != null) { if (unitdetails.SectionData != null && unitdetails.SectionData.ValueData != null) { if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPFarmliability.GenLiabilityLimitOfIndemnityFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPFarmliability.GenLiabilityLimitOfIndemnityFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPFarmliability.GenLiabilityLimitOfIndemnityFPObj.LimitOfIndemnity = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPFarmliability.ProdLiabilityLimitOfIndemnityFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPFarmliability.ProdLiabilityLimitOfIndemnityFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPFarmliability.ProdLiabilityLimitOfIndemnityFPObj.LimitOfIndemnity = val; } //if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPFarmliability.ListOfProductsSoldFPObj.EiId)) //{ // string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPFarmliability.ListOfProductsSoldFPObj.EiId).Select(p => p.Value).FirstOrDefault(); // FPFarmliability.ListOfProductsSoldFPObj.ListOfProductsSold = val; //} if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPFarmliability.OptPayingGuestFP.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPFarmliability.OptPayingGuestFP.EiId).Select(p => p.Value).FirstOrDefault(); FPFarmliability.OptPayingGuestFP.PayingGuestOption = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPFarmliability.TypeOfAccomGuestsStayingInFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPFarmliability.TypeOfAccomGuestsStayingInFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPFarmliability.TypeOfAccomGuestsStayingInFPObj.TypeOfAccommodation = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPFarmliability.DescriptionOfAccommodationFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPFarmliability.DescriptionOfAccommodationFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPFarmliability.DescriptionOfAccommodationFPObj.DescOfAccommodation = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPFarmliability.OptAccomComplyRegulationFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPFarmliability.OptAccomComplyRegulationFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPFarmliability.OptAccomComplyRegulationFPObj.AccomComplyRegulations = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPFarmliability.OptHolidayFarmsFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPFarmliability.OptHolidayFarmsFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPFarmliability.OptHolidayFarmsFPObj.HolidayFarms = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPFarmliability.ExcessFPFarmLiabilityObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPFarmliability.ExcessFPFarmLiabilityObj.EiId).Select(p => p.Value).FirstOrDefault(); FPFarmliability.ExcessFPFarmLiabilityObj.Excess = val; } } if (unitdetails.SectionData != null && unitdetails.SectionData.AddressData != null) { if (unitdetails.SectionData.AddressData != null) { FPFarmliability.AddressObj.Address = unitdetails.SectionData.AddressData.AddressLine1 + ", " + unitdetails.SectionData.AddressData.Suburb + " ," + unitdetails.SectionData.AddressData.State + ", " + unitdetails.SectionData.AddressData.Postcode; } } } if (cid != null && cid.HasValue) { FPFarmliability.CustomerId = cid.Value; } if (PcId != null && PcId.HasValue) { FPFarmliability.PcId = PcId; } Session["Controller"] = "FarmPolicyFarmLiability"; Session["ActionName"] = "FarmLiability"; return(View(FPFarmliability)); }
public async System.Threading.Tasks.Task <ActionResult> FarmInterruption(int?cid, int?PcId) { NewPolicyDetailsClass commonModel = new NewPolicyDetailsClass(); List <SelectListItem> ExcessToPay = new List <SelectListItem>(); ExcessToPay = commonModel.excessRate(); FPFarmInterruption FPFarmInterruption = new FPFarmInterruption(); string ApiKey = null; if (Session["ApiKey"] != null) { ApiKey = Session["ApiKey"].ToString(); } else { return(RedirectToAction("AgentLogin", "Login")); } var Policyincllist = new List <SessionModel>(); if (Session["Policyinclustions"] != null) { Policyincllist = Session["Policyinclustions"] as List <SessionModel>; if (Policyincllist != null) { if (Policyincllist != null) { if (Policyincllist.Exists(p => p.name == "Farm Interuption")) { } else if (Policyincllist.Exists(p => p.name == "Money")) { return(RedirectToAction("Money", "FarmPolicyMoney", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Farm Liability")) { return(RedirectToAction("FarmLiability", "FarmPolicyFarmLiability", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Machinery")) { return(RedirectToAction("Machinery", "FarmPolicyMachinery", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Electronics")) { return(RedirectToAction("Electronics", "FarmPolicyElectronics", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Transit")) { return(RedirectToAction("Transit", "FarmPolicyTransit", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Livestock")) { return(RedirectToAction("Livestock", "FarmPolicyLivestock", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Home Buildings")) { return(RedirectToAction("MainDetails", "FarmPolicyHome", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Home Contents")) { return(RedirectToAction("HomeContents", "FarmPolicyHomeContent", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Personal Liability")) { return(RedirectToAction("PersonalLiability", "FarmPolicyPersonalLiability", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Valuables")) { return(RedirectToAction("Valuables", "FarmPolicyValuables", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Motor")) { return(RedirectToAction("VehicleDescription", "FarmMotors", new { cid = cid, PcId = PcId })); } if (Policyincllist.Exists(p => p.name == "Farm Interuption")) { if (Session["unId"] == null && Session["profileId"] == null) { Session["unId"] = Policyincllist.Where(p => p.name == "Farm Interuption").Select(p => p.UnitId).First(); Session["profileId"] = Policyincllist.Where(p => p.name == "Farm Interuption").Select(p => p.ProfileId).First(); } } else { return(RedirectToAction("DisclosureDetails", "Disclosure", new { cid = cid, PcId = PcId })); } } } } else { RedirectToAction("PolicyInclustions", "Customer", new { CustomerId = cid, type = 1021 }); } ViewEditPolicyDetails unitdetails = new ViewEditPolicyDetails(); NewPolicyDetailsClass FarmDetailsmodel = new NewPolicyDetailsClass(); if (cid != null) { ViewBag.cid = cid; FPFarmInterruption.CustomerId = cid.Value; } FPFarmInterruption.ExpFarmIncomeNextYearFPObj = new ExpFarmIncomeNextYearFP(); FPFarmInterruption.ExpFarmIncomeNextYearFPObj.EiId = 62679; FPFarmInterruption.OptFarmIncomeIndemnityPerFPObj = new OptFarmIncomeIndemnityPerFP(); FPFarmInterruption.OptFarmIncomeIndemnityPerFPObj.EiId = 62681; FPFarmInterruption.SumInsuredFarmIncomeFPObj = new SumInsuredFarmIncomeFP(); FPFarmInterruption.SumInsuredFarmIncomeFPObj.EiId = 62683; FPFarmInterruption.ExcessFarmIncomeFPObj = new ExcessFarmIncomeFP(); FPFarmInterruption.ExcessFarmIncomeFPObj.ExcessList = ExcessToPay; FPFarmInterruption.ExcessFarmIncomeFPObj.EiId = 62685; FPFarmInterruption.ExpAgistIncomeNextYearFPObj = new ExpAgistIncomeNextYearFP(); FPFarmInterruption.ExpAgistIncomeNextYearFPObj.EiId = 62691; FPFarmInterruption.OptAgistIncomeIndemnityPerFPObj = new OptAgistIncomeIndemnityPerFP(); FPFarmInterruption.OptAgistIncomeIndemnityPerFPObj.EiId = 62693; FPFarmInterruption.SumInsuredAgistIncomeFPObj = new SumInsuredAgistIncomeFP(); FPFarmInterruption.SumInsuredAgistIncomeFPObj.EiId = 62695; FPFarmInterruption.ExcessAgistIncomeFPObj = new ExcessAgistIncomeFP(); FPFarmInterruption.ExcessAgistIncomeFPObj.ExcessList = ExcessToPay; FPFarmInterruption.ExcessAgistIncomeFPObj.EiId = 62697; FPFarmInterruption.OptExtraCostIndemnityPerFPObj = new OptExtraCostIndemnityPerFP(); FPFarmInterruption.OptExtraCostIndemnityPerFPObj.EiId = 62711; FPFarmInterruption.SumInsuredExtraCostFPObj = new SumInsuredExtraCostFP(); FPFarmInterruption.SumInsuredExtraCostFPObj.EiId = 62713; FPFarmInterruption.ExcessExtraCostFPObj = new ExcessExtraCostFP(); FPFarmInterruption.ExcessExtraCostFPObj.ExcessList = ExcessToPay; FPFarmInterruption.ExcessExtraCostFPObj.EiId = 62715; FPFarmInterruption.SumInsuredShearingDelayFPObj = new SumInsuredShearingDelayFP(); FPFarmInterruption.SumInsuredShearingDelayFPObj.EiId = 62721; FPFarmInterruption.ExcessShearingDelayFPObj = new ExcessShearingDelayFP(); FPFarmInterruption.ExcessShearingDelayFPObj.ExcessList = ExcessToPay; FPFarmInterruption.ExcessShearingDelayFPObj.EiId = 62723; FPFarmInterruption.AddressObj = new AddressINAddress(); FPFarmInterruption.AddressObj.EiId = 0; var db = new MasterDataEntities(); string policyid = null; if (cid != null) { ViewBag.cid = cid; FPFarmInterruption.CustomerId = cid.Value; } else { ViewBag.cid = FPFarmInterruption.CustomerId; } HttpClient hclient = new HttpClient(); string url = System.Configuration.ConfigurationManager.AppSettings["APIURL"]; hclient.BaseAddress = new Uri(url); hclient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); int unid = 0; int profileid = 0; int Fprofileid = 0; if (Session["unId"] != null && Session["ProfileId"] != null) { unid = Convert.ToInt32(Session["unId"]); profileid = Convert.ToInt32(Session["profileId"]); } if (Session["FProfileId"] != null) { Fprofileid = Convert.ToInt32(Session["FprofileId"]); } if (Session["Policyinclustions"] != null) { FPFarmInterruption.PolicyInclusions = Policyincllist; } if (PcId != null && PcId.HasValue && PcId > 0) { var policyinclusions = db.usp_GetUnit(null, PcId, null).ToList(); FPFarmInterruption.PolicyInclusion = new List <usp_GetUnit_Result>(); if (PcId != null && PcId.HasValue && PcId > 0) { FPFarmInterruption.PolicyInclusion = policyinclusions; } FPFarmInterruption.PolicyInclusions = new List <SessionModel>(); if (PcId != null && PcId > 0) { policyid = PcId.ToString(); FPFarmInterruption.PolicyId = policyid; } bool policyinclusion = policyinclusions.Exists(p => p.Name == "Farm Interruption"); if (policyinclusion == true && PcId != null && PcId.HasValue) { int sectionId = policyinclusions.Where(p => p.Name == "Farm Interruption").Select(p => p.UnId).FirstOrDefault(); int?profileunid = policyinclusions.Where(p => p.Name == "Farm Interruption").Select(p => p.ProfileUnId).FirstOrDefault(); HttpResponseMessage getunit = await hclient.GetAsync("UnitDetails?ApiKey=" + ApiKey + "&Action=Existing&SectionName=&SectionUnId=" + sectionId + "&ProfileUnId=" + profileunid); var EmpResponse = getunit.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); } } else { return(RedirectToAction("Money", "FarmPolicyMoney", new { cid = cid, PcId = PcId })); } } else { if (PcId == null && Session["unId"] == null && Session["profileId"] == null) { HttpResponseMessage Res = await hclient.GetAsync("UnitDetails?ApiKey=" + ApiKey + "&Action=New&SectionName=Farm Interruption&SectionUnId=&ProfileUnId=0"); var EmpResponse = Res.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); if (unitdetails != null && unitdetails.SectionData != null) { Session["unId"] = unitdetails.SectionData.UnId; Session["FprofileId"] = unitdetails.SectionData.ProfileUnId; Session["profileId"] = unitdetails.SectionData.ProfileUnId; if (Policyincllist != null && Policyincllist.Exists(p => p.name == "Farm Interuption")) { var policyhomelist = Policyincllist.FindAll(p => p.name == "Farm Interuption").ToList(); if (policyhomelist != null && policyhomelist.Count() > 0) { Policyincllist.FindAll(p => p.name == "Farm Interuption").Where(p => p.UnitId == null).First().UnitId = unitdetails.SectionData.UnId; Policyincllist.FindAll(p => p.name == "Farm Interuption").Where(p => p.ProfileId == null).First().ProfileId = unitdetails.SectionData.ProfileUnId; } else { Policyincllist.FindAll(p => p.name == "Farm Interuption").First().UnitId = unitdetails.SectionData.UnId; Policyincllist.FindAll(p => p.name == "Farm Interuption").First().ProfileId = unitdetails.SectionData.ProfileUnId; } } } } } else { if (PcId == null && Session["unId"] != null && (Session["profileId"] != null || (Fprofileid != null && Fprofileid < 0))) { if (profileid == null || profileid == 0) { profileid = Fprofileid; } HttpResponseMessage getunit = await hclient.GetAsync("UnitDetails?ApiKey=" + ApiKey + "&Action=Existing&SectionName=&SectionUnId=" + unid + "&ProfileUnId=" + profileid); var EmpResponse = getunit.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); if (unitdetails != null && unitdetails.SectionData != null) { Session["unId"] = unitdetails.SectionData.UnId; Session["FprofileId"] = unitdetails.SectionData.ProfileUnId; } } } } } if (unitdetails != null) { if (unitdetails.SectionData != null && unitdetails.SectionData.ValueData != null) { if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPFarmInterruption.ExcessAgistIncomeFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPFarmInterruption.ExcessAgistIncomeFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPFarmInterruption.ExcessAgistIncomeFPObj.Excess = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPFarmInterruption.ExcessExtraCostFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPFarmInterruption.ExcessExtraCostFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPFarmInterruption.ExcessExtraCostFPObj.Excess = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPFarmInterruption.ExcessFarmIncomeFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPFarmInterruption.ExcessFarmIncomeFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPFarmInterruption.ExcessFarmIncomeFPObj.Excess = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPFarmInterruption.ExcessShearingDelayFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPFarmInterruption.ExcessShearingDelayFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPFarmInterruption.ExcessShearingDelayFPObj.Excess = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPFarmInterruption.ExpAgistIncomeNextYearFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPFarmInterruption.ExpAgistIncomeNextYearFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPFarmInterruption.ExpAgistIncomeNextYearFPObj.AgistIncomeNextYear = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPFarmInterruption.ExpFarmIncomeNextYearFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPFarmInterruption.ExpFarmIncomeNextYearFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPFarmInterruption.ExpFarmIncomeNextYearFPObj.FarmIncomeNextYear = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPFarmInterruption.OptAgistIncomeIndemnityPerFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPFarmInterruption.OptAgistIncomeIndemnityPerFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPFarmInterruption.OptAgistIncomeIndemnityPerFPObj.OptIndemnityPeriod = val; } else { FPFarmInterruption.OptAgistIncomeIndemnityPerFPObj.OptIndemnityPeriod = "12"; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPFarmInterruption.OptExtraCostIndemnityPerFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPFarmInterruption.OptExtraCostIndemnityPerFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPFarmInterruption.OptExtraCostIndemnityPerFPObj.OptIndemnityPeriod = val; } else { FPFarmInterruption.OptExtraCostIndemnityPerFPObj.OptIndemnityPeriod = "12"; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPFarmInterruption.OptFarmIncomeIndemnityPerFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPFarmInterruption.OptFarmIncomeIndemnityPerFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPFarmInterruption.OptFarmIncomeIndemnityPerFPObj.OptIndemnityPeriod = val; } else { FPFarmInterruption.OptFarmIncomeIndemnityPerFPObj.OptIndemnityPeriod = "12"; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPFarmInterruption.SumInsuredAgistIncomeFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPFarmInterruption.SumInsuredAgistIncomeFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPFarmInterruption.SumInsuredAgistIncomeFPObj.SumInsured = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPFarmInterruption.SumInsuredExtraCostFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPFarmInterruption.SumInsuredExtraCostFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPFarmInterruption.SumInsuredExtraCostFPObj.SumInsured = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPFarmInterruption.SumInsuredFarmIncomeFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPFarmInterruption.SumInsuredFarmIncomeFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPFarmInterruption.SumInsuredFarmIncomeFPObj.SumInsured = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPFarmInterruption.SumInsuredShearingDelayFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPFarmInterruption.SumInsuredShearingDelayFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPFarmInterruption.SumInsuredShearingDelayFPObj.SumInsured = val; } } if (unitdetails.SectionData != null && unitdetails.SectionData.AddressData != null) { if (unitdetails.SectionData.AddressData != null) { FPFarmInterruption.AddressObj.Address = unitdetails.SectionData.AddressData.AddressLine1 + ", " + unitdetails.SectionData.AddressData.Suburb + " ," + unitdetails.SectionData.AddressData.State + ", " + unitdetails.SectionData.AddressData.Postcode; } } } if (cid != null && cid.HasValue) { FPFarmInterruption.CustomerId = cid.Value; } if (PcId != null && PcId.HasValue) { FPFarmInterruption.PcId = PcId; } Session["Controller"] = "FarmPolicyFarmInterruption"; Session["ActionName"] = "FarmInterruption"; return(View(FPFarmInterruption)); }
public async System.Threading.Tasks.Task <ActionResult> Transit(int?cid, int?PcId) { NewPolicyDetailsClass commonModel = new NewPolicyDetailsClass(); List <SelectListItem> TransitExcessToPay = new List <SelectListItem>(); TransitExcessToPay = commonModel.excessRate(); FPTransit FPTransit = new FPTransit(); var db = new MasterDataEntities(); if (cid != null) { ViewBag.cid = cid; FPTransit.CustomerId = cid.Value; } else { ViewBag.cid = FPTransit.CustomerId; } ViewEditPolicyDetails unitdetails = new ViewEditPolicyDetails(); NewPolicyDetailsClass commonmethods = new NewPolicyDetailsClass(); string apikey = null; List <SessionModel> PolicyInclustions = new List <SessionModel>(); if (Session["apiKey"] != null) { apikey = Session["apiKey"].ToString(); FPTransit.ApiKey = Session["apiKey"].ToString(); } else { return(RedirectToAction("AgentLogin", "Login")); } string policyid = null; if (PcId != null && PcId.HasValue && PcId > 0) { policyid = PcId.ToString(); FPTransit.PolicyId = policyid; } else if (Session["Policyinclustions"] != null) { #region Policy Selected or not testing FPTransit.PolicyInclusions = new List <SessionModel>(); var Policyincllist = Session["Policyinclustions"] as List <SessionModel>; FPTransit.PolicyInclusions = Policyincllist; if (Policyincllist != null) { if (Policyincllist.Exists(p => p.name == "Transit")) { } else if (Policyincllist.Exists(p => p.name == "Livestock")) { return(RedirectToAction("Livestock", "FarmPolicyLivestock", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Home Buildings")) { return(RedirectToAction("MainDetails", "FarmPolicyHome", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Home Contents")) { return(RedirectToAction("HomeContents", "FarmPolicyHomeContent", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Personal Liability")) { return(RedirectToAction("PersonalLiability", "FarmPolicyPersonalLiability", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Valuables")) { return(RedirectToAction("Valuables", "FarmPolicyValuables", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Motor")) { return(RedirectToAction("VehicleDescription", "FarmMotors", new { cid = cid, PcId = PcId })); } if (Policyincllist.Exists(p => p.name == "Transit")) { if (Session["unId"] == null && Session["profileId"] == null) { Session["unId"] = Policyincllist.Where(p => p.name == "Transit").Select(p => p.UnitId).First(); Session["profileId"] = Policyincllist.Where(p => p.name == "Transit").Select(p => p.ProfileId).First(); } } else { return(RedirectToAction("DisclosureDetails", "Disclosure", new { cid = cid, PcId = PcId })); } } #endregion } FPTransit.LivestockMaxValOneLoadObj = new LivestockMaximumValOfOneload(); FPTransit.LivestockMaxValOneLoadObj.EiId = 63249; FPTransit.FarmProduceMaxValOneLoadObj = new FarmProduceMaxValOfOneLoad(); FPTransit.FarmProduceMaxValOneLoadObj.EiId = 63253; FPTransit.ExcessFPTransitObj = new ExcessFPTransit(); FPTransit.ExcessFPTransitObj.ExcessList = TransitExcessToPay; FPTransit.ExcessFPTransitObj.EiId = 63257; FPTransit.AddressObj = new AddressTsAddress(); FPTransit.AddressObj.EiId = 0; HttpClient hclient = new HttpClient(); string url = System.Configuration.ConfigurationManager.AppSettings["APIURL"]; hclient.BaseAddress = new Uri(url); hclient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); int unid = Convert.ToInt32(Session["unId"]); int profileid = Convert.ToInt32(Session["profileId"]); if (PcId != null && PcId.HasValue) { var policyinclusions = db.usp_GetUnit(null, PcId, null).ToList(); FPTransit.PolicyInclusion = new List <usp_GetUnit_Result>(); if (PcId != null && PcId.HasValue && PcId > 0) { FPTransit.PolicyInclusion = policyinclusions; } FPTransit.PolicyInclusions = new List <SessionModel>(); if (PcId != null && PcId > 0) { FPTransit.PolicyId = PcId.ToString(); } bool policyinclusion = policyinclusions.Exists(p => p.Name == "Transit"); if (policyinclusion == true && PcId != null && PcId.HasValue) { int sectionId = policyinclusions.Where(p => p.Name == "Transit").Select(p => p.UnId).FirstOrDefault(); int?profileunid = policyinclusions.Where(p => p.Name == "Transit").Select(p => p.ProfileUnId).FirstOrDefault(); HttpResponseMessage getunit = await hclient.GetAsync("UnitDetails?ApiKey=" + apikey + "&Action=Existing&SectionName=&SectionUnId=" + unid + "&ProfileUnId=" + profileid); var EmpResponse = getunit.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); } } else { return(RedirectToAction("Livestock", "FarmPolicyLivestock", new { cid = cid, PcId = PcId })); } } else { if (PcId == null && Session["unId"] == null && Session["profileId"] == null) { HttpResponseMessage Res = await hclient.GetAsync("UnitDetails?ApiKey=" + apikey + "&Action=New&SectionName=Transit&SectionUnId=&ProfileUnId="); var EmpResponse = Res.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); if (unitdetails != null && unitdetails.SectionData != null) { Session["unId"] = unitdetails.SectionData.UnId; Session["profileId"] = unitdetails.SectionData.ProfileUnId; } } } else if (PcId == null && Session["unId"] != null && Session["profileId"] != null) { HttpResponseMessage getunit = await hclient.GetAsync("UnitDetails?ApiKey=" + apikey + "&Action=Existing&SectionName=&SectionUnId=" + unid + "&ProfileUnId=" + profileid); var EmpResponse = getunit.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); if (unitdetails != null && unitdetails.SectionData != null) { Session["unId"] = unitdetails.SectionData.UnId; Session["profileId"] = unitdetails.SectionData.ProfileUnId; } } } } if (unitdetails != null) { if (unitdetails.SectionData != null && unitdetails.SectionData.ValueData != null) { if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPTransit.LivestockMaxValOneLoadObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPTransit.LivestockMaxValOneLoadObj.EiId).Select(p => p.Value).FirstOrDefault(); FPTransit.LivestockMaxValOneLoadObj.LivestockMaxValoneload = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPTransit.LivestockMaxValOneLoadObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPTransit.LivestockMaxValOneLoadObj.EiId).Select(p => p.Value).FirstOrDefault(); FPTransit.LivestockMaxValOneLoadObj.LivestockMaxValoneload = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPTransit.ExcessFPTransitObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPTransit.ExcessFPTransitObj.EiId).Select(p => p.Value).FirstOrDefault(); FPTransit.ExcessFPTransitObj.Excess = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPTransit.FarmProduceMaxValOneLoadObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPTransit.FarmProduceMaxValOneLoadObj.EiId).Select(p => p.Value).FirstOrDefault(); FPTransit.FarmProduceMaxValOneLoadObj.farmproduceMaxValoneload = val; } } if (unitdetails.SectionData != null && unitdetails.SectionData.AddressData != null) { if (unitdetails.SectionData.AddressData != null) { FPTransit.AddressObj.Address = unitdetails.SectionData.AddressData.AddressLine1 + ", " + unitdetails.SectionData.AddressData.Suburb + " ," + unitdetails.SectionData.AddressData.State + ", " + unitdetails.SectionData.AddressData.Postcode; } } } //var db = new MasterDataEntities(); //string policyid = null; //var details = db.IT_GetCustomerQnsDetails(cid,Convert.ToInt32(FarmPolicySection.Transit), Convert.ToInt32(PolicyType.FarmPolicy), policyid).ToList(); //if (details != null && details.Any()) //{ // if (details.Exists(q => q.QuestionId == FPTransit.LivestockMaxValOneLoadObj.EiId)) // { // FPTransit.LivestockMaxValOneLoadObj.LivestockMaxValoneload = Convert.ToString(details.Where(q => q.QuestionId == FPTransit.LivestockMaxValOneLoadObj.EiId).FirstOrDefault().Answer); // } // if (details.Exists(q => q.QuestionId == FPTransit.FarmProduceMaxValOneLoadObj.EiId)) // { // FPTransit.FarmProduceMaxValOneLoadObj.farmproduceMaxValoneload = Convert.ToString(details.Where(q => q.QuestionId == FPTransit.FarmProduceMaxValOneLoadObj.EiId).FirstOrDefault().Answer); // } // if (details.Exists(q => q.QuestionId == FPTransit.ExcessFPTransitObj.EiId)) // { // var loc = details.Where(q => q.QuestionId == FPTransit.ExcessFPTransitObj.EiId).FirstOrDefault(); // FPTransit.ExcessFPTransitObj.Excess = !string.IsNullOrEmpty(loc.Answer) ? (loc.Answer) : null; // } //} if (cid != null && cid.HasValue && cid > 0) { FPTransit.CustomerId = cid.Value; } if (PcId != null && PcId > 0) { FPTransit.PcId = PcId; } Session["Controller"] = "FarmPolicyTransit"; Session["ActionName"] = "Transit"; return(View(FPTransit)); }
public async System.Threading.Tasks.Task <ActionResult> Burglary(int?cid, int?PcId) { NewPolicyDetailsClass commonModel = new NewPolicyDetailsClass(); List <SelectListItem> BurglaryExcessToPay = new List <SelectListItem>(); BurglaryExcessToPay = commonModel.excessRate(); FPBurglary FPBurglary = new FPBurglary(); string ApiKey = null; if (Session["ApiKey"] != null) { ApiKey = Session["ApiKey"].ToString(); } else { return(RedirectToAction("AgentLogin", "Login")); } var Policyincllist = new List <SessionModel>(); if (Session["Policyinclustions"] != null) { Policyincllist = Session["Policyinclustions"] as List <SessionModel>; if (Policyincllist != null) { if (Policyincllist != null) { if (Policyincllist.Exists(p => p.name == "Burglary")) { } else if (Policyincllist.Exists(p => p.name == "Farm Interuption")) { return(RedirectToAction("FarmInterruption", "FarmPolicyFarmInterruption", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Money")) { return(RedirectToAction("Money", "FarmPolicyMoney", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Farm Liability")) { return(RedirectToAction("FarmLiability", "FarmPolicyFarmLiability", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Machinery")) { return(RedirectToAction("Machinery", "FarmPolicyMachinery", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Electronics")) { return(RedirectToAction("Electronics", "FarmPolicyElectronics", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Transit")) { return(RedirectToAction("Transit", "FarmPolicyTransit", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Livestock")) { return(RedirectToAction("Livestock", "FarmPolicyLivestock", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Home Buildings")) { return(RedirectToAction("MainDetails", "FarmPolicyHome", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Home Contents")) { return(RedirectToAction("HomeContents", "FarmPolicyHomeContent", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Personal Liability")) { return(RedirectToAction("PersonalLiability", "FarmPolicyPersonalLiability", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Valuables")) { return(RedirectToAction("Valuables", "FarmPolicyValuables", new { cid = cid, PcId = PcId })); } else if (Policyincllist.Exists(p => p.name == "Motor")) { return(RedirectToAction("VehicleDescription", "FarmMotors", new { cid = cid, PcId = PcId })); } if (Policyincllist.Exists(p => p.name == "Burglary")) { if (Session["unId"] == null && Session["profileId"] == null) { Session["unId"] = Policyincllist.Where(p => p.name == "Burglary").Select(p => p.UnitId).First(); Session["profileId"] = Policyincllist.Where(p => p.name == "Burglary").Select(p => p.ProfileId).First(); } } else { return(RedirectToAction("DisclosureDetails", "Disclosure", new { cid = cid, PcId = PcId })); } } } } else { RedirectToAction("PolicyInclustions", "Customer", new { CustomerId = cid, type = 1021 }); } ViewBag.cid = cid; if (cid != null) { FPBurglary.CustomerId = cid.Value; } FPBurglary.CoverYourPropOptionFPObj = new CoverYourPropOptionFP(); FPBurglary.CoverYourPropOptionFPObj.EiId = 62581; FPBurglary.FarmBuildingExCoolRoomsFPObj = new FarmBuildingExcCoolRoomsFP(); FPBurglary.FarmBuildingExCoolRoomsFPObj.EiId = 62585; FPBurglary.CoolRoomsFPObj = new CoolRoomsFP(); FPBurglary.CoolRoomsFPObj.EiId = 62587; FPBurglary.OtherFarmStructuresFPObj = new OtherFarmStructuresFP(); FPBurglary.OtherFarmStructuresFPObj.EiId = 62591; FPBurglary.FarmContentsFPObj = new FarmContentsFP(); FPBurglary.FarmContentsFPObj.EiId = 62595; FPBurglary.HailNettingStoredFPObj = new HailNettingStoredFP(); FPBurglary.HailNettingStoredFPObj.EiId = 62597; FPBurglary.UnspecifiedMachineryFPObj = new UnspecifiedMachineryFP(); FPBurglary.UnspecifiedMachineryFPObj.EiId = 62609; FPBurglary.SpecifiedItemsOver5KFPObj = new SpecifiedItemsOver5KFP(); FPBurglary.SpecifiedItemsOver5KFPObj.EiId = 62613; FPBurglary.ExcessFPBurglaryObj = new ExcessFPBurglary(); FPBurglary.ExcessFPBurglaryObj.ExcessList = BurglaryExcessToPay; FPBurglary.ExcessFPBurglaryObj.EiId = 62615; FPBurglary.OptFPCoverTheftFSAndFCObj = new FPCoverTheftFSAndFC(); FPBurglary.OptFPCoverTheftFSAndFCObj.EiId = 62619; FPBurglary.FarmFencingFPObj = new FarmFencingFP(); FPBurglary.FarmFencingFPObj.EiId = 62589; FPBurglary.OptFPCoverTheftFarmMachineryObj = new FPCoverTheftFarmMachinery(); FPBurglary.OptFPCoverTheftFarmMachineryObj.EiId = 62621; FPBurglary.OptFPPortalableItemsOptObj = new FPPortalableItemsOpt(); FPBurglary.OptFPPortalableItemsOptObj.EiId = 62623; FPBurglary.AddressObj = new AddressAddress(); FPBurglary.AddressObj.EiId = 0; var db = new MasterDataEntities(); string policyid = null; ViewEditPolicyDetails unitdetails = new ViewEditPolicyDetails(); if (cid != null) { ViewBag.cid = cid; FPBurglary.CustomerId = cid.Value; } else { ViewBag.cid = FPBurglary.CustomerId; } HttpClient hclient = new HttpClient(); string url = System.Configuration.ConfigurationManager.AppSettings["APIURL"]; hclient.BaseAddress = new Uri(url); hclient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); int unid = 0; int?profileid = 0; int Fprofileid = 0; if (Session["unId"] != null && Session["profileId"] != null) { unid = Convert.ToInt32(Session["unId"]); profileid = Convert.ToInt32(Session["profileId"]); } if (Session["FprofileId"] != null) { Fprofileid = Convert.ToInt32(Session["FprofileId"]); } if (Session["Policyinclustions"] != null) { FPBurglary.PolicyInclusions = Policyincllist; } if (PcId != null && PcId.HasValue && PcId > 0) { var policyinclusions = db.usp_GetUnit(null, PcId, null).ToList(); FPBurglary.PolicyInclusion = new List <usp_GetUnit_Result>(); if (PcId != null && PcId.HasValue && PcId > 0) { FPBurglary.PolicyInclusion = policyinclusions; } FPBurglary.PolicyInclusions = new List <SessionModel>(); if (PcId != null && PcId > 0) { policyid = PcId.ToString(); FPBurglary.PolicyId = policyid; } bool policyinclusion = policyinclusions.Exists(p => p.Name == "Burglary"); if (policyinclusion == true && PcId != null && PcId.HasValue) { unid = policyinclusions.Where(p => p.Name == "Burglary").Select(p => p.UnId).FirstOrDefault(); profileid = policyinclusions.Where(p => p.Name == "Burglary").Select(p => p.ProfileUnId).FirstOrDefault(); HttpResponseMessage getunit = await hclient.GetAsync("UnitDetails?ApiKey=" + ApiKey + "&Action=Existing&SectionName=&SectionUnId=" + unid + "&ProfileUnId=" + profileid); var EmpResponse = getunit.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); } } else { return(RedirectToAction("FarmInterruption", "FarmPolicyFarmInterruption", new { cid = cid, PcId = PcId })); } } else { if (PcId == null && Session["unId"] == null && Session["profileId"] == null) { HttpResponseMessage Res = await hclient.GetAsync("UnitDetails?ApiKey=" + ApiKey + "&Action=New&SectionName=Burglary&SectionUnId=&ProfileUnId=" + Fprofileid); var EmpResponse = Res.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); if (unitdetails != null && unitdetails.SectionData != null) { Session["unId"] = unitdetails.SectionData.UnId; Session["profileId"] = unitdetails.SectionData.ProfileUnId; if (Policyincllist != null && Policyincllist.Exists(p => p.name == "Burglary")) { var policyhomelist = Policyincllist.FindAll(p => p.name == "Burglary").ToList(); if (policyhomelist != null && policyhomelist.Count() > 0) { Policyincllist.FindAll(p => p.name == "Burglary").Where(p => p.UnitId == null).First().UnitId = unitdetails.SectionData.UnId; Policyincllist.FindAll(p => p.name == "Burglary").Where(p => p.ProfileId == null).First().ProfileId = unitdetails.SectionData.ProfileUnId; } else { Policyincllist.FindAll(p => p.name == "Burglary").First().UnitId = unitdetails.SectionData.UnId; Policyincllist.FindAll(p => p.name == "Burglary").First().ProfileId = unitdetails.SectionData.ProfileUnId; } } } } } else { if (PcId == null && Session["unId"] != null && (Session["profileId"] != null || (profileid != null && profileid < 0))) { HttpResponseMessage getunit = await hclient.GetAsync("UnitDetails?ApiKey=" + ApiKey + "&Action=Existing&SectionName=&SectionUnId=" + unid + "&ProfileUnId=" + profileid); var EmpResponse = getunit.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { unitdetails = JsonConvert.DeserializeObject <ViewEditPolicyDetails>(EmpResponse); if (unitdetails != null && unitdetails.SectionData != null) { Session["unId"] = unitdetails.SectionData.UnId; Session["profileId"] = unitdetails.SectionData.ProfileUnId; } } } } } if (unitdetails != null) { if (unitdetails.SectionData != null && unitdetails.SectionData.ValueData != null) { if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPBurglary.CoolRoomsFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPBurglary.CoolRoomsFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPBurglary.CoolRoomsFPObj.CoolRooms = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPBurglary.CoverYourPropOptionFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPBurglary.CoverYourPropOptionFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPBurglary.CoverYourPropOptionFPObj.Cover = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPBurglary.ExcessFPBurglaryObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPBurglary.ExcessFPBurglaryObj.EiId).Select(p => p.Value).FirstOrDefault(); FPBurglary.ExcessFPBurglaryObj.Excess = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPBurglary.FarmBuildingExCoolRoomsFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPBurglary.FarmBuildingExCoolRoomsFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPBurglary.FarmBuildingExCoolRoomsFPObj.FarmBuildingExcCoolRooms = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPBurglary.FarmContentsFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPBurglary.FarmContentsFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPBurglary.FarmContentsFPObj.FarmContents = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPBurglary.FarmFencingFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPBurglary.FarmFencingFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPBurglary.FarmFencingFPObj.FarmFencing = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPBurglary.HailNettingStoredFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPBurglary.HailNettingStoredFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPBurglary.HailNettingStoredFPObj.HailNettingStored = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPBurglary.OptFPCoverTheftFarmMachineryObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPBurglary.OptFPCoverTheftFarmMachineryObj.EiId).Select(p => p.Value).FirstOrDefault(); FPBurglary.OptFPCoverTheftFarmMachineryObj.CoverTheftFarmMachinery = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPBurglary.OptFPCoverTheftFSAndFCObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPBurglary.OptFPCoverTheftFSAndFCObj.EiId).Select(p => p.Value).FirstOrDefault(); FPBurglary.OptFPCoverTheftFSAndFCObj.CoverTheftFSandFC = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPBurglary.OptFPPortalableItemsOptObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPBurglary.OptFPPortalableItemsOptObj.EiId).Select(p => p.Value).FirstOrDefault(); FPBurglary.OptFPPortalableItemsOptObj.PortalbleItemsOpt = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPBurglary.OtherFarmStructuresFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPBurglary.OtherFarmStructuresFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPBurglary.OtherFarmStructuresFPObj.OtherFarmStructures = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPBurglary.SpecifiedItemsOver5KFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPBurglary.SpecifiedItemsOver5KFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPBurglary.SpecifiedItemsOver5KFPObj.SpecifiedItemOver5K = val; } if (unitdetails.SectionData.ValueData.Exists(p => p.Element.ElId == FPBurglary.UnspecifiedMachineryFPObj.EiId)) { string val = unitdetails.SectionData.ValueData.Where(p => p.Element.ElId == FPBurglary.UnspecifiedMachineryFPObj.EiId).Select(p => p.Value).FirstOrDefault(); FPBurglary.UnspecifiedMachineryFPObj.UnspecifiedMachinery = val; } } if (unitdetails.SectionData != null && unitdetails.SectionData.AddressData != null) { if (unitdetails.SectionData.AddressData != null) { FPBurglary.AddressObj.Address = unitdetails.SectionData.AddressData.AddressLine1 + ", " + unitdetails.SectionData.AddressData.Suburb + " ," + unitdetails.SectionData.AddressData.State + ", " + unitdetails.SectionData.AddressData.Postcode; } } } if (cid != null && cid.HasValue) { FPBurglary.CustomerId = cid.Value; } if (PcId != null && PcId.HasValue) { FPBurglary.PcId = PcId; } Session["Controller"] = "FarmPolicyBurglary"; Session["ActionName"] = "Burglary"; return(View(FPBurglary)); }