// // GET: /AddrBkGeographicalGroupMember/Create public ActionResult Create(Guid organizationId, String orgName, String basis) { ViewBag.orgName = orgName; ViewBag.organizationId = organizationId; ViewBag.MainTitle = Utils.AddrbkGeographicalGroupMember + " / " + orgName; ViewBag.State = ""; ViewBag.StateProvince = ""; ViewBag.streetAddress = ""; ViewBag.basis = basis; ViewBag.GeographicalGroup_LCID = new SelectList(db.AddrBk_GeographicalGroup, "Id", "Title"); if (basis.Equals(Utils.AB_GeoGraphicalMemberContinent)) ViewBag.Continent_LCID = new SelectList(db.Lookup_Continent.Where(e=>e.ActiveRec == true), "Id", "Title"); if (basis.Equals(Utils.AB_GeoGraphicalMemberCountry)) ViewBag.Country_LCID = new SelectList(db.Lookup_Country.Where(a => a.ActiveRec == true), "Id", "Title"); else ViewBag.Country = db.Lookup_Country.Where(a => a.ActiveRec == true).ToList(); AddrBk_GeographicalGroupMember model = new AddrBk_GeographicalGroupMember(); model.EffDt = DateTime.Now; if (basis.Equals(Utils.AB_GeoGraphicalMemberCountry)) return PartialView("_CreateCountry", model); else if(basis.Equals(Utils.AB_GeoGraphicalMemberState)) return PartialView("_CreateState", model); else if(basis.Equals(Utils.AB_GeoGraphicalMemberContinent)) return PartialView("_CreateContinent", model); else if (basis.Equals(Utils.AB_GeoGraphicalMemberCity) || basis.Equals(Utils.AB_GeoGraphicalMemberCounty) || basis.Equals(Utils.AB_GeoGraphicalMemberMunicipality)) return PartialView("_CreateCity", model); else return PartialView("_CreateStreet", model); }
public ActionResult Create(AddrBk_GeographicalGroupMember addrbk_geographicalgroupmember, Guid organizationId, String orgName, String basis) { try { if (basis.Equals(Utils.AB_GeoGraphicalMemberCountry)) { if (addrbk_geographicalgroupmember.Country_LCID == null || addrbk_geographicalgroupmember.Country_LCID == Guid.Empty) throw new Exception(); } else if (basis.Equals(Utils.AB_GeoGraphicalMemberState)) { if (addrbk_geographicalgroupmember.Country_LCID == null || addrbk_geographicalgroupmember.Country_LCID == Guid.Empty || addrbk_geographicalgroupmember.StateOrProv_LCID == null || addrbk_geographicalgroupmember.StateOrProv_LCID == Guid.Empty) throw new Exception(); } else if (basis.Equals(Utils.AB_GeoGraphicalMemberContinent)) { if (addrbk_geographicalgroupmember.Continent_LCID == null || addrbk_geographicalgroupmember.Continent_LCID == Guid.Empty) throw new Exception(); } else if (basis.Equals(Utils.AB_GeoGraphicalMemberCity) || basis.Equals(Utils.AB_GeoGraphicalMemberCounty) || basis.Equals(Utils.AB_GeoGraphicalMemberMunicipality)) { if (addrbk_geographicalgroupmember.Country_LCID == null || addrbk_geographicalgroupmember.Country_LCID == Guid.Empty || addrbk_geographicalgroupmember.StateOrProv_LCID == null || addrbk_geographicalgroupmember.StateOrProv_LCID == Guid.Empty || addrbk_geographicalgroupmember.StateOrProvLocalityID == null || addrbk_geographicalgroupmember.StateOrProvLocalityID == Guid.Empty) throw new Exception(); } else if (basis.Equals(Utils.AB_GeoGraphicalMemberStreet) || basis.Equals(Utils.AB_GeoGraphicalMemberPostalCode)) { if (addrbk_geographicalgroupmember.Country_LCID == null || addrbk_geographicalgroupmember.Country_LCID == Guid.Empty || addrbk_geographicalgroupmember.AddrID == null || addrbk_geographicalgroupmember.AddrID == Guid.Empty) throw new Exception(); } addrbk_geographicalgroupmember.Id = Guid.NewGuid(); addrbk_geographicalgroupmember.CreatedDt = addrbk_geographicalgroupmember.LastUpdatedDt = DateTime.Now; addrbk_geographicalgroupmember.ActiveRec = true; addrbk_geographicalgroupmember.GeographicalGroup_LCID = organizationId; db.AddrBk_GeographicalGroupMember.Add(addrbk_geographicalgroupmember); db.SaveChanges(); return RedirectToAction("Index", new { organizationId = organizationId, orgName = orgName }); } catch { ModelState.AddModelError(String.Empty, Utils.errorMsg); } ViewBag.orgName = orgName; ViewBag.organizationId = organizationId; ViewBag.MainTitle = Utils.AddrbkGeographicalGroupMember + " / " + orgName; ViewBag.basis = basis; ViewBag.GeographicalGroup_LCID = new SelectList(db.AddrBk_GeographicalGroup, "Id", "Title", addrbk_geographicalgroupmember.GeographicalGroup_LCID); if (basis.Equals(Utils.AB_GeoGraphicalMemberContinent)) ViewBag.Continent_LCID = new SelectList(db.Lookup_Continent.Where(e => e.ActiveRec == true), "Id", "Title", addrbk_geographicalgroupmember.Continent_LCID); if (basis.Equals(Utils.AB_GeoGraphicalMemberCountry)) ViewBag.Country_LCID = new SelectList(db.Lookup_Country.Where(a => a.ActiveRec == true), "Id", "Title"); else ViewBag.Country = db.Lookup_Country.Where(a => a.ActiveRec == true).ToList(); ViewBag.State = ""; if (addrbk_geographicalgroupmember.Country_LCID != null) ViewBag.State = db.Lookup_StateProvince.Where(a => a.ActiveRec == true && a.Cntry_LCID == addrbk_geographicalgroupmember.Country_LCID).ToList(); if (basis.Equals(Utils.AB_GeoGraphicalMemberCity) || basis.Equals(Utils.AB_GeoGraphicalMemberCounty) || basis.Equals(Utils.AB_GeoGraphicalMemberMunicipality)) { ViewBag.StateProvince = ""; if (addrbk_geographicalgroupmember.Country_LCID != null && addrbk_geographicalgroupmember.StateOrProv_LCID != null) { Guid basisId = Utils.GetGeoBasisId(organizationId); ViewBag.StateProvince = db.AddrBk_StateOrProvinceLocality.Where(a => a.ActiveRec == true && a.Cntry_LCID == addrbk_geographicalgroupmember.Country_LCID && a.GeoBasis_LCID == basisId && a.StateOrProv_LCID == addrbk_geographicalgroupmember.StateOrProv_LCID).ToList(); } } if(basis.Equals(Utils.AB_GeoGraphicalMemberStreet) || (basis.Equals(Utils.AB_GeoGraphicalMemberPostalCode))) { ViewBag.streetAddress = ""; if (addrbk_geographicalgroupmember.Country_LCID != null && addrbk_geographicalgroupmember.StateOrProv_LCID != null) { Guid address_typeId = Utils.GetAddressTypeId(streetaddressType); List<AddrBk_Address> list = db.AddrBk_Address.Where(a => a.ActiveRec == true && a.Cntry_LCID == addrbk_geographicalgroupmember.Country_LCID && a.AddrType_LCID == address_typeId && a.StateOrProv_LCID == addrbk_geographicalgroupmember.StateOrProv_LCID).ToList(); ViewBag.streetAddress = ""; if (list.Count > 0) { if (basis.Equals(Utils.AB_GeoGraphicalMemberStreet)) ViewBag.streetAddress = GetDistinctList(list); else ViewBag.streetAddress = GetDistinctList(list, true); } } } if (basis.Equals(Utils.AB_GeoGraphicalMemberCountry)) return PartialView("_CreateCountry", addrbk_geographicalgroupmember); else if (basis.Equals(Utils.AB_GeoGraphicalMemberState)) return PartialView("_CreateState", addrbk_geographicalgroupmember); else if (basis.Equals(Utils.AB_GeoGraphicalMemberContinent)) return PartialView("_CreateContinent", addrbk_geographicalgroupmember); else if (basis.Equals(Utils.AB_GeoGraphicalMemberCity) || basis.Equals(Utils.AB_GeoGraphicalMemberCounty) || basis.Equals(Utils.AB_GeoGraphicalMemberMunicipality)) return PartialView("_CreateCity", addrbk_geographicalgroupmember); else return PartialView("_CreateStreet", addrbk_geographicalgroupmember); }