コード例 #1
0
        // GET: api/Apatment
        //IEnumerable<Appartment> Get()
        public string Get()
        {
            Appartment P      = new Appartment("New", "New", 2);
            string     output = P.GetAp();

            return(output);
        }
コード例 #2
0
        // PUT: api/Apatment/5CMDnewtitle
        public string Put(string Input)
        {
            string[]   Data = Input.Split(new string[] { "CMD" }, StringSplitOptions.None);
            Appartment temp = new Appartment("temp", "temp", 0);

            return(temp.Update(Convert.ToInt32(Data[0]), Data[1]));
        }
コード例 #3
0
        static void Main(string[] args)
        {
            RealEstateAgent immo = new RealEstateAgent();

            Appartment app1 = new Appartment("Appartementstraat 10", 1, 180000);
            Appartment app2 = new Appartment("Appartementstraat 15", 3, 320000);

            House house1 = new House("Huisstraat 10", 1, 220000);
            House house2 = new House("Huisstraat 31", 3, 380000);

            immo.AddAppartment(app1);
            immo.AddAppartment(app2);

            immo.AddHouse(house1);
            immo.AddHouse(house2);

            Console.WriteLine("All appartments for sale:");
            immo.ShowAllAppartments();

            Console.WriteLine("----------------");

            Console.WriteLine("All houses for sale:");
            immo.ShowAllHouses();

            Console.ReadLine();
        }
コード例 #4
0
        public async Task <IHttpActionResult> PostAppartment(Appartment appartment)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Appartments.Add(appartment);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (AppartmentExists(appartment.AppartmentNo))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = appartment.AppartmentNo }, appartment));
        }
コード例 #5
0
        public async Task <IHttpActionResult> PutAppartment(int id, Appartment appartment)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != appartment.AppartmentNo)
            {
                return(BadRequest());
            }

            db.Entry(appartment).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AppartmentExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #6
0
        public async Task <ActionResult <Appartment> > PostAppartment(Appartment appartment)
        {
            _context.Appartments.Add(appartment);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetAppartment", new { id = appartment.AppartmentId }, appartment));
        }
