public ActionResult PropertyLocate(LocaterView m)
        {

            if (ModelState.IsValid)
            {
                using (UnitOfWork uow = new UnitOfWork())
                {
                    IEnumerable<Property> ps = uow.PropertyRepository.Get(p => p.PhoneNumber.Equals(m.PhoneNumber) && p.User==null&&p.Active, null, "Block");
                    if (ps == null || ps.Count() != 1)
                    {
                        ModelState.AddModelError("", "无法获取对应电话号码,该号码可能已和房产绑定,或您尚未登记手机号。请确认后重新输入,或联系物业公司注册手机号。");

                    }
                    else
                    {
                        return RedirectToActionPermanent("Register", new { phoneNumber = m.PhoneNumber });
                    }
                    /*
                    Property pp = ps.FirstOrDefault();
                    RegisterViewModel md = new RegisterViewModel();
                    md.PropertyId = pp.PropertyId;
                    md.PropertyDetails = pp.Block.BlockName + "单元" + pp.PropertyNumber;
                    md.PhoneNumber = pp.PhoneNumber;

                return RedirectToAction("Register", md);  */
                }
            }
            return View(m);
        }
        public void UoW_Can_Create_Domains()
        {
            //arrange
            //create a UoW
            UnitOfWork uow = new UnitOfWork();
            //create a new district
            District district = new District();
            district.City = "Melbourne";
            district.Name = "D1";
            district.NumberOfResidents = 100;
            district.PostCode = "3000";
            district.Province = "VIC";
            district.Street = "Dandenong";
            district.StreetNumber = 590;
            district.UnderDevelopment = false;
            //insert district
            uow.DistrictRepository.Insert(district);
            //create a new block
            Block block = new Block();
            block.BlockName = "Block";
            block.District = district;
            block.NumberOfResidents = 100;
            block.UnderDevelopment = false;
            uow.BlockRepository.Insert(block);
            //create property
            Property property = new Property();
            property.Active = true;
            property.Balance = 0;
            property.Block = block;
            property.NumberOfResidents = 10;
            property.PropertyNumber = "A1";
            property.Sold = false;
            uow.PropertyRepository.Insert(property);

            //act
            uow.Save();
        }
        public ActionResult Register(string phoneNumber)
        {
            //ViewBag.CanProceed = true;
            using (UnitOfWork uow = new UnitOfWork())
            {
                IEnumerable<Property> ps = uow.PropertyRepository.Get(p => phoneNumber!=null&&phoneNumber.Length>0 &&p.PhoneNumber.Equals(phoneNumber) && p.Active && p.User==null, null, "Block");
                if (ps == null || ps.Count() != 1)
                {
                    TempData["result"] = "请输入购房注册所用的手机号码";
                    return RedirectToActionPermanent("PropertyLocate");
                }
                Property pp = ps.FirstOrDefault();
                RegisterViewModel md = new RegisterViewModel();
                md.PropertyId = pp.PropertyId;
                md.PropertyDetails = pp.Block.BlockName + "单元" + pp.PropertyNumber;
                md.PhoneNumber = pp.PhoneNumber;

                return View(md);

            }
        }