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> 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> ClaimsDetails(int?cid, int?PcId) { NewPolicyDetailsClass Calimmodel = new NewPolicyDetailsClass(); List <SelectListItem> ClaimTypeList = new List <SelectListItem>(); ClaimTypeList = Calimmodel.ClaimTypeRular(); ClaimsDetails ClaimsDetails = new ClaimsDetails(); ClaimsDetails.PolicyInclusions = new List <string>(); Session["Controller"] = "Claims"; Session["ActionName"] = "ClaimsDetails"; string apikey = null; if (Session["ApiKey"] != null) { apikey = Session["ApiKey"].ToString(); } 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("PreviousClaims?ApiKey=" + apikey); var EmpResponse = getunit.Content.ReadAsStringAsync().Result; if (EmpResponse != null) { ClaimsDetails.ClaimTypeRowsourceOptions = new List <RowsourceDatas>(); ClaimsDetails.ValueData = new List <ValueData>(); ClaimsDetails = JsonConvert.DeserializeObject <ClaimsDetails>(EmpResponse); } ClaimsDetails.ClaimtypeObj = new ClaimType(); ClaimsDetails.ClaimtypeObj.ClaimTypeList = ClaimTypeList; ClaimsDetails.ClaimtypeObj.EiId = 73; ClaimsDetails.DetailsclaimObj = new DetailsOfClaim(); ClaimsDetails.DetailsclaimObj.EiId = 74; ClaimsDetails.ClaimvalueObj = new ClaimValue(); ClaimsDetails.ClaimvalueObj.EiId = 75; ClaimsDetails.YearObj = new ClaimYear(); ClaimsDetails.YearObj.EiId = 76; ClaimsDetails.InsurerObj = new ClaimInsurer(); ClaimsDetails.InsurerObj.EiId = 77; ClaimsDetails.DriverObj = new ClaimDriver(); ClaimsDetails.DriverObj.EiId = 79; if (cid != null && cid.HasValue) { ClaimsDetails.CustomerId = cid.Value; } if (ClaimsDetails.ValueData.Exists(p => p.Element.ElId == ClaimsDetails.ClaimtypeObj.EiId)) { string val = ClaimsDetails.ValueData.Where(p => p.Element.ElId == ClaimsDetails.ClaimtypeObj.EiId).Select(p => p.Value).FirstOrDefault(); ClaimsDetails.ClaimtypeObj.Type = val; } if (ClaimsDetails.ValueData.Exists(p => p.Element.ElId == ClaimsDetails.ClaimvalueObj.EiId)) { string val = ClaimsDetails.ValueData.Where(p => p.Element.ElId == ClaimsDetails.ClaimvalueObj.EiId).Select(p => p.Value).FirstOrDefault(); ClaimsDetails.ClaimvalueObj.Cvalue = val; } if (ClaimsDetails.ValueData.Exists(p => p.Element.ElId == ClaimsDetails.DetailsclaimObj.EiId)) { string val = ClaimsDetails.ValueData.Where(p => p.Element.ElId == ClaimsDetails.DetailsclaimObj.EiId).Select(p => p.Value).FirstOrDefault(); ClaimsDetails.DetailsclaimObj.Details = val; } if (ClaimsDetails.ValueData.Exists(p => p.Element.ElId == ClaimsDetails.DriverObj.EiId)) { string val = ClaimsDetails.ValueData.Where(p => p.Element.ElId == ClaimsDetails.DriverObj.EiId).Select(p => p.Value).FirstOrDefault(); ClaimsDetails.DriverObj.Driver = val; } if (ClaimsDetails.ValueData.Exists(p => p.Element.ElId == ClaimsDetails.InsurerObj.EiId)) { string val = ClaimsDetails.ValueData.Where(p => p.Element.ElId == ClaimsDetails.InsurerObj.EiId).Select(p => p.Value).FirstOrDefault(); ClaimsDetails.InsurerObj.Insurer = val; } ClaimsDetails.ClaimtypeobjList = new List <ValueDatas>(); if (ClaimsDetails.ValueData != null && ClaimsDetails.ValueData.Count() > 0) { if (ClaimsDetails.ValueData.Count() > 1) { List <ValueDatas> elmnts = new List <ValueDatas>(); var power = ClaimsDetails.ValueData.ToList(); for (int i = 0; i < power.Count(); i++) { ValueDatas vds = new ValueDatas(); vds.Element = new Elements(); vds.Element.ElId = power[i].Element.ElId; vds.Element.ItId = power[i].Element.ItId; vds.Value = power[i].Value; elmnts.Add(vds); } ClaimsDetails.ClaimtypeobjList = elmnts; } if (ClaimsDetails.ValueData.Exists(p => p.Element.ElId == ClaimsDetails.ClaimtypeObj.EiId)) { string val = ClaimsDetails.ValueData.Where(p => p.Element.ElId == ClaimsDetails.ClaimtypeObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && !string.IsNullOrEmpty(val)) { ClaimsDetails.ClaimtypeObj.Type = val; } if (ClaimsDetails.ValueData.Select(p => p.Element.ElId == ClaimsDetails.ClaimtypeObj.EiId).Count() > 1) { List <ValueDatas> elmnt = new List <ValueDatas>(); var DescriptionList = ClaimsDetails.ValueData.Where(p => p.Element.ElId == ClaimsDetails.ClaimtypeObj.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 = 73; vds.Element.ItId = DescriptionList[i]; vds.Value = ClaimsDetails.ValueData.Where(p => p.Element.ElId == ClaimsDetails.ClaimtypeObj.EiId && p.Element.ItId == DescriptionList[i]).Select(p => p.Value).FirstOrDefault(); elmnt.Add(vds); } ClaimsDetails.ClaimtypeobjList = elmnt; } } if (ClaimsDetails.ValueData.Exists(p => p.Element.ElId == ClaimsDetails.ClaimvalueObj.EiId)) { string val = ClaimsDetails.ValueData.Where(p => p.Element.ElId == ClaimsDetails.ClaimvalueObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && !string.IsNullOrEmpty(val)) { ClaimsDetails.ClaimvalueObj.Cvalue = val; } if (ClaimsDetails.ValueData.Select(p => p.Element.ElId == ClaimsDetails.ClaimvalueObj.EiId).Count() > 1) { List <ValueDatas> elmn = new List <ValueDatas>(); var DescriptionList = ClaimsDetails.ValueData.Where(p => p.Element.ElId == ClaimsDetails.ClaimvalueObj.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 = 75; vds.Element.ItId = DescriptionList[i]; vds.Value = ClaimsDetails.ValueData.Where(p => p.Element.ElId == ClaimsDetails.ClaimvalueObj.EiId && p.Element.ItId == DescriptionList[i]).Select(p => p.Value).FirstOrDefault(); elmn.Add(vds); } ClaimsDetails.ClaimvalueobjList = elmn; } } if (ClaimsDetails.ValueData.Exists(p => p.Element.ElId == ClaimsDetails.DetailsclaimObj.EiId)) { string val = ClaimsDetails.ValueData.Where(p => p.Element.ElId == ClaimsDetails.DetailsclaimObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && !string.IsNullOrEmpty(val)) { ClaimsDetails.DetailsclaimObj.Details = val; } if (ClaimsDetails.ValueData.Select(p => p.Element.ElId == ClaimsDetails.DetailsclaimObj.EiId).Count() > 1) { List <ValueDatas> elmn = new List <ValueDatas>(); var DescriptionList = ClaimsDetails.ValueData.Where(p => p.Element.ElId == ClaimsDetails.DetailsclaimObj.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 = 74; vds.Element.ItId = DescriptionList[i]; vds.Value = ClaimsDetails.ValueData.Where(p => p.Element.ElId == ClaimsDetails.DetailsclaimObj.EiId && p.Element.ItId == DescriptionList[i]).Select(p => p.Value).FirstOrDefault(); elmn.Add(vds); } ClaimsDetails.DetailsclaimobjList = elmn; } } if (ClaimsDetails.ValueData.Exists(p => p.Element.ElId == ClaimsDetails.DriverObj.EiId)) { string val = ClaimsDetails.ValueData.Where(p => p.Element.ElId == ClaimsDetails.DriverObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && !string.IsNullOrEmpty(val)) { ClaimsDetails.DriverObj.Driver = val; } if (ClaimsDetails.ValueData.Select(p => p.Element.ElId == ClaimsDetails.DriverObj.EiId).Count() > 1) { List <ValueDatas> elmn = new List <ValueDatas>(); var DescriptionList = ClaimsDetails.ValueData.Where(p => p.Element.ElId == ClaimsDetails.DriverObj.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 = 79; vds.Element.ItId = DescriptionList[i]; vds.Value = ClaimsDetails.ValueData.Where(p => p.Element.ElId == ClaimsDetails.DriverObj.EiId && p.Element.ItId == DescriptionList[i]).Select(p => p.Value).FirstOrDefault(); elmn.Add(vds); } ClaimsDetails.DriverobjList = elmn; } } if (ClaimsDetails.ValueData.Exists(p => p.Element.ElId == ClaimsDetails.InsurerObj.EiId)) { string val = ClaimsDetails.ValueData.Where(p => p.Element.ElId == ClaimsDetails.InsurerObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && !string.IsNullOrEmpty(val)) { ClaimsDetails.InsurerObj.Insurer = val; } if (ClaimsDetails.ValueData.Select(p => p.Element.ElId == ClaimsDetails.InsurerObj.EiId).Count() > 1) { List <ValueDatas> elmn = new List <ValueDatas>(); var DescriptionList = ClaimsDetails.ValueData.Where(p => p.Element.ElId == ClaimsDetails.InsurerObj.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 = 77; vds.Element.ItId = DescriptionList[i]; vds.Value = ClaimsDetails.ValueData.Where(p => p.Element.ElId == ClaimsDetails.InsurerObj.EiId && p.Element.ItId == DescriptionList[i]).Select(p => p.Value).FirstOrDefault(); elmn.Add(vds); } ClaimsDetails.InsurerobjList = elmn; } } if (ClaimsDetails.ValueData.Exists(p => p.Element.ElId == ClaimsDetails.YearObj.EiId)) { string val = ClaimsDetails.ValueData.Where(p => p.Element.ElId == ClaimsDetails.YearObj.EiId).Select(p => p.Value).FirstOrDefault(); if (val != null && !string.IsNullOrEmpty(val)) { ClaimsDetails.YearObj.Year = val; } if (ClaimsDetails.ValueData.Select(p => p.Element.ElId == ClaimsDetails.YearObj.EiId).Count() > 1) { List <ValueDatas> elmn = new List <ValueDatas>(); var DescriptionList = ClaimsDetails.ValueData.Where(p => p.Element.ElId == ClaimsDetails.YearObj.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 = 76; vds.Element.ItId = DescriptionList[i]; vds.Value = ClaimsDetails.ValueData.Where(p => p.Element.ElId == ClaimsDetails.YearObj.EiId && p.Element.ItId == DescriptionList[i]).Select(p => p.Value).FirstOrDefault(); elmn.Add(vds); } ClaimsDetails.yearobjList = elmn; } ClaimsDetails.PcId = PcId; Session["PcId"] = PcId; } } return(View(ClaimsDetails)); }
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> 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> 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> 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)); }