コード例 #1
0
        public void DeleteAppartmentTest()
        {
            //Arrange

            ApartmentService ap = new ApartmentService();
            string           actual;

            //Act

            ap.DeleteAparment("20");

            IList <Apartment> testList = ap.GetAllApartment();

            //Assert

            foreach (var appApartment in testList)
            {
                if (appApartment.Id == 20)
                {
                    actual = "Denne findes";
                }
                else
                {
                    actual = "Findes ikke";
                }
                Assert.AreEqual("Findes ikke", actual);
            }
        }
コード例 #2
0
        public async Task CreateAppartments(int buildingId, int entranceId, int countApartments)
        {
            IApartmentService apartmentService = new ApartmentService();

            IEntranceService entrancetService = new EntranceService();
            int entranceNumber = entrancetService.GetByIdAsync(entranceId).Result.EntranceNumber;

            Random Rand = new Random();

            for (int i = 0; i < countApartments; i++)
            {
                int apartmentByEntranceCounter = (entranceNumber - 1) * 75;


                var res = await apartmentService.CreateApartment(new ApartmentModel()
                {
                    BuildingId      = buildingId,
                    EntranceId      = entranceId,
                    IsOwn           = false,
                    SquareSize      = Rand.Next(50, 100),
                    ApartmentNumber = i + 1 + apartmentByEntranceCounter,
                    PersonId        = 1,
                });
            }
        }
コード例 #3
0
        public void PutAppartmentTest()
        {
            //Arrange

            ApartmentService ap = new ApartmentService();

            var newApartment = new Apartment {
                Price = 5000, Location = "KallePotte", PostalCode = 9999, Size = 555, NoRoom = 777, WashingMachine = false, Dishwasher = false
            };

            ap.UpdateApartment("14", newApartment);
            IList <Apartment> testList = ap.GetAllApartment();
            string            actuel;
            string            expected = "KallePotte";

            //Act&Assert
            foreach (var appApartment in testList)
            {
                if (appApartment.Id == 14)
                {
                    actuel = appApartment.Location;
                    Assert.AreEqual(expected, actuel);
                }
            }
        }
コード例 #4
0
ファイル: ApartmentTest.cs プロジェクト: IliqNikolov/ACM_V2.0
        public async Task TestGetAllApartmentsWithGoodData()
        {
            ACMDbContext     context          = ACMDbContextInMemoryFactory.InitializeContext();
            ApartmentService apartmentService = new ApartmentService(context);
            ACMUser          user             = new ACMUser {
                AppartentNumber = 1
            };
            Apartment apartment1 = new Apartment {
                Number = 1, User = user
            };
            Apartment apartment2 = new Apartment {
                Number = 2
            };
            await context.Apartments.AddAsync(apartment1);

            await context.Apartments.AddAsync(apartment2);

            await context.Users.AddAsync(user);

            await context.SaveChangesAsync();

            List <Models.ApartmentListDTO> list = apartmentService.GetAllApartments();

            Assert.Equal(2, list.Count);
            Assert.Equal(1, list[0].Number);
            Assert.Equal(2, list[1].Number);
            Assert.Equal(1, list[0].RegisteredUsersCount);
            Assert.Equal(0, list[1].RegisteredUsersCount);
        }
コード例 #5
0
ファイル: DatabaseServie.cs プロジェクト: tung17/ASP.NET-CORE
        public DatabaseService()
        {
            var mongoUrl = new MongoUrl(connectionString);
            var client   = new MongoClient(mongoUrl);
            var session  = client.StartSession();

            db = session.Client.GetDatabase("local");
            Task.Run(async() =>
            {
                if (await CollectionExistsAsync("room", db))
                {
                    await db.CreateCollectionAsync("room");
                }
                if (await CollectionExistsAsync("apartment", db))
                {
                    await db.CreateCollectionAsync("apartment");
                }
                if (await CollectionExistsAsync("device", db))
                {
                    await db.CreateCollectionAsync("device");
                }
            });
            deviceModel            = new DeviceService(db);
            roomModel              = new RoomService(db);
            apartmentModel         = new ApartmentService(db);
            apartmentModelJoinRoom = new ApartmentJoinRoomService(db);
        }
