//create Credit Card form //1 user can have several credit cards stored //GET: Account/PaymentCard public ActionResult Card() { using (var context = new OnlineStoreContext()) { return(View()); } }
public ActionResult UpdateAddress(BillingAddress address) { using (var context = new OnlineStoreContext()) { return(RedirectToAction("Index")); } }
// GET: Product public ActionResult Index() { OnlineStoreContext onlineStoreContext = new OnlineStoreContext(); List <ProductDetail> products = onlineStoreContext.Products.ToList(); return(View(products)); }
private static void InsertProducts() { var bread = new Product() { Name = "Fan", Price = 1500 }; var liquid = new Product[] { new Product { Name = "TV", Price = 30000 }, new Product { Name = "Oven", Price = 10000 } }; using (var context = new OnlineStoreContext()) { context.Products.Add(bread); context.AddRange(liquid); context.SaveChanges(); } }
private static void InsertCustomers() { var customer = new Customer() { Name = "Anna1" }; var customerSet = new Customer[] { new Customer { Name = "Ivan1" }, new Customer { Name = "Pavel1" } }; using (var context = new OnlineStoreContext()) { //context.Customers.Add(customer); context.Add(customer); context.AddRange(customerSet); context.SaveChanges(); } }
public static void Initialize(OnlineStoreContext context) { context.Database.EnsureCreated(); // Look for any students. //if (context.Users.Any()) //{ // return; // DB has been seeded //} var users = new User[] { new User { Name = "Carson", Password = "******" }, new User { Name = "Meredith", Password = "******" }, new User { Name = "Arturo", Password = "******" }, }; context.Users.AddRange(users); context.SaveChanges(); }
protected override void Seed(OnlineStoreContext context) { if (!context.Users.Any(x => x.Role == UserRole.Admin)) { var adminUser = new User { Username = "******", Password = "******", FirstName = "Pesho", LastName = "Bradata", EMail = "[email protected]", Role = UserRole.Admin, Address = new Address() { AddressText = "Server room 1", Town = new Town() { Name = "Plovdiv" } } }; var firstSupplier = new Supplier { Name = "Awful Creatures Ltd.", Phone = "+35929110101", Address = new Address() { AddressText = "Staria Lebed 1", Town = new Town() { Name = "Varna" } } }; context.Users.Add(adminUser); context.Suppliers.Add(firstSupplier); context.SaveChanges(); var demoClient = new User { Username = "******", Password = "******", FirstName = "Mara", LastName = "Hubavicata", EMail = "*****@*****.**", Role = UserRole.Client, ReferalUser = context.Users.First(), Address = new Address() { AddressText = "Carigradsko shose 1", Town = new Town() { Name = "Tutrakan" } } }; context.Users.Add(demoClient); context.SaveChanges(); } }
public static void SeedData(this IApplicationBuilder app) { using (var context = new OnlineStoreContext()) { if (!context.Database.EnsureCreated()) { context.Database.Migrate(); } } }
public ActionResult Cards() { using (var context = new OnlineStoreContext()) { var userId = User.Identity.GetUserId(); var cardsOp = context.PaymentOptions.Where(p => p.CustomerId == userId).ToList(); return(View(cardsOp)); } }
//purpose obtain orders that belong to 1 user; therefore create several orders/customer, therefore create ToList; several orderids are linked to one Customer //there is no order form as this is used to display items that have been ordered //purchaseddetails table-this contains details of items ordered/customer //user logins ensure to view their purchased details. userid is id given to user-user identifier. match the userId (loggin id ) to custoemrid //GET method as we are not modifiying anything public ActionResult Orders() { using (var context = new OnlineStoreContext()) { var userId = User.Identity.GetUserId(); var orders = context.PurchasedDetails.Where(p => p.CustomerId == userId).ToList(); return(View(orders)); } }
public Task Invoke(HttpContext context, IServiceProvider serviceProvider, OnlineStoreContext dbContext) { if (!(context.Session.Keys.Contains("starting"))) { DbInitializer.Initialize(dbContext); context.Session.SetString("starting", "Yes"); } // Call the next delegate/middleware in the pipeline return(_next.Invoke(context)); }
public ViewModelListProduct() { Context = new OnlineStoreContext(); ShowItems = new DelegateCommand(() => this.Show()); ListFilter = new List <string> { "Products", "by Clients" }; }
public static void SeedData(this IApplicationBuilder app) { using (var serviceScope = app.ApplicationServices .GetRequiredService <IServiceScopeFactory>() .CreateScope()) { var context = serviceScope.ServiceProvider.GetService <OnlineStoreContext>(); _context = context; context.Database.Migrate(); MigrateStaticData(); } }
private static void InsertCustomers() { var customer = new Customer { Name = "Nikolay" }; using (var context = new OnlineStoreContext()) { context.Customers.Add(customer); context.SaveChanges(); } }
public ActionResult Addresses() { using (var context = new OnlineStoreContext()) { var userId = User.Identity.GetUserId(); //return a list of billing addresses where the customerid == userid var billingAddresses = context.BillingAddress.Where(p => p.CustomerId == userId).ToList(); return(View(billingAddresses)); } }
public ViewModelListClients() { Context = new OnlineStoreContext(); Show = new DelegateCommand(() => this.ShowItems()); //Начальная инициализация списка с фильтрами. ListFilter = new List <string> { "Clients", "by Managers", "by Status" }; }
public UnitOfWork(OnlineStoreContext context) { _context = context; UserAddress = new UserAddressRepository(_context); Products = new ProductRepository(_context); Orders = new OrderRepository(_context); OrderItems = new OrderItemRepository(_context); ShoppingCarts = new ShoppingCartRepository(_context); ShoppingCartItems = new ShoppingCartItemRepository(_context); }
public AuthController(OnlineStoreContext context, SignInManager <User> signInMgr, UserManager <User> userMgr, IPasswordHasher <User> hasher, ILogger <AuthController> logger, IConfigurationRoot config) { _context = context; _signInMgr = signInMgr; _logger = logger; _userMgr = userMgr; _hasher = hasher; _config = config; }
private static void UpdateProductsDisconnected() { var product = new Product { Id = 1, Name = "Test1", Price = 10M - 10M * 0.1M }; using (var newContext = new OnlineStoreContext()) { newContext.Products.Update(product); newContext.SaveChanges(); } }
private static void SelectCustomers() { using (var context = new OnlineStoreContext()) { string name = "Mikhail"; //var allCustomers = context.Customers // .Where(c => c.Name == name) // .ToList(); var customers = context.Customers.ToList(); foreach (var customer in customers) { Console.WriteLine($"Customer: {customer.Name} has id: {customer.Id}"); } } }
private static void UpdateCustomersDisconnected() { var product = new Product { Id = 1, Name = "TEST", Price = 10m - 10m * 0.1m }; using (var newContext = new OnlineStoreContext()) { newContext.Products.Update(product); newContext.SaveChanges(); } }
private static void SelectCustomers() { using (var context = new OnlineStoreContext()) { string tom = "Tom"; // var allCustomers = context //.Customers //.Where(x=>x.Name==tom) //.ToList(); var customers = context.Customers.ToList(); foreach (var customer in customers) { Console.WriteLine($"Customer{customer.Name} has ID = {customer.Id}"); } } }
private static void SelectCustomer() { using (var context = new OnlineStoreContext()) { //string p = "Mikhail"; //var allCustomers = context // .Customers // .Where(x=> x.Name==p) // .ToList(); var customers = context.Customers.ToList(); foreach (var customer in customers) { Console.WriteLine($"{customer.Id}, {customer.Name}"); } } }
private static void SelectCustomers() { using (var context = new OnlineStoreContext()) { //string alex = "alex 9"; //var allCustomers1 = context.Customers.Where(c=>c.Name == "Alex 11").ToList(); //var allCustomers2 = context.Customers.Where(c => c.Name == alex).ToList(); var customers = context.Customers.ToList(); foreach (var customer in customers) { Console.WriteLine($"Customer '{customer.Name}' has ID = {customer.Id}"); } } }
private static void UpdateProductsDisconnected() { //var product = _context.Products.First(); //product.Price *= 1.1M; var product = new Product() { Id = 1, Name = "Bread", Price = 50M - 50M * 0.1M }; using (var newContext = new OnlineStoreContext()) { newContext.Products.Update(product); newContext.SaveChanges(); } }
public ViewModelClient() { Context = new OnlineStoreContext(); ShowWindowForCreateNewClient = new DelegateCommand(() => this.ShowClientCreationWindow()); CreateNewClient = new DelegateCommand(() => this.CreateClient()); CloseWinCreationNewClient = new DelegateCommand(() => this.CloseWindowCreationNewClient()); ShowWindowForEditSelectedClient = new DelegateCommand(() => this.ShowWindowEditSelectedClient()); EditSelectedClient = new DelegateCommand(() => this.EditClient()); CloseWinEditSelectedClient = new DelegateCommand(() => this.CloseWindowEditSelectedClient()); DeleteClient = new DelegateCommand(() => this.DeleteSelectedClient()); Clients = Context.Clients.ToList(); Managers = Context.Managers.ToList(); Statuses = Context.Status.ToList(); }
//check if the billing address is null. If null redirect to new address. If not null display address; AddressViewModel is found in the accountviewmodel public ActionResult Address(int?addressId = null) { var model = new AddressViewModel() { BillingAddress = new BillingAddress(), CountriesList = CultureInfo.GetCultures(CultureTypes.SpecificCultures) .Select(p => { try { return(new SelectListItem() { Text = new RegionInfo(p.LCID).DisplayName, Value = p.LCID.ToString() }); } catch { return(null); } }) .Where(p => p != null) .DistinctBy(p => p.Text) .OrderBy(p => p.Text) .ToList() }; if (addressId == null) { return(View(model)); } using (var context = new OnlineStoreContext()) { var userId = User.Identity.GetUserId(); var address = context.BillingAddress.Where(p => p.CustomerId == userId).Single(); model.BillingAddress = address; return(View(model)); } }
public ViewModelProduct() { Context = new OnlineStoreContext(); ShowWinCreateProduct = new DelegateCommand(() => this.ShowWindowCreateNewProduct()); CreateNewProduct = new DelegateCommand(() => this.CreateProduct()); CloseWinCreateProduct = new DelegateCommand(() => this.CloseWindowCreateProduct()); ShowWinEditProduct = new DelegateCommand(() => this.ShowWinEditSelectedProduct()); SaveChangesEditProduct = new DelegateCommand(() => this.EditProduct()); CancelChangesEditProduct = new DelegateCommand(() => this.CloseWindowEditSelectedProduct()); DeleteProduct = new DelegateCommand(() => this.DeleteSelectedProduct()); Products = Context.Products.ToList(); SubscriptionTypes = Context.SubscriptionTypes.ToList(); SubscriptionTerms = Context.SubscriptionTerms.ToList(); }
private static void InsertCustomers() { var customer = new Customer { Name = "Mikhail2" }; //_context.Add(customer); //var customerSet = new Customer[] //{ // new Customer { Name = "Nikolay" }, // new Customer {Name = "Vladislav"} //}; using (var context = new OnlineStoreContext()) { //context.Customers.Add(customer); context.Add(customer); //context.AddRange(customerSet); //context.SaveChanges(); } }
private static void InsertProduct() { var product = new Product { Name = "Bread", Price = 10 }; var productSet = new Product[] { new Product { Name = "Milk", Price = 62 }, new Product { Name = "Cheese", Price = 39 } }; using (var context = new OnlineStoreContext()) { context.Products.Add(product); context.Products.AddRange(productSet); context.SaveChanges(); } }