public CartController(bookstoreContext context, CartServices cartServices, IMapper mapper, BookServices bookServices) { _context = context; _cartServices = cartServices; _mapper = mapper; _bookServices = bookServices; }
public BooksController(BookServices bookServices, bookstoreContext bookstoreContext, IMapper mapper, ImageServices imageServices ) { _bookServices = bookServices; _context = bookstoreContext; _mapper = mapper; _imageServices = imageServices; }
public CartRedisController(bookstoreContext context, IConnectionMultiplexer connectionMultiplexer, IMapper mapper, CartServices cartServices, BookServices bookServices) { database = connectionMultiplexer.GetDatabase(); _mapper = mapper; _context = context; _cartServices = cartServices; _bookServices = bookServices; }
public AddressController(bookstoreContext context, CityServices cityServices, UserAddressService userAddressService, UserServices userServices, IMapper mapper) { _context = context; _cityServices = cityServices; _userAddressService = userAddressService; _userServices = userServices; _mapper = mapper; }
public UserAuthController(UserServices userServices, AccessToken accessToken, RefreshToken refreshToken, IMapper mapper, bookstoreContext bookstoreContext) { _userServices = userServices; _accessToken = accessToken; _refreshToken = refreshToken; _mapper = mapper; _bookstoreContext = bookstoreContext; }
public InvoiceController(bookstoreContext context, InvoiceService invoiceService, IMapper mapper, CartServices cartServices, InvoiceDetailsService invoiceDetailsService) { _context = context; _invoiceService = invoiceService; _mapper = mapper; _cartServices = cartServices; _invoiceDetailsService = invoiceDetailsService; }
private static void AddRoles(bookstoreContext context) { IList <Role> roles = new List <Role>(); roles.Add(new Role { RoleName = "Admin", Id = 0 }); roles.Add(new Role { RoleName = "Manager", Id = 1 }); roles.Add(new Role { RoleName = "User", Id = 2 }); roles.Add(new Role { RoleName = "Store", Id = 3 }); context.Roles.AddRange(roles); }
private static void AddUsers(bookstoreContext context) { IList <User> users = new List <User>(); users.Add(new User { Username = "******", Password = "******", RoleId = 1, Email = "*****@*****.**", Name = "Ninh Ngoc Hieu" }); users.Add(new User { Username = "******", Password = "******", RoleId = 2 }); users.Add(new User { Username = "******", Password = "******", RoleId = 3 }); users.Add(new User { Username = "******", Password = "******", RoleId = 4 }); users.Add(new User { Username = "******", Password = "******", RoleId = 4 }); context.Users.AddRange(users); }
public static async Task Main(string[] args) { IHost host = CreateHostBuilder(args).Build(); //writeJsonFile(); using (var scope = host.Services.CreateScope()) { IServiceProvider serviceProvider = scope.ServiceProvider; try { bookstoreContext bookstoreContext = scope.ServiceProvider.GetRequiredService <bookstoreContext>(); await bookstoreContext.Database.MigrateAsync(); await BookStoreSeed.Seed(bookstoreContext); } catch { throw; } } host.Run(); }
private static async void writeJsonFile() { string defaultExtension = ".json"; using (var bookstoreContext = new bookstoreContext()) { List <Role> roles = bookstoreContext.Roles.ToList(); File.WriteAllText("role" + defaultExtension, JsonConvert.SerializeObject(roles)); } using (var bookstoreContext = new bookstoreContext()) { List <User> users = bookstoreContext.Users.ToList(); File.WriteAllText("user" + defaultExtension, JsonConvert.SerializeObject(users, Formatting.None, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }));; } using (var bookstoreContext = new bookstoreContext()) { List <UserAddress> userAddresses = bookstoreContext.UserAddress.ToList(); File.WriteAllText("address" + defaultExtension, JsonConvert.SerializeObject(userAddresses, Formatting.None, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }));; } using (var bookstoreContext = new bookstoreContext()) { List <CityAddress> cityAddresses = bookstoreContext.CityAddresses.ToList(); File.WriteAllText("city" + defaultExtension, JsonConvert.SerializeObject(cityAddresses, Formatting.None, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }));; } using (var bookstoreContext = new bookstoreContext()) { List <DistrictAddress> districtAddresses = bookstoreContext.DistrictAddresses.ToList(); File.WriteAllText("district" + defaultExtension, JsonConvert.SerializeObject(districtAddresses, Formatting.None, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }));; } using (var bookstoreContext = new bookstoreContext()) { List <Ward> wards = bookstoreContext.Ward.ToList(); File.WriteAllText("ward" + defaultExtension, JsonConvert.SerializeObject(wards, Formatting.None, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }));; } using (var bookstoreContext = new bookstoreContext()) { List <Author> authors = bookstoreContext.Author.ToList(); File.WriteAllText("author" + defaultExtension, JsonConvert.SerializeObject(authors, Formatting.None, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }));; } using (var bookstoreContext = new bookstoreContext()) { List <Book> books = bookstoreContext.Book.ToList(); File.WriteAllText("book" + defaultExtension, JsonConvert.SerializeObject(books, Formatting.None, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }));; } using (var bookstoreContext = new bookstoreContext()) { List <BookComment> bookComments = bookstoreContext.BookComment.ToList(); File.WriteAllText("comment" + defaultExtension, JsonConvert.SerializeObject(bookComments, Formatting.None, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }));; } using (var bookstoreContext = new bookstoreContext()) { List <BookImage> bookImages = bookstoreContext.BookImage.ToList(); File.WriteAllText("image" + defaultExtension, JsonConvert.SerializeObject(bookImages, Formatting.None, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }));; } using (var bookstoreContext = new bookstoreContext()) { List <Cart> carts = bookstoreContext.Carts.ToList(); File.WriteAllText("cart" + defaultExtension, JsonConvert.SerializeObject(carts, Formatting.None, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }));; } using (var bookstoreContext = new bookstoreContext()) { List <Category> categories = bookstoreContext.Categories.ToList(); File.WriteAllText("category" + defaultExtension, JsonConvert.SerializeObject(categories, Formatting.None, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }));; } using (var bookstoreContext = new bookstoreContext()) { List <Invoice> invoices = bookstoreContext.Invoices.ToList(); File.WriteAllText("invoice" + defaultExtension, JsonConvert.SerializeObject(invoices, Formatting.None, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }));; } using (var bookstoreContext = new bookstoreContext()) { List <InvoiceDetail> invoiceDetails = bookstoreContext.InvoiceDetails.ToList(); File.WriteAllText("invoice_detail" + defaultExtension, JsonConvert.SerializeObject(invoiceDetails, Formatting.None, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }));; } using (var bookstoreContext = new bookstoreContext()) { List <Status> statuses = bookstoreContext.Statuses.ToList(); File.WriteAllText("status" + defaultExtension, JsonConvert.SerializeObject(statuses, Formatting.None, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }));; } }
public InvoiceController(bookstoreContext context, IMapper mapper, CartServices cartServices) { _context = context; _mapper = mapper; _cartServices = cartServices; }
public RoleController(bookstoreContext context, IMapper mapper) { _context = context; _mapper = mapper; }
public AuthorController(bookstoreContext context, IMapper mapper, AuthorServices authorServices) { _context = context; _mapper = mapper; _authorServices = authorServices; }
public StatusController(bookstoreContext context) { _context = context; }
internal static async Task Seed(bookstoreContext bookstoreContext) { string defaultExtension = ".json"; if (!bookstoreContext.Roles.Any()) { List <Role> roles = JsonSerializer.Deserialize <List <Role> >(File.ReadAllText("role" + defaultExtension)); bookstoreContext.Roles.AddRange(roles); } if (!bookstoreContext.Users.Any()) { List <User> users = JsonSerializer.Deserialize <List <User> >(File.ReadAllText("user" + defaultExtension)); bookstoreContext.Users.AddRange(users); } if (!bookstoreContext.UserAddress.Any()) { List <UserAddress> userAddresses = JsonSerializer.Deserialize <List <UserAddress> >(File.ReadAllText("address" + defaultExtension)); bookstoreContext.UserAddress.AddRange(userAddresses); } if (!bookstoreContext.Categories.Any()) { List <Category> categories = JsonSerializer.Deserialize <List <Category> >(File.ReadAllText("category" + defaultExtension)); bookstoreContext.Categories.AddRange(categories); } if (!bookstoreContext.Author.Any()) { List <Author> authors = JsonSerializer.Deserialize <List <Author> >(File.ReadAllText("author" + defaultExtension)); bookstoreContext.Author.AddRange(authors); } if (!bookstoreContext.CityAddresses.Any()) { List <CityAddress> cityAddresses = JsonSerializer.Deserialize <List <CityAddress> >(File.ReadAllText("city" + defaultExtension)); bookstoreContext.CityAddresses.AddRange(cityAddresses); } if (!bookstoreContext.DistrictAddresses.Any()) { List <DistrictAddress> districtAddresses = JsonSerializer.Deserialize <List <DistrictAddress> >(File.ReadAllText("district" + defaultExtension)); bookstoreContext.DistrictAddresses.AddRange(districtAddresses); } if (!bookstoreContext.Ward.Any()) { List <Ward> wards = JsonSerializer.Deserialize <List <Ward> >(File.ReadAllText("ward" + defaultExtension)); bookstoreContext.Ward.AddRange(wards); } if (!bookstoreContext.Book.Any()) { List <Book> books = JsonSerializer.Deserialize <List <Book> >(File.ReadAllText("book" + defaultExtension)); bookstoreContext.Book.AddRange(books); } if (!bookstoreContext.BookComment.Any()) { List <BookComment> bookComments = JsonSerializer.Deserialize <List <BookComment> >(File.ReadAllText("comment" + defaultExtension)); bookstoreContext.BookComment.AddRange(bookComments); } if (!bookstoreContext.Carts.Any()) { List <Cart> carts = JsonSerializer.Deserialize <List <Cart> >(File.ReadAllText("cart" + defaultExtension)); bookstoreContext.Carts.AddRange(carts); } if (!bookstoreContext.BookImage.Any()) { List <BookImage> bookImages = JsonSerializer.Deserialize <List <BookImage> >(File.ReadAllText("image" + defaultExtension)); bookstoreContext.BookImage.AddRange(bookImages); } if (!bookstoreContext.Invoices.Any()) { List <Invoice> invoices = JsonSerializer.Deserialize <List <Invoice> >(File.ReadAllText("invoice" + defaultExtension)); bookstoreContext.Invoices.AddRange(invoices); } if (!bookstoreContext.InvoiceDetails.Any()) { List <InvoiceDetail> invoiceDetails = JsonSerializer.Deserialize <List <InvoiceDetail> >(File.ReadAllText("invoice_detail" + defaultExtension)); bookstoreContext.InvoiceDetails.AddRange(invoiceDetails); } if (!bookstoreContext.Statuses.Any()) { List <Status> statuses = JsonSerializer.Deserialize <List <Status> >(File.ReadAllText("status" + defaultExtension)); bookstoreContext.Statuses.AddRange(statuses); } await bookstoreContext.SaveChangesAsync(); }
public BookServices(bookstoreContext bookstoreContext, IWebHostEnvironment webHostEnvironment, IMapper mapper, ImageServices imageServices, BookCommentServices bookCommentServices) : base(bookstoreContext, webHostEnvironment, mapper) { _imageServices = imageServices; _bookCommentServices = bookCommentServices; }
public Service(bookstoreContext bookstoreContext, IWebHostEnvironment webHostEnvironment, IMapper mapper) { _bookstoreContext = bookstoreContext; _webHostEnvironment = webHostEnvironment; _mapper = mapper; }
public UserAddressService(bookstoreContext bookstoreContext, IWebHostEnvironment webHostEnvironment, IMapper mapper) : base(bookstoreContext, webHostEnvironment, mapper) { }
public CategoryService(BookServices bookServices, bookstoreContext bookstoreContext, IWebHostEnvironment webHostEnvironment, IMapper mapper) : base(bookstoreContext, webHostEnvironment, mapper) { _bookServices = bookServices; }
public InvoiceDetailsService(bookstoreContext bookstoreContext, IWebHostEnvironment webHostEnvironment, IMapper mapper) : base(bookstoreContext, webHostEnvironment, mapper) { }
public CartServices(bookstoreContext bookstoreContext, IWebHostEnvironment webHostEnvironment, IMapper mapper) : base(bookstoreContext, webHostEnvironment, mapper) { }
public InvoiceDetailController(bookstoreContext context) { _context = context; }