コード例 #6
0
ファイル: ApartmentTest.cs プロジェクト: IliqNikolov/ACM_V2.0
        public async Task TestCreateWithGoodData()
        {
            ACMDbContext     context          = ACMDbContextInMemoryFactory.InitializeContext();
            ApartmentService apartmentService = new ApartmentService(context);
            await apartmentService.Create(1);

            Assert.Equal(1, context.Apartments.Count());
        }
コード例 #7
0
ファイル: ApartmentTest.cs プロジェクト: IliqNikolov/ACM_V2.0
        public async Task TestCreateIfTheIDIOk()
        {
            ACMDbContext     context          = ACMDbContextInMemoryFactory.InitializeContext();
            ApartmentService apartmentService = new ApartmentService(context);
            string           id = await apartmentService.Create(1);

            Assert.Equal(1, context.Apartments.Where(x => x.Id == id).FirstOrDefault().Number);
        }
コード例 #8
0
ファイル: ApartmentTest.cs プロジェクト: IliqNikolov/ACM_V2.0
        public async Task TestCreateWithExistingApartment()
        {
            ACMDbContext     context          = ACMDbContextInMemoryFactory.InitializeContext();
            ApartmentService apartmentService = new ApartmentService(context);
            await apartmentService.Create(1);

            await Assert.ThrowsAsync <ACMException>(() => apartmentService.Create(1));
        }
コード例 #9
0
ファイル: ApartmentTest.cs プロジェクト: IliqNikolov/ACM_V2.0
        public void TestGetAllApartmentsWithEmptyData()
        {
            ACMDbContext     context            = ACMDbContextInMemoryFactory.InitializeContext();
            ApartmentService apartmentService   = new ApartmentService(context);
            List <Models.ApartmentListDTO> list = apartmentService.GetAllApartments();

            Assert.Empty(list);
        }
コード例 #10
0
 public void Setup()
 {
     apartmentService        = new ApartmentService(null);
     apartment               = new Apartment();
     apartment.Name          = "Test Name";
     apartment.Location      = new Location();
     apartment.Location.Name = "Test Location Name";
 }
コード例 #11
0
 public ApartmentsMonitorWorker(
     IApartmentsProvider apartmentsProvider,
     IWorkerController workerController,
     ApartmentService apartmentService,
     MonitoringServiceOptions options,
     ILogger logger)
 {
     _apartmentsProvider = apartmentsProvider ?? throw new ArgumentNullException(nameof(apartmentsProvider));
     _workerController   = workerController ?? throw new ArgumentNullException(nameof(workerController));
     _apartmentService   = apartmentService ?? throw new ArgumentNullException(nameof(apartmentService));
     _options            = options ?? throw new ArgumentNullException(nameof(options));
     _logger             = logger ?? throw new ArgumentNullException(nameof(logger));
 }
コード例 #12
0
 private void BindGrid()
 {
     grdBrands.DataSource = ApartmentService.ApartmentInfo_GetByAll(Lang);
     grdBrands.DataBind();
     if (grdBrands.PageCount <= 1)
     {
         grdBrands.PagerStyle.Visible = false;
     }
     else
     {
         grdBrands.PagerStyle.Visible = true;
     }
 }
コード例 #13
0
        protected void DeleteButton_Click(object sender, EventArgs e)
        {
            DataGridItem item = default(DataGridItem);

            for (int i = 0; i < grdBrands.Items.Count; i++)
            {
                item = grdBrands.Items[i];
                if (item.ItemType == ListItemType.AlternatingItem | item.ItemType == ListItemType.Item)
                {
                    if (((CheckBox)item.FindControl("ChkSelect")).Checked)
                    {
                        string strId = item.Cells[1].Text;
                        ApartmentService.ApartmentInfo_Delete(strId);
                    }
                }
            }
            grdBrands.CurrentPageIndex = 0;
            BindGrid();
        }
