// GET: Apartments/Delete/5 public ActionResult Delete(string id) { ObjectId apartmentId = new ObjectId(id); Apartment apartment = ApartmentRepository.GetApartmentById(apartmentId); return(View(apartment)); }
public UnitOfWork(ISession session) { this.session = session; tx = session.BeginTransaction(); apartmentRepository = new ApartmentRepository(session); dwellerRepository = new DwellerRepository(session); }
public List <apartment> GetListApartment(int status, string search) { return(ApartmentRepository.FindBy(p => ((status == -1 && (p.status == 0 || p.status == 1)) || p.status == status) && (Equals(search, null) || p.city.Contains(search) || p.address.Contains(search) || p.code.Contains(search) || (p.user_profile.full_name).Contains(search) || p.user_profile.phone.Contains(search)) && !p.is_import).Include(p => p.apartment_content).Include(p => p.user_profile).Include(p => p.aparment_image).Include(p => p.apartment_facility).OrderByDescending(p => p.apartment_id).ToList()); }
public BMBuildingController() { _buildingRepo = new BuildingRepository(); _accountRepo = new AccountRepository(); _apartmentRepo = new ApartmentRepository(); _svgDatasource = new SVGDataSource(); }
public List <apartment> GetListApartmentByProjectId(int id) { return(ApartmentRepository .FindBy(p => p.status == 1 && p.project_id == id && !p.is_import) .Include(p => p.aparment_image).Include(p => p.apartment_content) .Include(p => p.apartment_facility).Include(p => p.user_profile).Include(p => p.project.project_content).OrderByDescending(p => p.apartment_id).ToList()); }
public async Task InsertAsync() { // Arrange ApartmentRepository apartmentRepository = new ApartmentRepository(); apartmentRepository.SetDbContext(testContext); int expectedEntitiesBeforeInsertCount = TestData.ApartmentCount; int expectedEntitiesAfterInsertCount = TestData.ApartmentCount + 1; Apartment entityToInsert = new Apartment { Id = 100, MainPhoto = "photo.png", Name = "A100", Description = "A100", Price = 100 }; // Act int actualEntitiesBeforeInsertCount = testContext.Apartments.Count(); await apartmentRepository.InsertAsync(entityToInsert); testContext.SaveChanges(); int actualEntitiesAfterInsertCount = testContext.Apartments.Count(); // Assert Assert.Equal(expectedEntitiesBeforeInsertCount, actualEntitiesBeforeInsertCount); Assert.Equal(expectedEntitiesAfterInsertCount, actualEntitiesAfterInsertCount); Assert.Contains(entityToInsert, testContext.Apartments); }
public void DeleteByIdTest() { // Arrange ApartmentRepository apartmentRepository = new ApartmentRepository(); apartmentRepository.SetDbContext(testContext); Apartment entityToDelete = testContext.Apartments.First(); int idToDelete = entityToDelete.Id; int expectedCountBeforeDelete = TestData.ApartmentCount; int expectedCountAfterDelete = TestData.ApartmentCount - 1; // Act int actualCountBeforeDelete = testContext.Apartments.Count(); apartmentRepository.Delete(idToDelete); testContext.SaveChanges(); int actualCountAfterDelete = testContext.Apartments.Count(); // Assert Assert.Equal(expectedCountBeforeDelete, actualCountBeforeDelete); Assert.Equal(expectedCountAfterDelete, actualCountAfterDelete); Assert.DoesNotContain(testContext.Users, x => x.Id == idToDelete); Assert.DoesNotContain(entityToDelete, testContext.Apartments); }
public ActionResult AddCommentLike(long?ApartmentCommentId) { InfoApartmentCommentResult result = new InfoApartmentCommentResult(); ApartmentRepository.AddApartmentCommentLike((long)ApartmentCommentId, (long)user.ProfileId); result.Comment = ApartmentRepository.GetApartmentComment((long)ApartmentCommentId); result.Apartment = ApartmentRepository.GetApartment((long)result.Comment.ApartmentId); result.Me = ProfileRepository.GetProfile(user.ProfileId); return(PartialView("_InfoComment", result)); }
public List <apartment> GetSimilarApartment(ApartmentModel model) { return(ApartmentRepository.FindBy(p => p.project_id == model.ProjectId && p.no_bedroom == model.NoBedRoom && p.city.Contains(model.City) && p.status == 1 && !p.is_import) .OrderByDescending(p => p.price) .Include(p => p.aparment_image).Include(p => p.apartment_content) .Include(p => p.apartment_facility).Include(p => p.user_profile).Include(p => p.project.project_content) .Skip(0).Take(3) .OrderByDescending(p => p.apartment_id) .ToList()); }
public void RemoveComment(long?id) { ApartmentComment comment = ApartmentRepository.GetApartmentComment((long)id); Apartment apartment = ApartmentRepository.GetApartment((long)comment.ApartmentId); if (comment != null) { if ((comment.ProfileId == user.ProfileId) || (apartment.ProfileId == user.ProfileId)) { ApartmentRepository.RemoveApartmentComment((long)id); } } }
public List <apartment> SearchListApartment(FilterModel filter) { return(ApartmentRepository .FindBy(p => p.status == 1 && !p.is_import && (Equals(filter.Search, null) || p.city.Contains(filter.Search) || p.address.Contains(filter.Search) || (!Equals(p.project_id, null) && p.project.project_content.Any(q => q.name.Contains(filter.Search)))) && filter.FilterArea.MinValue <= p.area && p.area <= filter.FilterArea.MaxValue && filter.FilterPrice.MinValue <= p.price && p.price <= filter.FilterPrice.MaxValue && (filter.FilterRoom.NoBathRoom == 0 || filter.FilterRoom.NoBathRoom == p.no_bathroom) && (filter.FilterRoom.NoBedRoom == 0 || filter.FilterRoom.NoBedRoom == p.no_bedroom) && (filter.FilterFacility.FacilityIds.Count == 0 || filter.FilterFacility.FacilityIds.All(x => p.apartment_facility.Any(y => x == y.facility_id)))) .OrderByDescending(p => p.apartment_id) .Include(p => p.aparment_image).Include(p => p.apartment_content) .Include(p => p.apartment_facility).Include(p => p.user_profile).Include(p => p.project.project_content).ToList()); }
public ActionResult AddComment(ApartmentComment apartmentComment) { InfoApartmentCommentResult result = new InfoApartmentCommentResult(); if (ApartmentRepository.IsApartmentExists((long)apartmentComment.ApartmentId)) { apartmentComment.Date = DateTime.Now; ApartmentRepository.AddApartmentComment(apartmentComment); } result.Me = ProfileRepository.GetProfile(user.ProfileId); result.Apartment = ApartmentRepository.GetApartment((long)apartmentComment.ApartmentId); result.Comment = ApartmentRepository.GetApartmentComment(apartmentComment.ApartmentCommentId); return(PartialView("_InfoComment", result)); }
public ActionResult ConfirmDelete(string id) { try { // TODO: Add delete logic here ObjectId apartmentId = new ObjectId(id); ApartmentRepository.DeleteApartmentById(apartmentId); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public ActionResult Create(Apartment apartment) { try { // TODO: Add insert logic here ApartmentRepository.SaveApartment(apartment); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public ActionResult Edit(string id, Apartment apartment) { try { // TODO: Add update logic here ObjectId apartmentId = new ObjectId(id); ApartmentRepository.UpdateApartment(apartmentId, apartment); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
/// <summary> /// lets the user input parameters to create a apartment /// </summary> /// <param name="address">The apartments address</param> /// <param name="livingArea">The apartments living area</param> /// <param name="monthlyCost">The cost per month of living in the apartment</param> private void CreateApartment(string address, int livingArea, int monthlyCost) { Console.Write("Enter floor number: "); string input = Console.ReadLine(); int.TryParse(input, out int floor); Console.Write("Is there an elevator? (y/n): "); input = Console.ReadLine(); bool hasElevator = (input.ToLower() == "y"); Apartment apartment = new Apartment(address, livingArea, monthlyCost, floor, hasElevator); ApartmentRepository.SaveApartment(apartment); }
public async Task GetByIdAsync() { // Arrange ApartmentRepository apartmentRepository = new ApartmentRepository(); apartmentRepository.SetDbContext(testContext); Apartment expectedEntity = testContext.Apartments.First(); int entityId = expectedEntity.Id; // Act Apartment actualEntity = await apartmentRepository.GetAsync(entityId); // Assert Assert.Equal(expectedEntity, actualEntity); }
public void GetImageByIdTest() { // Arrange ApartmentRepository apartmentRepository = new ApartmentRepository(); apartmentRepository.SetDbContext(testContext); int apartmentId = 2; string expectedImage = "photo2.png"; // Act string actualImage = apartmentRepository.GetImageById(apartmentId); // Assert Assert.Equal(expectedImage, actualImage); }
public MediaManager(UmbracoContext context) { _context = context; _accountFolderRepo = new AccountFolderRepository(); _buildingFolderRepo = new BuildingFolderRepository(); _buildingAssetRepo = new BuildingAssetRepository(); _apartmentAssetRepo = new ApartmentAssetRepository(); _apartmentFolderRepo = new ApartmentFolderRepository(); _buildingRepo = new BuildingRepository(); _accountRepo = new AccountRepository(); _apartmentRepo = new ApartmentRepository(); _assetManager = new AssetManager(); _mediaService = _context.Application.Services.MediaService; _umbracoHelper = new UmbracoHelper(_context); }
public void GetByPredicate() { // Arrange ApartmentRepository apartmentRepository = new ApartmentRepository(); apartmentRepository.SetDbContext(testContext); int expectedEntityCount = TestData.ApartmentFor100Count; Expression <Func <Apartment, bool> > predicateToGet = a => a.Price == 100; IEnumerable <Apartment> expectedEntities = testContext.Apartments.Where(predicateToGet); // Act IEnumerable <Apartment> actualEntities = apartmentRepository.Get(predicateToGet); int actualEntitiesCount = actualEntities.Count(); // Assert Assert.Equal(expectedEntities, actualEntities); Assert.Equal(expectedEntityCount, actualEntitiesCount); }
public ActionResult Info(long?id) { InfoApartmentsViewResult result = new InfoApartmentsViewResult(); var query = ApartmentRepository.GetApartment((long)id); if (ApartmentRepository.IsMyApartment((long)id, (long)user.ProfileId)) { result.MyApartment = true; } else { ApartmentRepository.AddProfileVisit((long)id, (long)user.ProfileId); } result.Apartment = query; result.Apartment.ApartmentVisitors = result.Apartment.ApartmentVisitors.OrderByDescending(m => m.LastDate).ToList(); result.Apartment.ApartmentComments = result.Apartment.ApartmentComments.OrderByDescending(m => m.Date).Take(3).ToList(); result.Me = ProfileRepository.GetProfile(user.ProfileId); return(View(result)); }
/// <summary> /// Lets the user select a residence /// </summary> /// <returns>The selected residence</returns> private static Residence SelectResidence() { List <Residence> residences = new List <Residence>(); List <House> houses = HouseRepository.GetHouses(); List <Apartment> apartments = ApartmentRepository.GetApartments(); residences.AddRange(houses); residences.AddRange(apartments); for (int i = 0; i < residences.Count; i++) { Console.WriteLine($"{i+1}: {residences[i].Address}"); } Console.Write("Select residence: "); string input = Console.ReadLine(); int selectedNumber = int.Parse(input); return(residences[selectedNumber - 1]); }
public void CountTest() { // Arrange ApartmentRepository apartmentRepository = new ApartmentRepository(); apartmentRepository.SetDbContext(testContext); int expectedApartmentCount = TestData.ApartmentCount; int expectedApartmentFor100Count = TestData.ApartmentFor100Count; int expectedApartmentFor200Count = TestData.ApartmentFor200Count; // Act int actualApartmentCount = apartmentRepository.Count(); int actualApartmentFor100Count = apartmentRepository.Count(a => a.Price == 100); int actualApartmentFor200Count = apartmentRepository.Count(a => a.Price == 200); // Assert Assert.Equal(expectedApartmentCount, actualApartmentCount); Assert.Equal(expectedApartmentFor100Count, actualApartmentFor100Count); Assert.Equal(expectedApartmentFor200Count, actualApartmentFor200Count); }
public void DeleteByPredicateTest() { // Arrange ApartmentRepository apartmentRepository = new ApartmentRepository(); apartmentRepository.SetDbContext(testContext); Expression <Func <Apartment, bool> > predicateToDelete = a => a.Price == 100; int expectedCountBeforeDelete = TestData.ApartmentCount; int expectedCountAfterDelete = TestData.ApartmentCount - testData.ApartmentFor100Count; // Act int actualCountBeforeDelete = testContext.Apartments.Count(); apartmentRepository.Delete(predicateToDelete); testContext.SaveChanges(); int actualCountAfterDelete = testContext.Apartments.Count(); // Assert Assert.Equal(expectedCountBeforeDelete, actualCountBeforeDelete); Assert.Equal(expectedCountAfterDelete, actualCountAfterDelete); Assert.DoesNotContain(testContext.Apartments, a => a.Price == 100); }
/// <summary> /// Prints a list of all residences /// </summary> private void ShowResidences() { Console.Clear(); Console.WriteLine("Showing residences..."); List <House> houses = HouseRepository.GetHouses(); List <Apartment> apartments = ApartmentRepository.GetApartments(); Console.WriteLine("Address - Living area - Monthly cost - Floors - Plot area"); foreach (House house in houses) { Console.WriteLine($"{house.Address} - {house.LivingArea} - {house.MonthlyCost} - {house.Floors} - {house.PlotArea}"); } Console.WriteLine("\nAddress - Living area - Monthly cost - Floor - Has elevator"); foreach (Apartment apartment in apartments) { Console.WriteLine($"{apartment.Address} - {apartment.LivingArea} - {apartment.MonthlyCost} - {apartment.Floor} - {apartment.HasElevator}"); } Console.WriteLine("Press enter to continue..."); Console.ReadLine(); }
public List <apartment> GetAllStatusApartment() { return(ApartmentRepository.GetAll().ToList()); }
// GET: Apartments public ActionResult Index() { List <Apartment> apartments = ApartmentRepository.GetApartments(); return(View(apartments)); }
public void SaveApartment(apartment apartment) { ApartmentRepository.Save(apartment); }
public BMBuildingSliderController() { _buildingRepo = new BuildingRepository(); _accountRepo = new AccountRepository(); _apartmentRepo = new ApartmentRepository(); }
public List <apartment> GetListApartmentByUserProfileId(int userProfileId) { return(ApartmentRepository.FindBy(p => p.user_profile_owner_id == userProfileId && !p.is_import).ToList()); }