/// <summary> /// Fill listings table with fake data async. /// </summary> public static async Task FillListingsAsync() { var listingsGenerator = new Faker <Listing>() .RuleFor(l => l.City, (f, l) => f.Address.City()) .RuleFor(l => l.State, (f, l) => f.Address.State()) .RuleFor(l => l.Zip, (f, l) => f.Address.ZipCode()) .RuleFor(l => l.AddressLine1, (f, l) => f.Address.FullAddress()) .RuleFor(l => l.AddressLine2, (f, l) => f.Address.SecondaryAddress()) .RuleFor(l => l.Status, (f, l) => f.PickRandom <ListingStatus>()) .RuleFor(l => l.Beds, (f, l) => f.Random.Number(1, 10)) .RuleFor(l => l.Size, (f, l) => f.Random.Double(1, 3000)) .RuleFor(l => l.BuiltYear, (f, l) => f.Date.Past(1000).Year) .RuleFor(l => l.StartingPrice, (f, l) => f.Random.Decimal(1, 1000000)) .RuleFor(l => l.DueDate, (f, l) => f.Date.Future()) .RuleFor(l => l.Description, (f, l) => f.Lorem.Text()); List <Listing> listings = listingsGenerator.Generate(10); foreach (var listing in listings) { await context.Listings.AddAsync(listing); } await context.SaveChangesAsync(); }
public async Task <Address> AddAddressAsync(Address address) { try { dbContext.Address.Add(address); await dbContext.SaveChangesAsync(); } catch (Exception) { throw; } return(address); }
public async Task<House> AddHouseAsync(House house) { try { dbContext.Houses.Add(house); await dbContext.SaveChangesAsync(); } catch(Exception) { throw; } return house; }
public async Task <Ad> AddAdAsync(Ad ad) { try { dbContext.Ads.Add(ad); await dbContext.SaveChangesAsync(); } catch (Exception) { throw; } return(ad); }
public async Task <Estate> AddEstateAsync(Estate estate) { try { dbContext.Estates.Add(estate); await dbContext.SaveChangesAsync(); } catch (Exception) { throw; } return(estate); }
public async Task <Housing> AddHousingAsync(Housing housing) { try { dbContext.Housings.Add(housing); await dbContext.SaveChangesAsync(); } catch (Exception) { throw; } return(housing); }
public async Task <Workplace> AddWorkPlaceAsync(Workplace workplace) { try { dbContext.Workplaces.Add(workplace); await dbContext.SaveChangesAsync(); } catch (Exception) { throw; } return(workplace); }
public async Task <User> AddUserAsync(User user) { try { dbContext.Users.Add(user); await dbContext.SaveChangesAsync(); } catch (Exception) { throw; } return(user); }
public async Task <Host> AddHostAsync(Host host) { try { dbContext.Hosts.Add(host); await dbContext.SaveChangesAsync(); } catch (Exception) { throw; } return(host); }
/// <inheritdoc cref="ICommentRepository.AddCommentAsync(Comment)" /> public async Task AddCommentAsync(Comment comment) { await context.Comments.AddAsync(comment); await context.SaveChangesAsync(); }
/// <inheritdoc cref="IListingRepository.AddListingAsync(Listing)" /> public async Task AddListingAsync(Listing listing) { await context.Listings.AddAsync(listing); await context.SaveChangesAsync(); }
/// <inheritdoc cref="IUserRepository.AddUserAsync(User)" /> public async Task AddUserAsync(User user) { await context.Users.AddAsync(user); await context.SaveChangesAsync(); }