コード例 #14
0
ファイル: ApartmentTest.cs プロジェクト: IliqNikolov/ACM_V2.0
        public async Task TestGetAppartmentsWithGoodData()
        {
            ACMDbContext     context          = ACMDbContextInMemoryFactory.InitializeContext();
            ApartmentService apartmentService = new ApartmentService(context);
            Apartment        apartment1       = new Apartment {
                Number = 1
            };
            Apartment apartment2 = new Apartment {
                Number = 2
            };
            await context.Apartments.AddAsync(apartment1);

            await context.Apartments.AddAsync(apartment2);

            await context.SaveChangesAsync();

            List <Models.ApartmentListElementDTO> list = apartmentService.GetAppartments();

            Assert.Equal(2, list.Count);
            Assert.Equal("1", list[0].Number);
            Assert.Equal("2", list[1].Number);
        }
コード例 #15
0
        private void LoadSaleApartments()
        {
            string chuoi = "";
            List <ApartmentInfo> listApartmentInfos = new List <ApartmentInfo>();

            listApartmentInfos = ApartmentService.ApartmentInfo_GetByAll("vi");
            if (listApartmentInfos.Count > 0)
            {
                for (int i = 0; i < listApartmentInfos.Count; i++)
                {
                    chuoi += "<div class=\" row \" style=\"line-height: 25px;\">";
                    chuoi += "<h3><span style=\" color: blue;\"> <a href = \" Default2.aspx?mod=" + listApartmentInfos[i].Tag + "\">" + listApartmentInfos[i].Title +
                             "</a> </span></h3>";

                    //cột trái
                    chuoi += "<div class=\"span3\">";
                    chuoi += "<img src=\"" + listApartmentInfos[i].Image1 + "\" />";
                    chuoi += "</div>";
                    //cột phải
                    chuoi += "<div class=\"span6\">";
                    chuoi += "<p>" + listApartmentInfos[i].Description + "</p>";
                    chuoi += "<p>" + "Giá: " + "<span style=\"color: red; font-weight:bold;\">" + listApartmentInfos[0].Price + "</span>" + " VND" + " | " + "Tổng diện tích: " + "<span style=\"color: red; font-weight:bold;\">" + listApartmentInfos[0].TotalArea + "</span>" + " | " +
                             "Diện tích nhà: " + "<span style=\"color: red; font-weight:bold;\">" + listApartmentInfos[0].FloorArea + "</span>" + " | " + "Số phòng ngủ: " + "<span style=\"color: red; font-weight:bold;\">" +
                             listApartmentInfos[0].BedroomNumber + "</span>" + "</p>";
                    chuoi += "<p>" + "<table><tr><td width=\"60%\">Địa chỉ: " + "<span style=\"color: blue; font-weight:bold;\">" + listApartmentInfos[i].Address + "</span>" + "</td><td width=\"40%\">Người đăng: " + "<span style=\"color: blue; font-weight:bold;\">" + listApartmentInfos[i].CreateBy + "</span>" + "</td></tr></table></p>";
                    chuoi += "</div>";
                    chuoi += "</div>";
                    //chuoi += "<hr style=\" border: 1px solid grey;\">";
                }
            }
            else
            {
                chuoi += "<p>" + "Không có dữ liều nào để hiển thị </p>";
            }
            ltrTab1.Text = chuoi;
            //ltrTab2.Text = chuoi;
            listApartmentInfos.Clear();
        }