コード例 #7
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Title,Description,Price,Owner,Photo,PhotoPath")] Appartment appartment)
        {
            if (id != appartment.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(appartment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AppartmentExists(appartment.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(appartment));
        }
コード例 #8
0
        //CRUD of Appartment
        public List <Appartment> GetAppartment()
        {
            string sqlString = @"
SELECT [ID], [AppartmentNo], [Area]
FROM [Appartment]
";

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand(sqlString, connection);

                connection.Open();
                SqlDataReader     reader      = command.ExecuteReader();
                List <Appartment> appartments = new List <Appartment>();
                while (reader.Read())
                {
                    Appartment appartment = new Appartment
                    {
                        ID           = int.Parse(reader["ID"].ToString()),
                        AppartmentNo = int.Parse(reader["AppartmentNo"].ToString()),
                        Area         = int.Parse(reader["Area"].ToString()),
                    };
                    appartment.Humans = new HumanDbCommands().GetHumansByApartment(appartment.ID);

                    appartments.Add(appartment);
                }
                return(appartments);
            }
        }
コード例 #9
0
        public async Task <IActionResult> PutAppartment(Guid id, Appartment appartment)
        {
            if (id != appartment.AppartmentId)
            {
                return(BadRequest());
            }

            _context.Entry(appartment).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AppartmentExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #10
0
        public async Task <IActionResult> Create(AppartmentViewModel appartment)
        {
            if (appartment.Photo != null)
            {
                BlobContainerClient containerClient = _blobService.GetBlobContainerClient("home");
                Stream          stream      = appartment.Photo.OpenReadStream();
                string          fileName    = $"{Guid.NewGuid().ToString()}{appartment.Photo.FileName}";
                BlobContentInfo blobContent = await containerClient.UploadBlobAsync(fileName, stream);

                BlobClient blobClient = containerClient.GetBlobClient(fileName);
                string     url        = blobClient.Uri.AbsoluteUri;
                Appartment newAppart  = new Appartment();
                newAppart.Title       = appartment.Title;
                newAppart.Description = appartment.Description;
                newAppart.Owner       = appartment.Owner;
                newAppart.Price       = appartment.Price;
                newAppart.Photo       = fileName;
                newAppart.PhotoPath   = url;
                _context.Add(newAppart);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(appartment));
        }
コード例 #11
0
        public async System.Threading.Tasks.Task <ActionResult> Index()
        {
            mBuilding = TempData["myBuilding"] as Building;
            TempData.Keep("myBuilding");

            var query = ParseObject.GetQuery("Building").WhereEqualTo("objectId", mBuilding.id);


            IEnumerable <ParseObject> results = await query.FindAsync();

            foreach (ParseObject userData in results)
            {
                var appQuery = ParseObject.GetQuery("Appartment").WhereEqualTo("Building", userData);
                IEnumerable <ParseObject> appResults = await appQuery.FindAsync();

                mAppList         = new AppartmentsList();
                mAppList.appList = new List <Appartment>();
                Appartment tempApp;
                foreach (ParseObject pObj in appResults)
                {
                    tempApp            = new Appartment();
                    tempApp.name       = pObj.Get <string>("Name");
                    tempApp.objId      = pObj.ObjectId;
                    tempApp.settlement = pObj.Get <float>("Settlement");

                    mAppList.appList.Add(tempApp);
                }

                mAppList.size = mAppList.appList.Count;
            }
            return(View(mAppList));
        }
コード例 #12
0
ファイル: AppartmentDB.cs プロジェクト: roneetkumar/asp.net
        ////search function by AppartmentId
        //public static Appartment SearchRecord(int searchId)
        //{
        //    Appartment app = new Appartment();
        //    SqlConnection conn = UtilityDB.ConnectDB();

        //    SqlCommand cmd = new SqlCommand();

        //    cmd.Connection = conn;
        //    cmd.CommandText = "Select * From Appartments where AppartmentId = @AppartmentId ";
        //    cmd.Parameters.AddWithValue("@AppartmentId", searchId);

        //    SqlDataReader reader = cmd.ExecuteReader();
        //    if (reader.Read())
        //    {
        //        app.AppartmentId = Convert.ToInt32(reader["EmployeeId"]);
        //        app.NumberOfRoom = Convert.ToInt32(reader["NumberOfRoom"]);
        //        app.NumberOfBath = Convert.ToInt32(reader["NumberOfBath"]);
        //        app.NumberOfParking = Convert.ToInt32(reader["NumberOfParking"]);
        //        app.FloorNum = Convert.ToInt32(reader["FloorNum"]);
        //        app.PricePerMonth = Convert.ToInt32(reader["PricePerMonth"]);
        //        app.Description = Convert.ToString(reader["Description"]);
        //        app.RentStatus = Convert.ToString(reader["RentStatus"]);
        //        app.BuildingId = Convert.ToInt32(reader["BuildingId"]);
        //    }
        //    else
        //    {
        //        app = null;
        //    }

        //    conn.Close();
        //    return app;
        //}

        //search more than one record by Int

        public static List <Appartment> SearchRecords(SqlDataReader reader)
        {
            List <Appartment> ListApp = new List <Appartment>();
            Appartment        app;

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    app = new Appartment();
                    app.AppartmentId    = Convert.ToInt32(reader["AppartmentId"]);
                    app.NumberOfRoom    = Convert.ToInt32(reader["NumberOfRoom"]);
                    app.NumberOfBath    = Convert.ToInt32(reader["NumberOfBath"]);
                    app.NumberOfParking = Convert.ToInt32(reader["NumberOfParking"]);
                    app.FloorNum        = Convert.ToInt32(reader["FloorNum"]);
                    app.PricePerMonth   = Convert.ToInt32(reader["PricePerMonth"]);
                    app.Description     = Convert.ToString(reader["Description"]);
                    app.RentStatus      = Convert.ToString(reader["RentStatus"]);
                    app.BuildingId      = Convert.ToInt32(reader["BuildingId"]);

                    ListApp.Add(app);
                }
            }
            else
            {
                ListApp = null;
            }
            return(ListApp);
        }
コード例 #13
0
        public async Task AppartmentCreate_Invalid()
        {
            // Setup
            AppartmentDTO testApt = new AppartmentDTO()
            {
                address = new AddressDTO()
                {
                    buildingNo = "142A",
                    street     = "Test Road"
                }
            };
            Appartment apt = _mapper.Map <Appartment>(testApt);

            if (!new AppConfigration().IsRealMongoDbUsed())
            {
                _mockRepo.Setup(repo => repo.CreateAppartment(apt))
                .Verifiable();
            }

            // Act
            var result = await _controller.Post(testApt);

            // Assert
            var actionResult           = Assert.IsType <ActionResult <AppartmentDTO> >(result);
            var badRequestObjectResult = Assert.IsType <BadRequestObjectResult>(actionResult.Result);
            var returnValue            = Assert.IsType <AppartmentDTO>(badRequestObjectResult.Value);
        }
