public UnitOfWork(EasyFindPropertiesEntities dbCtx) { _dbCtx = dbCtx; PropertyType = new PropertyTypeRepository(_dbCtx); AdPriority = new AdPriorityRepository(_dbCtx); AdType = new AdTypeRepository(_dbCtx); PropertyCategory = new PropertyCategoryRepository(_dbCtx); PropertyCondition = new PropertyConditionRepository(_dbCtx); PropertyImage = new PropertyImageRepository(_dbCtx); PropertyPurpose = new PropertyPurposeRepository(_dbCtx); PropertyRating = new PropertyRatingRepository(_dbCtx); Property = new PropertyRepository(_dbCtx); PropertyRequisition = new PropertyRequisitionRepository(_dbCtx); SubscriptionType = new SubscriptionTypeRepository(_dbCtx); Subscription = new SubscriptionRepository(_dbCtx); TagType = new TagTypeRepository(_dbCtx); Tennant = new TennantRepository(_dbCtx); Owner = new OwnerRepository(_dbCtx); Tags = new TagsRepository(_dbCtx); Message = new MessageRepository(_dbCtx); User = new UserRepository(_dbCtx); UserType = new UserTypeRepository(_dbCtx); UserTypeAssoc = new UserTypeAssocRepository(_dbCtx); MessageTrash = new MessageTrashRepository(_dbCtx); Meeting = new MeetingRepository(_dbCtx); MeetingMembers = new MeetingMembersRepository(_dbCtx); }
public async Task AddAsync() { var repo = new PropertyTypeRepository(dbContext); var result = repo.AddAsync(new PropertyTypeModel { Id = 1, Name = "Free" }); Assert.IsNotNull(result); Assert.AreEqual(result.Result.Id, 1); Assert.AreEqual(result.Result.Name, "Free"); }
public async Task GetByIdAsync() { dbContext.PropertyTypeModel.Add(new PropertyTypeModel { Id = 1, Name = "Free" }); dbContext.PropertyTypeModel.Add(new PropertyTypeModel { Id = 2, Name = "Lease" }); dbContext.SaveChanges(); var repo = new PropertyTypeRepository(dbContext); var result = repo.GetByIdAsync(1); Assert.IsNotNull(result); Assert.AreEqual(result.Result.Id, 1); Assert.AreEqual(result.Result.Name, "Free"); }
public async Task DeleteAsync() { dbContext.PropertyTypeModel.Add(new PropertyTypeModel { Id = 1, Name = "Free" }); dbContext.PropertyTypeModel.Add(new PropertyTypeModel { Id = 2, Name = "Lease" }); dbContext.SaveChanges(); var repo = new PropertyTypeRepository(dbContext); var result = repo.DeleteAsync(1); Assert.IsNotNull(result); Assert.AreEqual(dbContext.PropertyTypeModel.Count(), 1); Assert.AreEqual(dbContext.PropertyTypeModel.First(m => m.Id == 2).Id, 2); Assert.AreEqual(dbContext.PropertyTypeModel.First(m => m.Id == 2).Name, "Lease"); }
public async Task UpdateAsync() { dbContext.PropertyTypeModel.Add(new PropertyTypeModel { Id = 1, Name = "Free" }); dbContext.PropertyTypeModel.Add(new PropertyTypeModel { Id = 2, Name = "Lease" }); dbContext.SaveChanges(); var repo = new PropertyTypeRepository(dbContext); var toUpdate = dbContext.PropertyTypeModel.First(m => m.Id == 1); toUpdate.Name = "Freehold"; var result = repo.UpdateAsync(toUpdate); Assert.IsNotNull(result); Assert.AreEqual(dbContext.PropertyTypeModel.First(m => m.Id == 1).Id, 1); Assert.AreEqual(dbContext.PropertyTypeModel.First(m => m.Id == 1).Name, "Freehold"); }
public async Task GetAllAsync() { dbContext.PropertyTypeModel.Add(new PropertyTypeModel { Id = 1, Name = "Free" }); dbContext.PropertyTypeModel.Add(new PropertyTypeModel { Id = 2, Name = "Lease" }); dbContext.SaveChanges(); var repo = new PropertyTypeRepository(dbContext); var result = repo.GetAllAsync().Result.ToList(); Assert.IsNotNull(result); Assert.AreEqual(result.Count, 2); Assert.AreEqual(result[0].Id, 1); Assert.AreEqual(result[0].Name, "Free"); Assert.AreEqual(result[1].Id, 2); Assert.AreEqual(result[1].Name, "Lease"); }