コード例 #16
0
        private void LoadHome()
        {
            string chuoi = "";
            List <ApartmentInfo> listApartmentInfos = new List <ApartmentInfo>();

            listApartmentInfos = ApartmentService.ApartmentInfo_GetByAll("vi");
            if (listApartmentInfos.Count > 0)
            {
                for (int i = 0; i < listApartmentInfos.Count; i++)
                {
                    chuoi += "<div class=\" row \" style=\" margin-left: 10px; line-height: 20px;\">";
                    chuoi += "<h3 style=\" color: blue;\"> <a href = \" Default2.aspx?mod=" + listApartmentInfos[i].Tag + "\" style=\" color: olive;\">" + listApartmentInfos[i].Title +
                             "</a> </h3>";

                    //cột trái
                    chuoi += "<div class=\"span1\" style=\" width: 135px;\">";
                    chuoi += "<a href=\" " + listApartmentInfos[i].Tag + " \" alt=\" Xem chi tiết \"><img src=\"" + listApartmentInfos[i].Image1 + "\"/></a>";
                    chuoi += "</div>";
                    //cột phải
                    chuoi += "<div class=\"span5\">";
                    chuoi += "<p ><span style=\" color: green;\" >" + listApartmentInfos[i].Description + "</span></p>";
                    chuoi += "<p>" + "Giá: " + "<span style=\"color: red;\">" + listApartmentInfos[0].Price + "</span>" + " VND" + " | " + "Tổng diện tích: " + "<span style=\"color: red;\">" + listApartmentInfos[0].TotalArea + "</span>" + " | " +
                             "Diện tích nhà: " + "<span style=\"color: red;\">" + listApartmentInfos[0].FloorArea + "</span>" + " | " + "Số phòng ngủ: " + "<span style=\"color: red; font-weight:bold;\">" +
                             listApartmentInfos[0].BedroomNumber + "</span>" + "</p>";
                    chuoi += "<p>" + "<table><tr><td width=\"50%\">Địa chỉ: " + "<span style=\"color: blue;\">" + listApartmentInfos[i].Address + "</span>" + "</td><td width=\"50%\">Người đăng: " + "<span style=\"color: blue; \">" + listApartmentInfos[i].CreateBy + "</span>" + "</td></tr></table></p>";
                    chuoi += "</div>";
                    chuoi += "<hr style=\" margin-left: 9px; width: 99%; color: grey\">";
                    chuoi += "</div>";
                }
            }
            else
            {
                chuoi += "<p>" + "Không có dữ liều nào để hiển thị </p>";
            }
            ltrTab1.Text = chuoi;
            listApartmentInfos.Clear();
        }
コード例 #17
0
        public void GetAllApartmentTest()
        {
            //Arrange

            ApartmentService ap = new ApartmentService();

            //Act

            IList <Apartment> aplist = ap.GetAllApartment();
            string            actual;

            if (aplist.Count > 0)
            {
                actual = "Ja";
            }
            else
            {
                actual = "Nej";
            }


            //Assert
            Assert.AreEqual("Ja", actual);
        }
コード例 #18
0
        protected void grdBrands_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            string strCA = e.CommandArgument.ToString();

            switch (e.CommandName)
            {
            case "Edit":
                Insert = false;
                Id     = strCA;
                List <ApartmentInfo> listApartmentInfos = ApartmentService.ApartmentInfo_GetById(Id);
                //txtName.Text = listE[0].Name;
                //txtLogo.Text = listE[0].Logo;
                //imgLogo.ImageUrl = listE[0].Logo.Length > 0 ? listE[0].Logo : "";
                //txtOrd.Text = listE[0].Ord;
                pnView.Visible   = false;
                pnUpdate.Visible = true;
                break;

            case "Delete":
                ApartmentService.ApartmentInfo_Delete(strCA);
                BindGrid();
                break;
            }
        }
コード例 #19
0
 protected void Update_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         ApartmentInfo obj = new ApartmentInfo();
         //obj.Id = Id;
         //obj.Name = txtName.Text;
         //obj.Logo = txtLogo.Text;
         //obj.Ord = txtOrd.Text;
         //obj.Lang = Lang;
         if (Insert == true)
         {
             ApartmentService.ApartmentInfo_Insert(obj);
         }
         else
         {
             ApartmentService.ApartmentInfo_Update(obj);
         }
         BindGrid();
         pnView.Visible   = true;
         pnUpdate.Visible = false;
         Insert           = false;
     }
 }
