public ActionResult Results()
 {
     var m = new PeopleSearchModel();
     UpdateModel(m);
     UpdateModel(m.m);
     Session["FindPeopleInfo"] = m.m;
     return View(m);
 }
 public ActionResult ConvertToQuery()
 {
     var m = new PeopleSearchModel();
     UpdateModel(m);
     UpdateModel(m.m);
     Session["FindPeopleInfo"] = m.m;
     return Content("/QueryBuilder/Main/" + m.ConvertToQuery());
 }
Example #3
0
        public ActionResult Index(string name)
        {
            var m = new PeopleSearchModel();
            if (name.HasValue())
            {
                m.m.name = name;
            }
            else
            {
                var i = Session["FindPeopleInfo"] as PeopleSearchInfo;
                if (i != null)
                    m.m = i;
            }

            return View(m);
        }
        public ActionResult Index(string name)
        {
            var m = new PeopleSearchModel();
            if (name.HasValue())
            {
                m.m.name = name;
            //                if (m.Count() == 1)
            //                {
            //                    var pid = m.FetchPeople().Single().PeopleId;
            //                    return Redirect("/Person/Index/" + pid);
            //                }
            }
            else
            {
                var i = Session["FindPeopleInfo"] as PeopleSearchInfo;
                if (i != null)
                    m.m = i;
            }

            return View(m);
        }
Example #5
0
 public ActionResult Results(PeopleSearchModel m)
 {
     UpdateModel(m.m);
     Session["FindPeopleInfo"] = m.m;
     return View(m);
 }
Example #6
0
 public ActionResult ConvertToQuery(PeopleSearchModel m)
 {
     UpdateModel(m.m);
     Session["FindPeopleInfo"] = m.m;
     return Content(m.ConvertToSearch());
 }
Example #7
0
        internal void ValidateModelForNew(ModelStateDictionary ModelState, bool checkaddress)
        {
            if (!first.HasValue())
            {
                ModelState.AddModelError("name", "first name required");
            }

            if (!last.HasValue())
            {
                ModelState.AddModelError("name", "last name required");
            }

            if (!birthday.HasValue && dob.NotEqual("na"))
            {
                ModelState.AddModelError("dob", "valid birthday (or \"na\")");
            }

            var d = phone.GetDigits().Length;

            if (d != 7 && d < 10 && phone.NotEqual("na"))
            {
                ModelState.AddModelError("phone", "7 or 10+ digits (or \"na\")");
            }

            int count = 0;

            PeopleSearchModel.FindPerson(first, last, birthday ?? DateTime.MinValue, string.Empty, phone.GetDigits(),
                                         out count);
            if (count > 0)
            {
                ModelState.AddModelError("name", "name/dob already exists in db");
            }

            if (!Util.ValidEmail(email) && email.NotEqual("na"))
            {
                ModelState.AddModelError("email", "valid email address (or \"na\")");
            }

            if (gender == 99)
            {
                ModelState.AddModelError("gender", "specify gender");
            }

            if (marital == 99)
            {
                ModelState.AddModelError("marital", "specify marital status");
            }

            if (checkaddress)
            {
                if (!address.HasValue())
                {
                    ModelState.AddModelError("address", "address required (or \"na\")");
                }

                var addrok = false;
                if (city.HasValue() && state.HasValue())
                {
                    addrok = true;
                }
                if (zip.HasValue())
                {
                    addrok = true;
                }
                if (city.Equal("na") && state.Equal("na") && zip.Equal("na"))
                {
                    addrok = true;
                }
                if (!addrok)
                {
                    ModelState.AddModelError("zip", "city/state required or zip required (or \"na\" in all)");
                }

                if (ModelState.IsValid &&
                    address.NotEqual("na") && city.NotEqual("na") && state.NotEqual("na") &&
                    (country.Equal("United States") || !country.HasValue()))
                {
                    var r = AddressVerify.LookupAddress(address, address2, city, state, zip);
                    if (r.Line1 != "error")
                    {
                        if (!r.found)
                        {
                            ModelState.AddModelError("zip",
                                                     r.address +
                                                     ", if your address will not validate, change the country to 'USA, Not Validated'");
                            return;
                        }
                        if (r.Line1 != address)
                        {
                            ModelState.AddModelError("address", "address changed from '{0}'".Fmt(address));
                            address = r.Line1;
                        }
                        if (r.Line2 != (address2 ?? ""))
                        {
                            ModelState.AddModelError("address2", "address2 changed from '{0}'".Fmt(address2));
                            address2 = r.Line2;
                        }
                        if (r.City != (city ?? ""))
                        {
                            ModelState.AddModelError("city", "city changed from '{0}'".Fmt(city));
                            city = r.City;
                        }
                        if (r.State != (state ?? ""))
                        {
                            ModelState.AddModelError("state", "state changed from '{0}'".Fmt(state));
                            state = r.State;
                        }
                        if (r.Zip != (zip ?? ""))
                        {
                            ModelState.AddModelError("zip", "zip changed from '{0}'".Fmt(zip));
                            zip = r.Zip;
                        }
                    }
                }
            }
        }