Ejemplo n.º 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            Dwelling dwelling = db.Dwellings.Find(id);

            db.Dwellings.Remove(dwelling);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
        public void CreateDwelling(Dwelling dwelling, MapSize mapSize)
        {
            var dwellingType = GetDwellingType(dwelling.BuildingLocation, mapSize);

            engine.CreateObject(dwelling.UnityId, dwellingType, dwelling.BuildingLocation.X, dwelling.BuildingLocation.Y);

            CreateMarker(dwelling.UnityId, dwelling.BuildingLocation, dwelling.EntryLocation,
                         unitColor[dwelling.Recruit.UnitType], MapObject.SwordMarker);
        }
Ejemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "Id,PropertyAddressNumber,Availability,CurrentlyRented,PropertyStreetName,PropertyCity,PropertyPostalCode,PropertyPurchaseAmount,PurchaseDate,NamesOnLease,PhoneNumberForTennet,PrimaryTennetEmailAddress,LeaseRenewalDate")] Dwelling dwelling)
 {
     if (ModelState.IsValid)
     {
         db.Entry(dwelling).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(dwelling));
 }
Ejemplo n.º 4
0
        public void OwnDwelling()
        {
            var player = new Player {
                Id = 1
            };
            var dwelling = new Dwelling();

            Interaction.Make(player, dwelling);
            Assert.AreEqual(false, player.Dead);
            Assert.AreEqual(player.Id, dwelling.Owner);
            Assert.AreEqual(0, player.Gold);
        }
Ejemplo n.º 5
0
        // GET: Dwellings/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Dwelling dwelling = db.Dwellings.Find(id);

            if (dwelling == null)
            {
                return(HttpNotFound());
            }
            return(View(dwelling));
        }