コード例 #14
0
        public IActionResult Edit(int id)
        {
            List <Appartment> appartments = new AppartmentDbCommands().GetAppartment();
            Appartment        appartment  = appartments.First(a => a.ID == id);

            return(View(appartment));
        }
コード例 #15
0
        public async Task <ActionResult> Add()
        {
            int pos = Int32.Parse(Request.Form["iden"]);

            float addAmountSt = float.Parse(Request.Form["addAmount"], CultureInfo.InvariantCulture.NumberFormat);
            float negAmountSt = float.Parse(Request.Form["negAmount"], CultureInfo.InvariantCulture.NumberFormat);

            mBuilding = TempData["myBuilding"] as Building;
            TempData.Keep("myBuilding");

            var query = ParseObject.GetQuery("Building").WhereEqualTo("objectId", mBuilding.id);


            IEnumerable <ParseObject> results = await query.FindAsync();

            foreach (ParseObject userData in results)
            {
                var appQuery = ParseObject.GetQuery("Appartment").WhereEqualTo("Building", userData);
                IEnumerable <ParseObject> appResults = await appQuery.FindAsync();

                mAppList         = new AppartmentsList();
                mAppList.appList = new List <Appartment>();
                Appartment tempApp;
                foreach (ParseObject pObj in appResults)
                {
                    tempApp            = new Appartment();
                    tempApp.name       = pObj.Get <string>("Name");
                    tempApp.objId      = pObj.ObjectId;
                    tempApp.settlement = pObj.Get <float>("Settlement");

                    mAppList.appList.Add(tempApp);
                }

                mAppList.size = mAppList.appList.Count;

                var queryApp = ParseObject.GetQuery("Appartment").WhereEqualTo("objectId", mAppList.appList[pos].objId);


                IEnumerable <ParseObject> resultsApp = await queryApp.FindAsync();

                foreach (ParseObject appObj in resultsApp)
                {
                    if (negAmountSt == 0)
                    {
                        appObj["Settlement"] = appObj.Get <float>("Settlement") + addAmountSt;
                    }
                    else
                    {
                        appObj["Settlement"] = appObj.Get <float>("Settlement") - negAmountSt;
                    }

                    await appObj.SaveAsync();
                }
            }



            return(RedirectToAction("Index", "AdminNavigation"));
        }
コード例 #16
0
        protected void btnSubmitFlat_Click(object sender, EventArgs e)
        {
            Appartment CurrentAppartment = CreateAppartmentObject();

            PropertyData.UploadAd_Appartment(CurrentAppartment);
            UploadImages();
            Response.Redirect("Index.aspx");
        }
