public void Can_Save_LandRegistry() { // Arrange City city = new City(10000, "Zagreb"); Cadastre cadastre = new Cadastre("Trnje", "12345", city); CadastralParticle cadastralParticle = new CadastralParticle(cadastre, "123", 23, "Opis"); LandRegistry landRegistry = new LandRegistry(cadastralParticle); var person = new PhysicalPerson("12345678901", "Ime", "Prezime"); landRegistry.CreatePartitionSpace("123", 12, "Opis etaže", person); LandRegistriesNHRepository landRegistriesNhRepository = new LandRegistriesNHRepository(SessionFactory); // Act LandRegistry fetchedLandRegistry; using (var session = SessionFactory.OpenSession()) { using (var tx = session.BeginTransaction()) { session.Save(city); session.Save(person); session.Save(cadastre); landRegistriesNhRepository.SaveOrUpdate(landRegistry); tx.Commit(); } using (var tx = session.BeginTransaction()) { fetchedLandRegistry = landRegistriesNhRepository.GetByNumberOfCadastralParticle(cadastralParticle.NumberOfCadastralParticle); tx.Commit(); } } // Assert Assert.AreEqual(landRegistry, fetchedLandRegistry, "LandRegistries aren't equal"); Assert.IsTrue(fetchedLandRegistry.PartitionSpaces.Count == 1, "LandRegistry haven't exactly one partition space."); }
public void Can_Save_Bill_To_Db() { // Arrange City city = new City(10000, "Zagreb"); Cadastre cadastre = new Cadastre("Trnje", "12345", city); CadastralParticle cadastralParticle = new CadastralParticle(cadastre, "123", 23, "Opis"); LandRegistry landRegistry = new LandRegistry(cadastralParticle); var person = new PhysicalPerson("12345678901", "Ime", "Prezime") { Address = new Address("Ulica", "1", city) }; var partitionSpace = landRegistry.CreatePartitionSpace("123", 12, "Opis etaže", person); LegalPerson legalPerson = new LegalPerson("12345678902", "Ime") { NumberOfBankAccount = "123456", Address = new Address("Ulica", "2", city) }; BuildingManager buildingManager = new BuildingManager(legalPerson); Building building = new Building(buildingManager) { LandRegistry = landRegistry }; Bill bill = new Bill(legalPerson, building.Reserve, "opis plaćanja", 23) { ReferenceNumber = "123" }; bill.AddBillItem(new BillItem(1, 12.3m, "Opis")); IBillsRepository billsRepository = new BillsNHRepository(SessionFactory); // Act using (var session = SessionFactory.OpenSession()) { using (var transaction = session.BeginTransaction()) { session.Save(city); session.Save(person); session.Save(legalPerson); session.Save(cadastre); session.Save(landRegistry); session.Save(buildingManager); session.Save(building); billsRepository.SaveOrUpdate(bill); transaction.Commit(); } } IList<Bill> billsFromDb = null; using (var session = SessionFactory.OpenSession()) { using (var transaction = session.BeginTransaction()) { billsFromDb = billsRepository.GetAll().ToList(); transaction.Commit(); } } // Assert Assert.IsTrue(billsFromDb.Count == 1, "No Bill from database."); }
/// <summary> /// Konstruktor /// </summary> /// <param name="landRegistry">zemljisna knjiga</param> /// <param name="registryNumber">broj uloška</param> /// <param name="ordinalNumber">redni broj etaze</param> /// <param name="surfaceArea">povrsina etaziranog prostora</param> /// <param name="description">opis etaziranog prostra</param> internal PartitionSpace(LandRegistry landRegistry, string registryNumber, int ordinalNumber, decimal surfaceArea, string description) { this.landRegistry = landRegistry; this.registryNumber = registryNumber; this.ordinalNumber = ordinalNumber; SurfaceArea = surfaceArea; Description = description; Owner = null; }
public static LandRegistry getLandRegistry() { CadastralParticle cadastralParticle = new CadastralParticle(getCadastre(), "123/12", 50, "Zgrada i dvorište"); LandRegistry landRegistryForMock = new LandRegistry(cadastralParticle); Mock<ILandRegistriesRepository> landRegistriesRepositoryMock = new Mock<ILandRegistriesRepository>(); landRegistriesRepositoryMock.Setup(x => x.GetByNumberOfCadastralParticle("123/12")).Returns(landRegistryForMock); return landRegistriesRepositoryMock.Object.GetByNumberOfCadastralParticle("123/12"); }
public void Can_Save_Maintenance_To_DB() { // Arrange var person = new PhysicalPerson("12345678901", "Ime", "Prezime"); MaintenanceRequest maintenanceRequest = new MaintenanceRequest( person , "Kvar na grijanju" , "Grijanje ne radi" , "Prvi kat, stan 2"); City city = new City(10000, "Zagreb"); Cadastre cadastre = new Cadastre("Trnje", "12345", city); CadastralParticle cadastralParticle = new CadastralParticle(cadastre, "123", 23, "Opis"); LandRegistry landRegistry = new LandRegistry(cadastralParticle); var partitionSpace = landRegistry.CreatePartitionSpace("123", 12, "Opis etaže", person); LegalPerson legalPerson = new LegalPerson("12345678902", "Ime"); BuildingManager buildingManager = new BuildingManager(legalPerson); Building building = new Building(buildingManager) { LandRegistry = landRegistry }; RepairService repairService = new RepairService("Popravak grijanja"); Maintenance maintenance = new Maintenance(maintenanceRequest, Urgency.Normal, repairService, building); IMaintenancesRepository maintenancesRepository = new MaintenancesNHRepository(SessionFactory); // Act IList<Maintenance> maintenancesFromDb = null; using (var session = SessionFactory.OpenSession()) { using (var tx = session.BeginTransaction()) { session.Save(person); session.Save(city); session.Save(legalPerson); session.Save(cadastre); session.Save(landRegistry); session.Save(buildingManager); session.Save(building); session.Save(repairService); maintenancesRepository.SaveOrUpdate(maintenance); tx.Commit(); } using (var tx = session.BeginTransaction()) { maintenancesFromDb = maintenancesRepository.GetAll().ToList(); tx.Commit(); } } // Assert Assert.IsTrue(maintenancesFromDb.Count == 1, "No Maintenance from database."); }
public void Can_Read_Reserve_From_Db() { // Arrange City city = new City(10000, "Zagreb"); Cadastre cadastre = new Cadastre("Trnje", "12345", city); CadastralParticle cadastralParticle = new CadastralParticle(cadastre, "123", 23, "Opis"); LandRegistry landRegistry = new LandRegistry(cadastralParticle); var person = new PhysicalPerson("12345678901", "Ime", "Prezime"); var partitionSpace = landRegistry.CreatePartitionSpace("123", 12, "Opis etaže", person); LegalPerson legalPerson = new LegalPerson("12345678902", "Ime") { NumberOfBankAccount = "12332213", Address = new Address("dsa", "2", city) }; BuildingManager buildingManager = new BuildingManager(legalPerson); Building building = new Building(buildingManager) { LandRegistry = landRegistry }; Bill bill = new Bill(legalPerson, building.Reserve, "račun", 23) { ReferenceNumber = "123" }; building.Reserve.AddBillForPayment(bill); // Act using (var session = SessionFactory.OpenSession()) { using (var transaction = session.BeginTransaction()) { session.Save(city); session.Save(cadastre); session.Save(person); session.Save(landRegistry); session.Save(legalPerson); session.Save(buildingManager); session.Save(building); transaction.Commit(); } } IReservesRepository reservesRepository = new ReservesNHRepository(SessionFactory); IList<Reserve> reservesFromDb = null; using (var session = SessionFactory.OpenSession()) { using (var transaction = session.BeginTransaction()) { reservesFromDb = reservesRepository.GetAll().ToList(); transaction.Commit(); } } // Assert Assert.IsTrue(reservesFromDb.Count == 1, "No Reserves from database."); //Assert.IsTrue(reservesFromDb[0].ReserveBills.Count == 1); }
public void Can_Save_AdminJobsVoting_To_DB() { // Arrange City city = new City(10000, "Zagreb"); Cadastre cadastre = new Cadastre("Trnje", "12345", city); CadastralParticle cadastralParticle = new CadastralParticle(cadastre, "123", 23, "Opis"); LandRegistry landRegistry = new LandRegistry(cadastralParticle); var person = new PhysicalPerson("12345678901", "Ime", "Prezime"); var partitionSpace = landRegistry.CreatePartitionSpace("123", 12, "Opis etaže", person); LegalPerson legalPerson = new LegalPerson("12345678902", "Ime"); BuildingManager buildingManager = new BuildingManager(legalPerson); Building building = new Building(buildingManager) { LandRegistry = landRegistry }; AdministrationJobsVoting administrationJobsVoting = new AdministrationJobsVoting( AdministrationJobsType.Regular, building, "Subject", "Description", new DateTime(2011, 11, 11)); AdminJobsVotingsNHRepository adminJobsVotingsNhRepository = new AdminJobsVotingsNHRepository(SessionFactory); // Act AdministrationJobsVoting adminJobsVotingFromDb = null; using (var session = SessionFactory.OpenSession()) { using (var tx = session.BeginTransaction()) { session.Save(city); session.Save(person); session.Save(legalPerson); session.Save(cadastre); session.Save(landRegistry); session.Save(buildingManager); session.Save(building); adminJobsVotingsNhRepository.SaveOrUpdate(administrationJobsVoting); tx.Commit(); } using (var tx = session.BeginTransaction()) { adminJobsVotingFromDb = adminJobsVotingsNhRepository.GetById(administrationJobsVoting.Id); tx.Commit(); } } // Assert Assert.AreEqual(administrationJobsVoting, adminJobsVotingFromDb, "Two administration jobs voting entities aren't equal."); }
public void SetUp() { cadastre = new Cadastre("Trešnjevka", "332134", new City(10000, "Zagreb")); cadastralParticle = new CadastralParticle(cadastre, "123", 120, "opis"); landRegistry = new LandRegistry(cadastralParticle); var buildingManager = new BuildingManager(new LegalPerson("12345678903", "Upravitelj")); building = new Building(buildingManager) { LandRegistry = landRegistry }; partitionSpace1 = landRegistry.CreatePartitionSpace("123", 23, "Stan 1", new PhysicalPerson("12345678903", "Mile1", "Milic")); partitionSpace2 = landRegistry.CreatePartitionSpace("123", 23, "Stan 2", new PhysicalPerson("12345678904", "Mile2", "Milic")); partitionSpace3 = landRegistry.CreatePartitionSpace("123", 23, "Stan 3", new PhysicalPerson("12345678905", "Mile3", "Milic")); partitionSpace4 = landRegistry.CreatePartitionSpace("123", 23, "Stan 4", new PhysicalPerson("12345678906", "Mile4", "Milic")); }
public void Can_Save_Building_To_DB() { // Arrange City city = new City(10000, "Zagreb"); Cadastre cadastre = new Cadastre("Trnje", "12345", city); CadastralParticle cadastralParticle = new CadastralParticle(cadastre, "123", 23, "Opis"); LandRegistry landRegistry = new LandRegistry(cadastralParticle); var person = new PhysicalPerson("12345678901", "Ime", "Prezime"); var partitionSpace = landRegistry.CreatePartitionSpace("123", 12, "Opis etaže", person); LegalPerson legalPerson = new LegalPerson("12345678902", "Ime"); BuildingManager buildingManager = new BuildingManager(legalPerson); Building building = new Building(buildingManager) { LandRegistry = landRegistry }; BuildingsNHRepository buildingsNhRepository = new BuildingsNHRepository(SessionFactory); // Act Building buildingFromDb = null; using (var session = SessionFactory.OpenSession()) { using (var tx = session.BeginTransaction()) { session.Save(city); session.Save(person); session.Save(legalPerson); session.Save(cadastre); session.Save(landRegistry); session.Save(buildingManager); buildingsNhRepository.SaveOrUpdate(building); tx.Commit(); } using (var tx = session.BeginTransaction()) { buildingFromDb = buildingsNhRepository.GetById(building.Id); tx.Commit(); } } // Assert Assert.AreEqual(building, buildingFromDb, "Two building entities aren't equal."); }
public void SetUp() { cadastre = new Cadastre("Trešnjevka", "332134", new City(10000, "Zagreb")); cadastralParticle = new CadastralParticle(cadastre, "123", 120, "opis"); landRegistry = new LandRegistry(cadastralParticle); }
public ActionResult Create(int buildingId, CreateModel createModel) { if (!User.IsInRole("buildingmanager")) { return new HttpUnauthorizedResult(); } var building = buildingsRepository.GetById(buildingId); if(building == null) { return HttpNotFound(); } if (ModelState.IsValid) { // provjeri da li vec postoji katastarska cestica pod tim brojem var landRegistryModel = createModel.LandRegistry; LandRegistry landRegistry = landRegistriesRepository.GetByNumberOfCadastralParticle(landRegistryModel.NumberOfCadastralParticle); if (landRegistry == null) { try { Cadastre cadastre = cadastresRepository.GetById(landRegistryModel.Cadastre); CadastralParticle cadastralParticle = new CadastralParticle(cadastre, landRegistryModel.NumberOfCadastralParticle, landRegistryModel.SurfaceArea, landRegistryModel.Description); landRegistry = new LandRegistry(cadastralParticle); landRegistriesRepository.SaveOrUpdate(landRegistry); building.LandRegistry = landRegistry; return RedirectToAction("landregistry", new { Id = landRegistry.Id }); } catch (BusinessRulesException ex) { ex.CopyTo(ModelState); } } else { ModelState.AddModelError("NumberOfCadastralParticle", "Zemljisna knjiga sa takvim brojem katastarske cestice već postoji."); } } createModel.LandRegistry.Cities = new SelectList(citiesRepository.GetCitiesWithCadastres(), "Id", "Name", createModel.LandRegistry.City); createModel.Roles = Roles.GetRolesForUser(); createModel.CurrentRole = "buildingmanager"; createModel.Links = new LinksModel {Id = buildingId, Links = NavLinksGenerator.GetManagerLinks(building)}; return View(createModel); }