Ejemplo n.º 6
0
        private void LoadDwellings()
        {
            WriteToLog("Starting to Load Dwellings/Households");
            var householdRepo = Repository.GetRepository(RepositoryHousehold);
            var dwellingRepo  = Repository.GetRepository(RepositoryDwellings);
            var initialDate   = new Date(InitialYear, 0);
            var zoneSystem    = Repository.GetRepository(ZoneSystem);

            using (var reader = new CsvReader(InitialHouseholdFile, true))
            {
                if (FilesContainHeaders)
                {
                    reader.LoadLine();
                }
                while (reader.LoadLine(out int columns))
                {
                    /*
                     * int dwellingid, pumhid, ctcode, tts96, prov, urbru, cmapust, weight, hhinda, hhindb, hhpera, hhperb1, hhperb2, hhperd, hhpere,
                     *  hhperf, hhperg, hhperh, hhsize, hhcomp, hhnonfam, hhnuef, hhnuldg, hhnuempi, hhnutoti, hhmsinc, hhempinc, hhnetinv,
                     *  hhgovinc, hhotinc, hhtotinc, dtypeh, builth, tenurh, morg, rcondh, room, heath, fuelhh, valueh, grosrth, renth, omph,
                     *  mppit,hmage, hmsex, hmmarst, hmefamst, hmbirtpl, hmethnic, hmimmig, hhmotg, hmofflg, hmmob5, hmhlos, hmocc81, hmlfact,
                     *  hmcow, hmwkswk, hmfptwk, hmmsinc, hmempinc, hmnetinv, hmgovinc, hmotinc, hmtotinc, spage, spsex, spbirtpl, spethnic,
                     *  spmotg, spofflg, spimmig, spmob5, sphlos, spocc81, splfact, spcow, spwkswk, spfptwk, spmsinc, spempinc, spnetinv, spgovinc,
                     *  spotinc, sptotinc, efsize, efadult, efpersgh, efpersa, efpersb, efpersc, efpersd, efcomp, efnuempi, efnutoti, efloinc,
                     *  efmsinc, efempinc, efnetinv, efgovinc, efotinc, eftotinc, id;
                     */
                    if (columns > 39)
                    {
                        reader.Get(out int dwellingid, 0);
                        reader.Get(out int ctcode, 2);
                        reader.Get(out int hhcomp, 19);
                        reader.Get(out int dtype, 31);
                        reader.Get(out int tenur, 33);
                        reader.Get(out int rooms, 36);
                        reader.Get(out int value, 39);
                        Household h = new Household();
                        Dwelling  d = new Dwelling();
                        householdRepo.AddNew(dwellingid, h);
                        dwellingRepo.AddNew(dwellingid, d);
                        h.Dwelling      = d;
                        h.HouseholdType = ConvertHouseholdType(hhcomp);
                        d.Exists        = true;
                        d.Zone          = zoneSystem.GetFlatIndex(ctcode);
                        d.Rooms         = rooms;
                        d.Value         = new Money(value, initialDate);
                        h.Tenure        = ConvertTenureFromCensus(tenur);
                    }
                }
            }
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Dwelling = await _context.Dwelling.FindAsync(id);

            if (Dwelling != null)
            {
                _context.Dwelling.Remove(Dwelling);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Dwelling = await _context.Dwelling
                       .Include(d => d.Agent)
                       .Include(d => d.Buyer)
                       .Include(d => d.City).FirstOrDefaultAsync(m => m.Id == id);

            if (Dwelling == null)
            {
                return(NotFound());
            }
            return(Page());
        }
        public void Add(DwellingRequest request)
        {
            using (MultifamilyPropertyContext db = new MultifamilyPropertyContext())
            {
                var dwelling = new Dwelling();

                try
                {
                    dwelling.IdBuilding = request.IdBuilding;
                    dwelling.Name       = request.Name;

                    db.Dwelling.Add(dwelling);
                    db.SaveChanges();
                }
                catch (Exception err)
                {
                    throw new Exception(err.Message);
                }
            }
        }
Ejemplo n.º 10
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Dwelling = await _context.Dwelling
                       .Include(d => d.Agent)
                       .Include(d => d.City)
                       .Include(d => d.SalesOffice).FirstOrDefaultAsync(m => m.Id == id);

            if (Dwelling == null)
            {
                return(NotFound());
            }
            ViewData["AgentId"]       = new SelectList(_context.Agent, "Id", "FullName");
            ViewData["CityId"]        = new SelectList(_context.City, "Id", "Name");
            ViewData["SalesOfficeId"] = new SelectList(_context.Set <SalesOffice>(), "Id", "Name");
            return(Page());
        }
Ejemplo n.º 11
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Dwelling = await _context.Dwelling
                       .Include(d => d.Agent)
                       .Include(d => d.Buyer)
                       .Include(d => d.City).FirstOrDefaultAsync(m => m.Id == id);

            if (Dwelling == null)
            {
                return(NotFound());
            }
            ViewData["AgentId"] = new SelectList(_context.Set <Agent>(), "Id", "FirstName");
            ViewData["BuyerId"] = new SelectList(_context.Set <Buyer>(), "Id", "FirstName");
            ViewData["CityId"]  = new SelectList(_context.Set <City>(), "Id", "Name");
            return(Page());
        }
Ejemplo n.º 12
0
        private static void Main(string[] args)
        {
            var dwelling = new Dwelling {Address = "1 Main Street, New York, NY", Type = DwellingTypes.SingleHouse};
            var dwelling2 = new Dwelling {Address = "2 Main Street, New York, NY", Type = DwellingTypes.SingleHouse};
            var policy1 = new Policy {Name = "Silver", PolicyType = PolicyTypes.Home, Price = 1200, Dwelling = dwelling};
            var policy2 = new Policy {Name = "Gold", PolicyType = PolicyTypes.Home, Price = 2300, Dwelling = dwelling2};
            var customer1 = new Customer {Name = "John Do", Age = 22, Sex = SexTypes.Male, Policy = policy1};
            var customer2 = new Customer {Name = "Emily Brown", Age = 32, Sex = SexTypes.Female, Policy = policy2};

            var repository = new RuleRepository();
            repository.Load("Test", x => x.From(typeof (Program).Assembly));
            var ruleSets = repository.GetRuleSets();

            IRuleCompiler compiler = new RuleCompiler();
            ISessionFactory factory = compiler.Compile(ruleSets);
            ISession session = factory.CreateSession();

            session.Insert(policy1);
            session.Insert(policy2);
            session.Insert(customer1);
            session.Insert(customer2);
            session.Insert(dwelling);
            session.Insert(dwelling2);

            customer1.Age = 10;
            session.Update(customer1);

            session.Retract(customer2);

            session.Fire();

            session.Insert(customer2);

            session.Fire();

            customer1.Age = 30;
            session.Update(customer1);

            session.Fire();
        }