コード例 #20
0
ファイル: Program.cs プロジェクト: tdu819/District.net.core
        static void Main(string[] args)
        {
            //Эта трехуровневая архитектура буквально выпила мою душу. Она принесла мне огромное количество радости и разочарований. Спасибо.



            //Generator generator = new Generator();
            //var res = generator.CreateBuildings(4);
            //res.Wait();

            IPersonService    personService    = new PersonService();
            IApartmentService apartmentService = new ApartmentService();
            IBuildingService  buildingService  = new BuildingService();

            //Console.WriteLine("Enter someName please:");
            //string s = Console.ReadLine();

            //string someName = "Building Creator";
            string someName = "Name2";


            SquarePrice squarePrice = new SquarePrice();
            //squarePrice.priceForOneM2 = 100;

            var somePerson = personService.FindPersonByName(someName);

            somePerson.Wait();

            var foundApartments = apartmentService.GetApartmentsByPersonId(somePerson.Result.Id);

            foundApartments.Wait();
            foreach (var apartment in foundApartments.Result)
            {
                var tempBuilding = buildingService.GetByIdAsync(apartment.BuildingId);
                tempBuilding.Wait();
                Console.WriteLine($"{somePerson.Result.Name}, {tempBuilding.Result.BuildingNumber} , {apartment.ApartmentNumber},  {apartment.SquareSize}, {apartment.SquareSize * squarePrice.priceForOneM2}, {apartment.OrderDate}, {somePerson.Result.PhoneNumber}");
            }
            Console.WriteLine();

            //find all
            var allPerson = personService.GetAllPersons();

            allPerson.Wait();

            foreach (var person  in allPerson.Result)
            {
                if (person.Id == 1)
                {
                    continue;
                }
                var personApartments = apartmentService.GetApartmentsByPersonId(person.Id);
                personApartments.Wait();
                foreach (var personApartment in personApartments.Result)
                {
                    var tempBuilding = buildingService.GetByIdAsync(personApartment.BuildingId);
                    tempBuilding.Wait();
                    Console.WriteLine($"{person.Name}, {tempBuilding.Result.BuildingNumber}, {personApartment.ApartmentNumber},  {personApartment.OrderDate}, {person.PhoneNumber} {personApartment.SquareSize}, {personApartment.SquareSize * squarePrice.priceForOneM2},");
                }
            }


            //

            //var item = personService.CreatePerson(new PersonModel
            //{
            //    Id = 2,
            //    Name = "Name1",
            //    PhoneNumber = 0670000001,
            //});
            //item.Wait();

            // Buy apartment
            //var person = personService.BuyApartment(3, 9);
            //person.Wait();

            //var item2 = personService.CreatePerson(new PersonModel
            //{
            //    Id = 3,
            //    Name = "Name3",
            //    PhoneNumber = 0670000003,
            //});
            //item2.Wait();



            //var res = apartmentService.CreateApartment(new ApartmentModel()
            //{
            //    ApartmentNumber = 1,
            //    BuildingId = 1,
            //    IsOwn = false,
            //    SquareSize = 12,
            //    EntranceId = 1,
            //    PersonId = 1,
            //});
            //res.Wait();
            //Task<List<ApartmentModel>> apartments = apartmentService.GetAllApartments();
            //apartments.Wait();
            //foreach (var apartment in apartments.Result)
            //{
            //    Console.WriteLine($"{apartment.ApartmentNumber}, {apartment.SquareSize}, {apartment.IsOwn} ");
            //}


            //IPersonService personService = new PersonService();
            ////var res = personService.CreatePerson(new PersonModel()
            ////{
            ////    //Id = 0,
            ////    Name = "Name2",
            ////    PhoneNumber = 0670000002,
            ////});
            ////res.Wait();

            ////res = personService.
            ////res.Wait();

            //Task<List<PersonModel>> persons = personService.GetAllPersons();
            //persons.Wait();
            //foreach (var person in persons.Result)
            //{
            //    Console.WriteLine($"{person.Id}, {person.Name}, {person.PhoneNumber}");
            //}



            Console.WriteLine("End of program");
            Console.ReadLine();
        }
コード例 #21
0
 public PeoplesController(PeopleService peopleService, ApartmentService apartmentService, ApartmentPeopleService apartmentPeopleService)
 {
     _peopleService          = peopleService;
     _apartmentService       = apartmentService;
     _apartmentPeopleService = apartmentPeopleService;
 }
コード例 #22
0
 public LoginPage()
 {
     BindingContext   = viewModel = new LoginPageViewModel();
     apartmentService = new ApartmentService();
     InitializeComponent();
 }
コード例 #23
0
 public LoginPageViewModel()
 {
     service         = new ApartmentService();
     _apartmentNames = service.GetApartments().Result;
 }
コード例 #24
0
 public DatabaseApartmentsProvider(ApartmentService apartmentService)
 {
     _apartmentService = apartmentService ?? throw new ArgumentNullException(nameof(apartmentService));
 }
コード例 #25
0
 public ResidentialsController(ResidentialService residentialService, ApartmentService apartmentService)
 {
     _residentialService = residentialService;
     _apartmentService   = apartmentService;
 }