コード例 #17
0
        public ActionResult DeleteConfirmed(int id)
        {
            Appartment appartment = db.Appartments.Find(id);

            db.Appartments.Remove(appartment);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #18
0
        public async Task <bool> UpdateAppartment(Appartment apt)
        {
            FilterDefinition <Appartment> filter = Builders <Appartment> .Filter.Eq(_apt => _apt.id, apt.id);

            ReplaceOneResult res = await _context.Appartments.ReplaceOneAsync(filter : filter, replacement : apt);

            return(res.IsAcknowledged && res.ModifiedCount > 0);
        }
コード例 #19
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            Appartment appartment = await db.Appartments.FindAsync(id);

            db.Appartments.Remove(appartment);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
コード例 #20
0
        // POST: api/Apatment/TitleCMDAddressCMDNbrofRooms
        // CMD is used for string split
        public string Post(string Input)
        {
            string[]   Data = Input.Split(new string[] { "CMD" }, StringSplitOptions.None);
            Appartment P    = new Appartment(Data[0], Data[1], Convert.ToInt32(Data[2]));

            P.Add();

            return("New Appartment Id=" + P.Id + " Was Created");
        }
コード例 #21
0
        /// <summary>
        /// Удаление Квартиры по Id
        /// </summary>
        /// <param name="id">Id квартиры</param>
        /// <returns></returns>
        public async Task Delete(int id)
        {
            Appartment appartment = await _appartmentContext.Appartments.FindAsync(id);

            if (appartment != null)
            {
                _appartmentContext.Appartments.Remove(appartment);
            }
        }
コード例 #22
0
 private void DeleteAppartment()
 {
     if (this.selectedAppartment != null)
     {
         context.DeleteAppartment(selectedAppartment.AppartmentId);
         context.DataContext.SaveChanges();
         Appartments.Remove(selectedAppartment);
         selectedAppartment = null;
     }
 }
コード例 #23
0
        public async Task <IHttpActionResult> GetAppartment(int id)
        {
            Appartment appartment = await db.Appartments.FindAsync(id);

            if (appartment == null)
            {
                return(NotFound());
            }

            return(Ok(appartment));
        }
コード例 #24
0
 public ActionResult Edit([Bind(Include = "AppartmentId,NumberOfRoom,NumberOfBath,NumberOfParking,FloorNum,PricePerMonth,Description,RentStatus,BuildingId")] Appartment appartment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(appartment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.BuildingId = new SelectList(db.Buildings, "BuildingId", "Address", appartment.BuildingId);
     return(View(appartment));
 }
コード例 #25
0
        public void InsertAppartment(Appartment appartment)
        {
            string query = "INSERT INTO  dbo.Appartment(AppartmentNo,Area) VALUES(@AppartmentNo,@Area)";

            using (SqlConnection cn = new SqlConnection(connectionString))

            {
                cn.Open();
                cn.Execute(query, appartment);
                cn.Close();
            }
        }
コード例 #26
0
        public void UpdateAppartment(int oldID, Appartment appartment)
        {
            string query = "UPDATE Appartament SET AppartmentNo = @NewAppartmentNo, Are = @Area, HumansName = @HumansName BirthDate = @BirthDate WHERE ID = @oldID";

            using (SqlConnection connection = new SqlConnection(connectionString))

            {
                connection.Open();

                connection.Execute(query, appartment);
            }
        }
コード例 #27
0
 private void GetAppartmentList()
 {
     using (var api = new BusinessContext())
     {
         Appartments.Clear();
         context.GetAppartmentList();
         selectedAppartment = null;
         foreach (var appartment in context.GetAppartmentList())
         {
             Appartments.Add(appartment);
         }
     }
 }
コード例 #28
0
        public async Task <IHttpActionResult> DeleteAppartment(int id)
        {
            Appartment appartment = await db.Appartments.FindAsync(id);

            if (appartment == null)
            {
                return(NotFound());
            }

            db.Appartments.Remove(appartment);
            await db.SaveChangesAsync();

            return(Ok(appartment));
        }
コード例 #29
0
 public ActionResult Edit([Bind(Include = "Apt_id,Build_id,Manager_id,Tenant_id,Owner_id,Description")] Appartment appartment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(appartment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Build_id   = new SelectList(db.Buildings, "Build_id", "Description", appartment.Build_id);
     ViewBag.Tenant_id  = new SelectList(db.Persons, "P_id", "FirstName", appartment.Tenant_id);
     ViewBag.Manager_id = new SelectList(db.Persons, "P_id", "FirstName", appartment.Manager_id);
     ViewBag.Owner_id   = new SelectList(db.Persons, "P_id", "FirstName", appartment.Owner_id);
     return(View(appartment));
 }
コード例 #30
0
        // GET: Appartments/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Appartment appartment = db.Appartments.Find(id);

            if (appartment == null)
            {
                return(HttpNotFound());
            }
            return(View(appartment));
        }
コード例 #31
0
ファイル: HouseFactory.cs プロジェクト: nirshandileep/RHP
 public static BaseHouse Create(RHP.Common.Enums.HouseType houseType)
 {
     BaseHouse baseHouse;
     switch (houseType)
     {
         case RHP.Common.Enums.HouseType.Dorms:
             baseHouse = new Dorm();
             break;
         case RHP.Common.Enums.HouseType.Appartment:
             baseHouse = new Appartment();
             break;
         case RHP.Common.Enums.HouseType.Condo:
             baseHouse = new Condo();
             break;
         case RHP.Common.Enums.HouseType.FamilyHousing:
             baseHouse = new FamilyHousing();
             break;
         case RHP.Common.Enums.HouseType.House:
             baseHouse = new OnCampusHouse();
             break;
         case RHP.Common.Enums.HouseType.OffCampusAppartment:
             baseHouse = new OffCampusAppartment();
             break;
         case RHP.Common.Enums.HouseType.OffCampusCondo:
             baseHouse = new OffCampusCondo();
             break;
         case RHP.Common.Enums.HouseType.TownHome:
             baseHouse = new TownHome();
             break;
         case RHP.Common.Enums.HouseType.OffCampusHouse:
             baseHouse = new OffCampusHouse();
             break;
         default:
             baseHouse = new Dorm();
             break;
     }
     return baseHouse;
 }