Ejemplo n.º 13
0
        // sort the list based on the refines from the page choices
        public List <ListObjectSorted> SortList(List <ListObject> listIn)
        {
            List <ListObjectSorted> listOut = new List <ListObjectSorted>();
            List <ListObjectSorted> temp    = new List <ListObjectSorted>();

            // change listin to listout
            foreach (var r in listIn)
            {
                ListObjectSorted newObj = new ListObjectSorted();
                newObj.Address     = r.Address;
                newObj.Description = r.Description.ToString(); // char to string
                if (newObj.Description.Equals("N"))            // expand out string
                {
                    newObj.Description = "New";
                }
                else
                {
                    newObj.Description = "Second Hand";
                }
                newObj.NotFullMP = r.NotFullMP.ToString(); // char to string
                if (newObj.NotFullMP.Equals("N"))          // expand out string
                {
                    newObj.NotFullMP = "No";
                }
                else
                {
                    newObj.NotFullMP = "Yes";
                }
                newObj.PostCode = r.PostCode;
                newObj.Price    = r.Price;
                newObj.SoldOn   = r.SoldOn;
                listOut.Add(newObj);
            }
            // if new property dwelling
            if (Dwelling.Equals("New Property"))
            {
                foreach (var r in listOut)
                {
                    if (r.Description.Equals("New"))
                    {
                        temp.Add(r);
                    }
                }
                listOut.Clear();
                listOut.AddRange(temp);
                temp.Clear();
            }
            // if second hand property dwelling
            if (Dwelling.Equals("Second Hand Property"))
            {
                foreach (var r in listOut)
                {
                    if (r.Description.Equals("Second Hand"))
                    {
                        temp.Add(r);
                    }
                }
                listOut.Clear();
                listOut.AddRange(temp);
                temp.Clear();
            }
            // if market price yes
            if (MarketPrice.Equals("Yes"))
            {
                foreach (var r in listOut)
                {
                    if (r.NotFullMP.Equals("Yes"))
                    {
                        temp.Add(r);
                    }
                }
                listOut.Clear();
                listOut.AddRange(temp);
                temp.Clear();
            }
            // if market price no
            if (MarketPrice.Equals("No"))
            {
                foreach (var r in listOut)
                {
                    if (r.NotFullMP.Equals("No"))
                    {
                        temp.Add(r);
                    }
                }
                listOut.Clear();
                listOut.AddRange(temp);
                temp.Clear();
            }
            // if county is dublin sort by postal code
            if (County.Equals("Dublin"))
            {
                if (!PostCode.Equals("All"))
                {
                    string pc = "";
                    if (PostCode.Equals("county dublin"))
                    {
                        pc = PostCode;
                        foreach (var r in listOut)
                        {
                            if (r.PostCode.Equals(pc))
                            {
                                temp.Add(r);
                            }
                        }
                    }
                    else
                    {
                        pc = "dublin " + PostCode;
                        foreach (var r in listOut)
                        {
                            if (r.PostCode.Equals(pc))
                            {
                                temp.Add(r);
                            }
                        }
                    }
                    listOut.Clear();
                    listOut.AddRange(temp);
                    temp.Clear();
                }
            }
            // take out any with price greater than max price
            foreach (var r in listOut)
            {
                if (r.Price <= PriceValue)
                {
                    temp.Add(r);
                }
            }
            listOut.Clear();
            listOut.AddRange(temp);
            temp.Clear();
            // return list
            return(listOut);
        }