diff --git a/Angular-UrbanBazaar/src/app/app-routing.module.ts b/Angular-UrbanBazaar/src/app/app-routing.module.ts index b41868d..72e214b 100644 --- a/Angular-UrbanBazaar/src/app/app-routing.module.ts +++ b/Angular-UrbanBazaar/src/app/app-routing.module.ts @@ -1,21 +1,29 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; import { LoginComponent } from './auth/login/login.component'; +import { SignUpComponent } from './auth/sign-up/sign-up.component'; import { CartComponent } from './components/cart/cart.component'; import { HomeComponent } from './components/home/home.component'; +import { MemberlistComponent } from './components/memberlist/memberlist.component'; import { UserProfileDetailsComponent } from './components/user-profile-details/user-profile-details.component'; -import { UserShowComponent } from './components/user-show/user-show.component'; const routes: Routes = [ - {path: '', component: LoginComponent}, - {path: 'home', component: HomeComponent}, - {path: 'showAllUsers', component: UserShowComponent}, - {path: 'profile', component: UserProfileDetailsComponent}, - {path: 'showCart', component: CartComponent}, + { path: '', component: LoginComponent}, + { path: 'login', component: LoginComponent}, + { path: 'signup', component: SignUpComponent}, + { path: 'user-profile-details', component: UserProfileDetailsComponent}, + { path: 'memberlist', component: MemberlistComponent}, + { path: 'showCart', component: CartComponent}, + { path: 'home', component: HomeComponent, + children: [ + { path: 'user-profile-details', component: UserProfileDetailsComponent, outlet: 'user'}, + { path: 'memberlist', component: MemberlistComponent, outlet: 'member'} + ] + } ]; @NgModule({ - imports: [RouterModule.forRoot(routes)], + imports: [RouterModule.forRoot(routes ,{ useHash: true })], exports: [RouterModule] diff --git a/Angular-UrbanBazaar/src/app/app.module.ts b/Angular-UrbanBazaar/src/app/app.module.ts index 8b54043..ac81ea0 100644 --- a/Angular-UrbanBazaar/src/app/app.module.ts +++ b/Angular-UrbanBazaar/src/app/app.module.ts @@ -1,11 +1,9 @@ import { NgModule } from '@angular/core'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { BrowserModule } from '@angular/platform-browser'; - import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; import { HttpClientModule } from '@angular/common/http'; -import { UserShowComponent } from './components/user-show/user-show.component'; import { UserProfileDetailsComponent } from './components/user-profile-details/user-profile-details.component'; import { PageNavBarComponent } from './components/page-nav-bar/page-nav-bar.component'; import { HomeComponent } from './components/home/home.component'; @@ -14,35 +12,16 @@ import { MatInputModule } from '@angular/material/input'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatCardModule } from '@angular/material/card'; import { MatButtonModule } from '@angular/material/button'; +import { MatDividerModule } from '@angular/material/divider'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { FlexLayoutModule } from '@angular/flex-layout'; import { LoginComponent } from './auth/login/login.component'; import { SignUpComponent } from './auth/sign-up/sign-up.component'; -import { RouterModule, Routes } from '@angular/router'; -import { HttpModule } from '@angular/http'; import { MemberlistComponent } from './components/memberlist/memberlist.component'; -const appRoutes : Routes = -[ - {path:'',component:LoginComponent}, - {path:'login',component:LoginComponent}, - {path:'signup',component:SignUpComponent}, - {path:'user-profile-details',component:UserProfileDetailsComponent}, - {path:'memberlist',component:MemberlistComponent}, - {path:'home',component:HomeComponent, -children: [ - {path:'user-profile-details',component:UserProfileDetailsComponent,outlet:'user'}, - {path:'memberlist',component:MemberlistComponent,outlet:'member'} - -] -} - - - ] @NgModule({ declarations: [ AppComponent, - UserShowComponent, UserProfileDetailsComponent, PageNavBarComponent, HomeComponent, @@ -53,6 +32,7 @@ children: [ ], imports: [ BrowserModule, + BrowserAnimationsModule, AppRoutingModule, FormsModule, ReactiveFormsModule, @@ -62,10 +42,7 @@ children: [ MatInputModule, MatCardModule, MatButtonModule, - BrowserAnimationsModule,AppRoutingModule, - RouterModule.forRoot(appRoutes,{ useHash: true }), - FormsModule, - HttpModule, + MatDividerModule, ], providers: [], bootstrap: [AppComponent] diff --git a/Angular-UrbanBazaar/src/app/auth/sign-up/sign-up.component.ts b/Angular-UrbanBazaar/src/app/auth/sign-up/sign-up.component.ts index 7ba8690..5d98a6f 100644 --- a/Angular-UrbanBazaar/src/app/auth/sign-up/sign-up.component.ts +++ b/Angular-UrbanBazaar/src/app/auth/sign-up/sign-up.component.ts @@ -7,35 +7,31 @@ import { UserService } from 'src/app/services/user.service'; @Component({ selector: 'app-sign-up', templateUrl: './sign-up.component.html', - styleUrls: ['./sign-up.component.css'] + styleUrls: ['./sign-up.component.css'], }) export class SignUpComponent implements OnInit { + user: User; + tys: string = 't'; + temp: Observable; - user :User; - tys :string="t" - temp : Observable; - - isFormSubmitted : boolean; - public signup(signupForm : NgForm) { + isFormSubmitted: boolean; + public signup(signupForm: NgForm) { if (signupForm.invalid) { - alert("Kindly enter all details") + alert('Kindly enter all details'); return; } - this.isFormSubmitted=true; - - this._userservice.addUser(this.user).subscribe(x => { this.tys="y"; alert("Signup Successful") - if(this.tys=="t") - alert("not")}); - - - } - constructor(private _userservice:UserService) { - this.user=new User(); - this.isFormSubmitted=false; - } + this.isFormSubmitted = true; - ngOnInit(): void { + this._userservice.addUser(this.user).subscribe((x) => { + this.tys = 'y'; + alert('Signup Successful'); + if (this.tys == 't') alert('not'); + }); + } + constructor(private _userservice: UserService) { + this.user = new User(); + this.isFormSubmitted = false; } - + ngOnInit(): void {} } diff --git a/Angular-UrbanBazaar/src/app/components/home/home.component.html b/Angular-UrbanBazaar/src/app/components/home/home.component.html index 0c83e9f..24358e8 100644 --- a/Angular-UrbanBazaar/src/app/components/home/home.component.html +++ b/Angular-UrbanBazaar/src/app/components/home/home.component.html @@ -1,50 +1,23 @@ - -       -    -    +   - -     -     -     -     - -

+ +

- - -
- - + + + + +
{{i.productname}}
-

Rs. {{i.productprice}}
- Weight: {{i.productweight}} Kg

+

Rs. {{i.productprice}}
Weight: {{i.productweight}} Kg

- - - - - - - - - \ No newline at end of file + \ No newline at end of file diff --git a/Angular-UrbanBazaar/src/app/components/home/home.component.ts b/Angular-UrbanBazaar/src/app/components/home/home.component.ts index d7a030e..075dd8d 100644 --- a/Angular-UrbanBazaar/src/app/components/home/home.component.ts +++ b/Angular-UrbanBazaar/src/app/components/home/home.component.ts @@ -1,55 +1,52 @@ import { Component, OnInit } from '@angular/core'; import { ProductService } from './../../services/product.service'; -import { Observable } from 'rxjs'; import { Product } from './../../models/product'; -import { ActivatedRoute, Router } from '@angular/router'; +import { Router } from '@angular/router'; import { CartService } from 'src/app/services/cart.service'; -import { Cart } from 'src/app/models/cart'; -import { ThrowStmt } from '@angular/compiler'; @Component({ selector: 'app-home', templateUrl: './home.component.html', - styleUrls: ['./home.component.css'] + styleUrls: ['./home.component.css'], }) export class HomeComponent implements OnInit { - public products: Product[]; public Searchedproducts: Product[]; - searchValue : string = ""; + searchValue: string = ''; - constructor(private productservice: ProductService, - private router: Router, - private cartservice: CartService, - ) {} + constructor( + private productservice: ProductService, + private router: Router, + private cartservice: CartService + ) {} - public showCart(){ + public showCart() { this.router.navigateByUrl('/showCart'); } - addCart(item:any){ + addCart(item: any) { this.cartservice.addtoCart(item); } searchProduct() { - if(this.searchValue=="") { + if (this.searchValue == '') { this.Searchedproducts = this.products; } else { - // this.productservice.searchProduct(this.searchValue).subscribe( - // res => {this.Searchedproducts = res;} - // ); - this.Searchedproducts = this.products.filter(p => p.productname.toLocaleLowerCase().includes(this.searchValue)); + this.Searchedproducts = this.products.filter((p) => + p.productname.toLocaleLowerCase().includes(this.searchValue) + ); } } - EditProfile(){ - this.router.navigateByUrl('/user-profile-details') - } - Members(){ - this.router.navigateByUrl('/memberlist') - } + EditProfile() { + this.router.navigateByUrl('/user-profile-details'); + } + Members() { + this.router.navigateByUrl('/memberlist'); + } ngOnInit(): void { - this.productservice.showAllProduct().subscribe(res=>{ + this.productservice.showAllProduct().subscribe((res) => { this.products = res; this.Searchedproducts = res; - }) -}} + }); + } +} diff --git a/Angular-UrbanBazaar/src/app/components/memberlist/memberlist.component.ts b/Angular-UrbanBazaar/src/app/components/memberlist/memberlist.component.ts index 4915fb4..e47e4ee 100644 --- a/Angular-UrbanBazaar/src/app/components/memberlist/memberlist.component.ts +++ b/Angular-UrbanBazaar/src/app/components/memberlist/memberlist.component.ts @@ -8,82 +8,67 @@ import { UserService } from 'src/app/services/user.service'; @Component({ selector: 'app-memberlist', templateUrl: './memberlist.component.html', - styleUrls: ['./memberlist.component.css'] + styleUrls: ['./memberlist.component.css'], }) export class MemberlistComponent implements OnInit { + currentUser: Observable; + member: MemberUser; + userid: number = this._userservice.currentUser.userid; + public toggleButton: boolean = false; + mem: MemberUser; + isFormSubmitted: boolean = false; - currentUser : Observable; - member : MemberUser; - userid :number =this._userservice.currentUser.userid - public toggleButton: boolean ; - mem :MemberUser - isFormSubmitted : boolean; - public add(addmemForm : NgForm) { - this.mem.userid=this._userservice.currentUser.userid + constructor( + private _memberService: MemberUserService, + private _userservice: UserService + ) { + this.member = new MemberUser(); + this.mem = new MemberUser(); + this.isFormSubmitted = false; + + this.toggleButton = true; + this.currentUser = this._memberService.searchMembersbyUser( + this._userservice.currentUser.userid + ); + this.currentUser.subscribe(); + } + + public add(addmemForm: NgForm) { + this.mem.userid = this._userservice.currentUser.userid; if (addmemForm.invalid) { - alert("Kindly enter all details") + alert('Kindly enter all details'); return; } - this.isFormSubmitted=true; - - this._memberService.addMemberUser(this.mem).subscribe(x => { alert("Member added Successfuly") + this.isFormSubmitted = true; - }) - - // .subscribe(x => {alert("Sign up Successfull")}); - - + this._memberService.addMemberUser(this.mem).subscribe((x) => { + alert('Member added Successfuly'); + }); } - public delete(updateForm : NgForm,v: MemberUser) { - - this._memberService.deleteMemberUser(v.memberid).subscribe(x => { alert("Member deleted Successfuly") - - }) + public delete(updateForm: NgForm, v: MemberUser) { + this._memberService.deleteMemberUser(v.memberid).subscribe((x) => { + alert('Member deleted Successfuly'); + }); } - constructor(private _memberService : MemberUserService,private _userservice:UserService) { - this.member=new MemberUser() - this.mem=new MemberUser(); - this.isFormSubmitted=false; - - this.toggleButton=true - this.currentUser = this._memberService.searchMembersbyUser(this._userservice.currentUser.userid); - this.currentUser.subscribe(); - } - - - update(updateForm : NgForm ,v:MemberUser) { - + public update(updateForm: NgForm, v: MemberUser) { if (updateForm.invalid) { return; } - // console.log(v) - this._memberService.updateMemberUser(v).subscribe(x=>{ - alert("Member Id: "+v.memberid+" with MemberName "+v.membername+" is updated") }) - // alert("Record Updated")}) - + this._memberService.updateMemberUser(v).subscribe((x) => { + alert( + 'Member Id: ' + + v.memberid + + ' with MemberName ' + + v.membername + + ' is updated' + ); + }); } - // addMember(updateForm : NgForm ,v:MemberUser) { - // if (updateForm.invalid) { - // return; - // } - // // console.log(v) - // this._memberService.addMemberUser(v).subscribe(x=>{ - // alert("Member Id: "+v.memberid+" with MemberName "+v.membername+" is updated") }) - // // alert("Record Updated")}) + enable() { this.toggleButton = false; } + disable() { this.toggleButton = true; } - // } - - enable(){ - this.toggleButton = false - } - - disable(){ - this.toggleButton = true - } - ngOnInit(): void { - } - + ngOnInit(): void {} } diff --git a/Angular-UrbanBazaar/src/app/components/page-nav-bar/page-nav-bar.component.html b/Angular-UrbanBazaar/src/app/components/page-nav-bar/page-nav-bar.component.html index d253576..b008910 100644 --- a/Angular-UrbanBazaar/src/app/components/page-nav-bar/page-nav-bar.component.html +++ b/Angular-UrbanBazaar/src/app/components/page-nav-bar/page-nav-bar.component.html @@ -1,29 +1,19 @@ \ No newline at end of file diff --git a/Angular-UrbanBazaar/src/app/components/page-nav-bar/page-nav-bar.component.ts b/Angular-UrbanBazaar/src/app/components/page-nav-bar/page-nav-bar.component.ts index a34c59f..8eee1a5 100644 --- a/Angular-UrbanBazaar/src/app/components/page-nav-bar/page-nav-bar.component.ts +++ b/Angular-UrbanBazaar/src/app/components/page-nav-bar/page-nav-bar.component.ts @@ -1,9 +1,4 @@ import { Component, OnInit } from '@angular/core'; -import { Observable } from 'rxjs'; -import { ProductService } from 'src/app/services/product.service'; -import { Product } from 'src/app/models/product'; -import { Router } from '@angular/router'; -import { UserService } from 'src/app/services/user.service'; @Component({ selector: 'app-page-nav-bar', @@ -12,18 +7,7 @@ import { UserService } from 'src/app/services/user.service'; }) export class PageNavBarComponent implements OnInit { - searchValue: string = ""; - products : Observable - - constructor(private _productService : ProductService, private router: Router) { } - - clickme() { - alert('searchValue: '+this.searchValue); - this.products = this._productService.searchProduct(this.searchValue); - this._productService.search = this.searchValue; - // this.router.navigate(["/search", {search: this.searchValue}]); - - } + constructor() { } ngOnInit(): void { } diff --git a/Angular-UrbanBazaar/src/app/components/user-add/user-add.component.css b/Angular-UrbanBazaar/src/app/components/user-add/user-add.component.css deleted file mode 100644 index e69de29..0000000 diff --git a/Angular-UrbanBazaar/src/app/components/user-add/user-add.component.html b/Angular-UrbanBazaar/src/app/components/user-add/user-add.component.html deleted file mode 100644 index a738d37..0000000 --- a/Angular-UrbanBazaar/src/app/components/user-add/user-add.component.html +++ /dev/null @@ -1 +0,0 @@ -

user-add works!

diff --git a/Angular-UrbanBazaar/src/app/components/user-add/user-add.component.spec.ts b/Angular-UrbanBazaar/src/app/components/user-add/user-add.component.spec.ts deleted file mode 100644 index 74a02a1..0000000 --- a/Angular-UrbanBazaar/src/app/components/user-add/user-add.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { UserAddComponent } from './user-add.component'; - -describe('UserAddComponent', () => { - let component: UserAddComponent; - let fixture: ComponentFixture; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [ UserAddComponent ] - }) - .compileComponents(); - }); - - beforeEach(() => { - fixture = TestBed.createComponent(UserAddComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/Angular-UrbanBazaar/src/app/components/user-add/user-add.component.ts b/Angular-UrbanBazaar/src/app/components/user-add/user-add.component.ts deleted file mode 100644 index 3f3366a..0000000 --- a/Angular-UrbanBazaar/src/app/components/user-add/user-add.component.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Component, OnInit } from '@angular/core'; - -@Component({ - selector: 'app-user-add', - templateUrl: './user-add.component.html', - styleUrls: ['./user-add.component.css'] -}) -export class UserAddComponent implements OnInit { - - constructor() { } - - ngOnInit(): void { - } - -} diff --git a/Angular-UrbanBazaar/src/app/components/user-profile-details/user-profile-details.component.ts b/Angular-UrbanBazaar/src/app/components/user-profile-details/user-profile-details.component.ts index 04d26ba..f8a042d 100644 --- a/Angular-UrbanBazaar/src/app/components/user-profile-details/user-profile-details.component.ts +++ b/Angular-UrbanBazaar/src/app/components/user-profile-details/user-profile-details.component.ts @@ -7,43 +7,39 @@ import { UserService } from 'src/app/services/user.service'; @Component({ selector: 'app-user-profile-details', templateUrl: './user-profile-details.component.html', - styleUrls: ['./user-profile-details.component.css'] + styleUrls: ['./user-profile-details.component.css'], }) export class UserProfileDetailsComponent implements OnInit { - currentUser : Observable; - user : User; - public toggleButton: boolean ; + currentUser: Observable; + user: User; + public toggleButton: boolean; // /isFormSubmitted : boolean; - - constructor(private _userService : UserService) { - this.user=new User() - this.toggleButton=true - this.currentUser = this._userService.searchUser(this._userService.currentUser.userid); - this.currentUser.subscribe((userold: User)=> this.user = userold); + constructor(private _userService: UserService) { + this.user = new User(); + this.toggleButton = true; + this.currentUser = this._userService.searchUser( + this._userService.currentUser.userid + ); + this.currentUser.subscribe((userold: User) => (this.user = userold)); } - - - update(vendorForm : NgForm) { + public update(vendorForm: NgForm) { if (vendorForm.invalid) { return; } - + // this.isFormSubmitted=true; - this._userService.updateUser(this.user).subscribe(x => { }) - alert("Record Updated") + this._userService.updateUser(this.user).subscribe((x) => {}); + alert('Record Updated'); } - - enable(){ - this.toggleButton = false - } - - disable(){ - this.toggleButton = true - } - ngOnInit(): void { + enable() { + this.toggleButton = false; } + disable() { + this.toggleButton = true; + } + ngOnInit(): void {} } diff --git a/Angular-UrbanBazaar/src/app/components/user-search/user-search.component.css b/Angular-UrbanBazaar/src/app/components/user-search/user-search.component.css deleted file mode 100644 index e69de29..0000000 diff --git a/Angular-UrbanBazaar/src/app/components/user-search/user-search.component.html b/Angular-UrbanBazaar/src/app/components/user-search/user-search.component.html deleted file mode 100644 index a44ec04..0000000 --- a/Angular-UrbanBazaar/src/app/components/user-search/user-search.component.html +++ /dev/null @@ -1 +0,0 @@ -

user-search works!

diff --git a/Angular-UrbanBazaar/src/app/components/user-search/user-search.component.spec.ts b/Angular-UrbanBazaar/src/app/components/user-search/user-search.component.spec.ts deleted file mode 100644 index 31da958..0000000 --- a/Angular-UrbanBazaar/src/app/components/user-search/user-search.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { UserSearchComponent } from './user-search.component'; - -describe('UserSearchComponent', () => { - let component: UserSearchComponent; - let fixture: ComponentFixture; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [ UserSearchComponent ] - }) - .compileComponents(); - }); - - beforeEach(() => { - fixture = TestBed.createComponent(UserSearchComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/Angular-UrbanBazaar/src/app/components/user-search/user-search.component.ts b/Angular-UrbanBazaar/src/app/components/user-search/user-search.component.ts deleted file mode 100644 index 7055331..0000000 --- a/Angular-UrbanBazaar/src/app/components/user-search/user-search.component.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Component, OnInit } from '@angular/core'; - -@Component({ - selector: 'app-user-search', - templateUrl: './user-search.component.html', - styleUrls: ['./user-search.component.css'] -}) -export class UserSearchComponent implements OnInit { - - constructor() { } - - ngOnInit(): void { - } - -} diff --git a/Angular-UrbanBazaar/src/app/components/user-show/user-show.component.css b/Angular-UrbanBazaar/src/app/components/user-show/user-show.component.css deleted file mode 100644 index 4b26b98..0000000 --- a/Angular-UrbanBazaar/src/app/components/user-show/user-show.component.css +++ /dev/null @@ -1,3 +0,0 @@ -body { - padding-left: 10px; -} \ No newline at end of file diff --git a/Angular-UrbanBazaar/src/app/components/user-show/user-show.component.html b/Angular-UrbanBazaar/src/app/components/user-show/user-show.component.html deleted file mode 100644 index 2bca704..0000000 --- a/Angular-UrbanBazaar/src/app/components/user-show/user-show.component.html +++ /dev/null @@ -1,29 +0,0 @@ -

user-show works!

- - -

All User Details

- - - - - - - - - - - - - - - - - - - - - - -
User IdUser EmailFirst NameCityZipcodePhoneAddress Line 1Address Line 2
{{user.userid}}{{user.useremail}}{{user.userfirstname}}{{user.usercity}}{{user.userzip}}{{user.userphone}}{{user.useraddress}}{{user.useraddress2}}
- - \ No newline at end of file diff --git a/Angular-UrbanBazaar/src/app/components/user-show/user-show.component.spec.ts b/Angular-UrbanBazaar/src/app/components/user-show/user-show.component.spec.ts deleted file mode 100644 index d254382..0000000 --- a/Angular-UrbanBazaar/src/app/components/user-show/user-show.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { UserShowComponent } from './user-show.component'; - -describe('UserShowComponent', () => { - let component: UserShowComponent; - let fixture: ComponentFixture; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [ UserShowComponent ] - }) - .compileComponents(); - }); - - beforeEach(() => { - fixture = TestBed.createComponent(UserShowComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/Angular-UrbanBazaar/src/app/components/user-show/user-show.component.ts b/Angular-UrbanBazaar/src/app/components/user-show/user-show.component.ts deleted file mode 100644 index 3f899bf..0000000 --- a/Angular-UrbanBazaar/src/app/components/user-show/user-show.component.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { Observable } from 'rxjs'; -import { User } from 'src/app/models/user'; -import { UserService } from 'src/app/services/user.service'; - -@Component({ - selector: 'app-user-show', - templateUrl: './user-show.component.html', - styleUrls: ['./user-show.component.css'] -}) -export class UserShowComponent implements OnInit { - - userList : Observable; - - constructor(private _userService : UserService) { - this.userList = this._userService.showAllUsers(); - } - - ngOnInit(): void { - } - -} diff --git a/Angular-UrbanBazaar/src/app/models/cart.ts b/Angular-UrbanBazaar/src/app/models/cart.ts index e9568b2..bdee54b 100644 --- a/Angular-UrbanBazaar/src/app/models/cart.ts +++ b/Angular-UrbanBazaar/src/app/models/cart.ts @@ -1,10 +1,10 @@ export class Cart { - public cartid : number; - public userid : number; - public orderid : number; - public productname : string; - public productprice : number; - public quantity : number; - - constructor() {} + public cartid: number; + public userid: number; + public orderid: number; + public productname: string; + public productprice: number; + public quantity: number; + + constructor() {} } diff --git a/Angular-UrbanBazaar/src/app/models/login.ts b/Angular-UrbanBazaar/src/app/models/login.ts index 1c5c392..2b8d794 100644 --- a/Angular-UrbanBazaar/src/app/models/login.ts +++ b/Angular-UrbanBazaar/src/app/models/login.ts @@ -1,6 +1,6 @@ export class Login { - public userfirstname : string; - public userpassword : string; - - constructor() {} + public userfirstname: string; + public userpassword: string; + + constructor() {} } diff --git a/Angular-UrbanBazaar/src/app/models/member-user.ts b/Angular-UrbanBazaar/src/app/models/member-user.ts index 8e5f8b2..312b498 100644 --- a/Angular-UrbanBazaar/src/app/models/member-user.ts +++ b/Angular-UrbanBazaar/src/app/models/member-user.ts @@ -1,10 +1,10 @@ export class MemberUser { - public userid : number; - public memberid : number; - public membername : string; - public totalitems : number; - public memberphone : string; - public membertotalamount : number; - public memberdoornumber: number; - constructor() {} + public userid: number; + public memberid: number; + public membername: string; + public totalitems: number; + public memberphone: string; + public membertotalamount: number; + public memberdoornumber: number; + constructor() {} } diff --git a/Angular-UrbanBazaar/src/app/models/orders.ts b/Angular-UrbanBazaar/src/app/models/orders.ts index 1085ff0..cbf707c 100644 --- a/Angular-UrbanBazaar/src/app/models/orders.ts +++ b/Angular-UrbanBazaar/src/app/models/orders.ts @@ -1,21 +1,20 @@ export class Orders { + public orderid: number; + public orderuserid: number; + public orderamount: number; + public ordershipaddress: string; + public ordershipaddress2: string; + public ordercity: string; + public orderzip: string; + public orderstate: string; + public ordercountry: string; + public orderphone: string; + public ordershippingcost: number; + public ordertax: number; + public orderemail: string; + public orderdate: Date; + public ordershipped: string; + public ordertrackingnumber: string; - public orderid : number; - public orderuserid : number; - public orderamount : number; - public ordershipaddress : string; - public ordershipaddress2 : string; - public ordercity : string; - public orderzip : string; - public orderstate : string; - public ordercountry : string; - public orderphone : string; - public ordershippingcost : number; - public ordertax : number; - public orderemail : string; - public orderdate : Date; - public ordershipped : string; - public ordertrackingnumber : string; - - constructor() {} + constructor() {} } diff --git a/Angular-UrbanBazaar/src/app/models/product-category.ts b/Angular-UrbanBazaar/src/app/models/product-category.ts index b596f99..59a1af1 100644 --- a/Angular-UrbanBazaar/src/app/models/product-category.ts +++ b/Angular-UrbanBazaar/src/app/models/product-category.ts @@ -1,7 +1,6 @@ export class ProductCategory { + public categoryid: number; + public categoryname: string; - public categoryid : number; - public categoryname : string; - - constructor() {} + constructor() {} } diff --git a/Angular-UrbanBazaar/src/app/models/product.ts b/Angular-UrbanBazaar/src/app/models/product.ts index 98e2030..9cfc63c 100644 --- a/Angular-UrbanBazaar/src/app/models/product.ts +++ b/Angular-UrbanBazaar/src/app/models/product.ts @@ -1,13 +1,12 @@ export class Product { + public productid: number; + public productname: string; + public productprice: number; + public productweight: number; + public productshortdesc: string; + public productlongdesc: string; + public productimage: string; + public productcategoryid: number; - public productid : number; - public productname : string; - public productprice : number; - public productweight : number; - public productshortdesc : string; - public productlongdesc : string; - public productimage : string; - public productcategoryid : number; - - constructor() {} + constructor() {} } diff --git a/Angular-UrbanBazaar/src/app/models/user.ts b/Angular-UrbanBazaar/src/app/models/user.ts index e45a488..2045398 100644 --- a/Angular-UrbanBazaar/src/app/models/user.ts +++ b/Angular-UrbanBazaar/src/app/models/user.ts @@ -1,15 +1,15 @@ export class User { - public userid : number; - public useremail : string; - public userpassword : string; - public userfirstname : string; - public userlastname : string; - public usercity: string; - public userstate : string; - public userzip : string; - public userphone : string; - public useraddress : string; - public useraddress2 : string; + public userid: number; + public useremail: string; + public userpassword: string; + public userfirstname: string; + public userlastname: string; + public usercity: string; + public userstate: string; + public userzip: string; + public userphone: string; + public useraddress: string; + public useraddress2: string; - constructor() {} + constructor() {} } diff --git a/Angular-UrbanBazaar/src/app/services/cart.service.ts b/Angular-UrbanBazaar/src/app/services/cart.service.ts index 56dcc78..93c28e1 100644 --- a/Angular-UrbanBazaar/src/app/services/cart.service.ts +++ b/Angular-UrbanBazaar/src/app/services/cart.service.ts @@ -5,74 +5,51 @@ import { BehaviorSubject, Observable } from 'rxjs'; import { Cart } from '../models/cart'; @Injectable({ - providedIn: 'root' + providedIn: 'root', }) export class CartService { + public cartListItem: any = []; + public productList = new BehaviorSubject([]); - private _url : String = "http://localhost:4405/cart"; - constructor(private _http : HttpClient) { } + private _url: String = 'http://localhost:4405/cart'; - // public showAllOrder():Observable - // { - // return this._http.get(this._url+"/showCart"); - // } + constructor(private _http: HttpClient) {} - public cartListItem: any=[] - public productList = new BehaviorSubject([]) - // public addOrder(cart:Cart) - // { - // this._http.post(this._url+"/addCart",cart) - // } - - getProducts() - { + getProducts() { return this.productList.asObservable(); } - setProduct(product:any) - { + setProduct(product: any) { this.cartListItem.push(...product); this.productList.next(product); } - addtoCart(product:any) - { - this.cartListItem.push(product); - this.productList.next(this.cartListItem) - this.getTotalPrice(); - // console.log(this.cartListItem); + addtoCart(product: any) { + this.cartListItem.push(product); + this.productList.next(this.cartListItem); + this.getTotalPrice(); + // console.log(this.cartListItem); } - getTotalPrice():number{ - let grandTotal=0; - this.cartListItem.map((a:any)=>{ - grandTotal+=a.productprice; - }) + getTotalPrice(): number { + let grandTotal = 0; + this.cartListItem.map((a: any) => { + grandTotal += a.productprice; + }); return grandTotal; } - removeCartItem(product:any) - { - this.cartListItem.map((a:any,index:any)=>{ - if(product.productid === a.productid) - { - this.cartListItem.splice(index,1); + removeCartItem(product: any) { + this.cartListItem.map((a: any, index: any) => { + if (product.productid === a.productid) { + this.cartListItem.splice(index, 1); } - }) - this.productList.next(this.cartListItem); + }); + this.productList.next(this.cartListItem); } - removeAllCart() - { - this.cartListItem=[] + removeAllCart() { + this.cartListItem = []; this.productList.next(this.cartListItem); } - - - - - } - - - diff --git a/Angular-UrbanBazaar/src/app/services/member-user.service.ts b/Angular-UrbanBazaar/src/app/services/member-user.service.ts index dbd2c6c..9d6825d 100644 --- a/Angular-UrbanBazaar/src/app/services/member-user.service.ts +++ b/Angular-UrbanBazaar/src/app/services/member-user.service.ts @@ -2,64 +2,39 @@ import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; import { MemberUser } from '../models/member-user'; -import 'rxjs/add/operator/map'; -import { Http ,Response} from '@angular/http'; import { HttpClient } from '@angular/common/http'; @Injectable({ - providedIn: 'root' + providedIn: 'root', }) export class MemberUserService { + private _url: String = 'http://localhost:8008/user/'; + constructor(private _http: HttpClient) {} - - - private _url : String = "http://localhost:8008/user/"; - - constructor(private _http : HttpClient) { } - - // public showMembersByUser(id : number) : Observable { - // return this._http.get(this._url+"/showUserMembers/"+id); - // } - - // public addMemberToUser(member : MemberUser) { - // this._http.post(this._url+"/addMember", member); - // } - - showAllMemberUsers() { - return this._http.get(this._url+"showAllMembers")} - // .map((res : Response) => res.json()); } - // : Observable - addMemberUser(member: MemberUser){ - return this._http.post(this._url+"addMember/",member)} - // : Observable .map((res: Response)=> null); } - searchMemberUser(memberid : number) { - return this._http.get(this._url+"showAllMembers/" +memberid)} - // : Observable.map((res : Response) => res.json()); } - searchMembersbyUser(userid : number){ - return this._http.get(this._url+"showUserMembers/" +userid)} - // : Observable .map((res : Response) => res.json()); } - deleteMemberUser(memberid : number) { - return this._http.delete(this._url+"deleteMember/" +memberid)} - // .map((res : Response) => null); }: Observable - updateMemberUser(member :MemberUser) { - return this._http.put(this._url+"updateMember/",member) - // : Observable.map((res: Response)=> null); } - + public showAllMemberUsers() { + return this._http.get(this._url + 'showAllMembers'); } + public addMemberUser(member: MemberUser) { + return this._http.post(this._url + 'addMember/', member); + } + public searchMemberUser(memberid: number) { + return this._http.get(this._url + 'showAllMembers/' + memberid); + } - // private _url : String = "http://localhost:8001/user"; - - // constructor(private _http : HttpClient) { } - - // public showMembersByUser(id : number) : Observable { - // return this._http.get(this._url+"/showUserMembers/"+id); - // } + public searchMembersbyUser(userid: number) { + return this._http.get( + this._url + 'showUserMembers/' + userid + ); + } - // public addMemberToUser(member : MemberUser) { - // this._http.post(this._url+"/addMember", member); - // } + public deleteMemberUser(memberid: number) { + return this._http.delete(this._url + 'deleteMember/' + memberid); + } + public updateMemberUser(member: MemberUser) { + return this._http.put(this._url + 'updateMember/', member); + } } diff --git a/Angular-UrbanBazaar/src/app/services/orders.service.ts b/Angular-UrbanBazaar/src/app/services/orders.service.ts index 0759004..1b24bc6 100644 --- a/Angular-UrbanBazaar/src/app/services/orders.service.ts +++ b/Angular-UrbanBazaar/src/app/services/orders.service.ts @@ -4,24 +4,22 @@ import { Observable } from 'rxjs'; import { Orders } from '../models/orders'; @Injectable({ - providedIn: 'root' + providedIn: 'root', }) export class OrdersService { + private _url: String = 'http://localhost:8009/orders'; - private _url : String = "http://localhost:8009/orders"; - - constructor(private _http : HttpClient) { } - - public addOrder(order : Orders) { - this._http.post(this._url+"/addOrder", order); + constructor(private _http: HttpClient) {} + + public addOrder(order: Orders) { + this._http.post(this._url + '/addOrder', order); } - public findOrder(id : number) : Observable { - return this._http.get(this._url+"/findOrder"+id); + public findOrder(id: number): Observable { + return this._http.get(this._url + '/findOrder' + id); } - public findOrdersByUser(id : number) : Observable { - return this._http.get(this._url+"/findOrdersByUser"+id); + public findOrdersByUser(id: number): Observable { + return this._http.get(this._url + '/findOrdersByUser' + id); } - } diff --git a/Angular-UrbanBazaar/src/app/services/product-category.service.ts b/Angular-UrbanBazaar/src/app/services/product-category.service.ts index 99fdbd5..d69e0c9 100644 --- a/Angular-UrbanBazaar/src/app/services/product-category.service.ts +++ b/Angular-UrbanBazaar/src/app/services/product-category.service.ts @@ -4,15 +4,16 @@ import { Observable } from 'rxjs'; import { ProductCategory } from '../models/product-category'; @Injectable({ - providedIn: 'root' + providedIn: 'root', }) export class ProductCategoryService { + private _url: String = 'http://localhost:8007/products'; - private _url : String = "http://localhost:8007/products"; - - constructor(private _http : HttpClient) { } + constructor(private _http: HttpClient) {} - public showAllCategory() : Observable { - return this._http.get(this._url+"/showProductCategory"); + public showAllCategory(): Observable { + return this._http.get( + this._url + '/showProductCategory' + ); } } diff --git a/Angular-UrbanBazaar/src/app/services/product.service.ts b/Angular-UrbanBazaar/src/app/services/product.service.ts index 2dca25c..c65e976 100644 --- a/Angular-UrbanBazaar/src/app/services/product.service.ts +++ b/Angular-UrbanBazaar/src/app/services/product.service.ts @@ -2,26 +2,21 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; import { Product } from '../models/product'; -import {map} from 'rxjs/operators'; @Injectable({ - providedIn: 'root' + providedIn: 'root', }) export class ProductService { - private _url : String = "http://localhost:8007/products"; - search : string; - - constructor(private _http : HttpClient) { } + private _url: String = 'http://localhost:8007/products'; + search: string; - public showAllProduct(){ - return this._http.get(this._url+"/showAllProducts") - .pipe(map((res:any)=>{ - return res; - })) - } + constructor(private _http: HttpClient) {} - public searchProduct(name : string) : Observable { - return this._http.get(this._url+"/searchProduct/"+name); + public showAllProduct() : Observable { + return this._http.get(this._url + '/showAllProducts'); } + public searchProduct(name: string): Observable { + return this._http.get(this._url + '/searchProduct/' + name); + } } diff --git a/Angular-UrbanBazaar/src/app/services/user.service.ts b/Angular-UrbanBazaar/src/app/services/user.service.ts index c5b8208..5270436 100644 --- a/Angular-UrbanBazaar/src/app/services/user.service.ts +++ b/Angular-UrbanBazaar/src/app/services/user.service.ts @@ -1,82 +1,39 @@ -// import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; -import { Http,Response } from '@angular/http'; -// import { Observable } from 'rxjs'; import { Login } from '../models/login'; import { User } from '../models/user'; -import 'rxjs/add/operator/map'; -import { Observable } from 'rxjs'; import { HttpClient } from '@angular/common/http'; - +import { Observable } from 'rxjs'; @Injectable({ - providedIn: 'root' + providedIn: 'root', }) export class UserService { + currentUser: User; + private _url: string = 'http://localhost:8500/users/'; + constructor(private _http: HttpClient) {} -// private _url : string = "http://localhost:9000"; - -constructor(private _http : HttpClient) { } - -// public showAllUsers() : Observable { -// return this._http.get(this._url + "/showAllUsers"); -// } - -// public searchUser(id : number) : Observable { -// return this._http.get(this._url+"/findUserById/"+id); -// } - -// public addUser(user : User) { -// this._http.post(this._url+"/addUser/", user); -currentUser:User - private _url:string ="http://localhost:8008/user/" -showAllUsers() { - return this._http.get(this._url+"showAllUsers")} - // .map((res : Response) => res.json());} - -addUser(user: User) { - return this._http.post(this._url+"addUser/",user)} - // .map((res: Response)=> null).pipe();} -// loginUser (user:User):Observable{ -// return this._http.post("http://localhost:8006/user/login/",user).map((res: Response)=>null); -// } -searchUser(userid : number) { - return this._http.get(this._url+"findUserById/" +userid)} - // .map((res : Response) => res.json());} -updateUser(user : User) { - return this._http.put(this._url+"update/",user)} - // .map((res: Response)=> null);} -// findUserByUsername(name : string) : Observable { -// return this._http.get("http://localhost:8006/user/findUserByName/"+name).map((res : Response) => res.json()); -// } - -public loginUser(user : Login) { - return this._http.post(this._url+"login/",user)} - // .map((res: Response)=>null);} - -public findUserByUsername(name : string) { - return this._http.get(this._url+"findUserByName/"+name)} - //.map((res : Response) => res.json());} - - - // private _url : String = "http://localhost:8001/user"; - // currentUser : User; - - // constructor(private _http : HttpClient) { } + public showAllUsers(): Observable { + return this._http.get(this._url + 'showAllUsers'); + } - // public showAllUsers() : Observable { - // return this._http.get(this._url + "/showAllUsers"); - // } + public addUser(user: User) { + return this._http.post(this._url + 'addUser/', user); + } - // public searchUser(id : number) : Observable { - // return this._http.get(this._url+"/findUserById/"+id); - // } + public searchUser(userid: number) { + return this._http.get(this._url + 'findUserById/' + userid); + } - // public addUser(user : User) { - // this._http.post(this._url+"/addUser", user); - // } + public updateUser(user: User) { + return this._http.put(this._url + 'update/', user); + } - + public loginUser(user: Login) { + return this._http.post(this._url + 'login/', user); + } + public findUserByUsername(name: string) { + return this._http.get(this._url + 'findUserByName/' + name); + } } diff --git a/UB_UserServiceProxy/src/main/resources/application.properties b/UB_UserServiceProxy/src/main/resources/application.properties index 4d2c039..51194ab 100644 --- a/UB_UserServiceProxy/src/main/resources/application.properties +++ b/UB_UserServiceProxy/src/main/resources/application.properties @@ -1,9 +1,10 @@ -server.port=8008 -spring.datasource.url=jdbc:mysql://10.3.117.21:3306/grocery_db?createDatabaseIfNotExist=true +server.port=8500 + +spring.datasource.url=jdbc:mysql://10.3.117.22:3306/grocery_db?createDatabaseIfNotExist=true spring.datasource.username=testuser spring.datasource.password=Password123 -server.servlet.context-path=/user +server.servlet.context-path=/users spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect spring.jpa.hibernate.ddl-auto=update diff --git a/grocery_db_tables.sql b/grocery_db_tables.sql index 49a14ea..7d31037 100644 --- a/grocery_db_tables.sql +++ b/grocery_db_tables.sql @@ -5,16 +5,16 @@ use grocery_db; -- Users Table Schema CREATE TABLE `users` ( `UserID` int(11) NOT NULL AUTO_INCREMENT, - `UserFirstName` varchar(50) DEFAULT NULL, - `UserLastName` varchar(50) DEFAULT NULL, - `UserEmail` varchar(50) DEFAULT NULL, - `UserPassword` varchar(50) DEFAULT NULL, - `UserCity` varchar(50) DEFAULT NULL, + `UserFirstName` varchar(20) DEFAULT NULL, + `UserLastName` varchar(20) DEFAULT NULL, + `UserEmail` varchar(20) DEFAULT NULL, + `UserPassword` varchar(20) DEFAULT NULL, + `UserCity` varchar(30) DEFAULT NULL, `UserState` varchar(20) DEFAULT NULL, - `UserZip` varchar(12) DEFAULT NULL, - `UserPhone` varchar(20) DEFAULT NULL, - `UserAddress` varchar(100) DEFAULT NULL, - `UserAddress2` varchar(50) DEFAULT NULL, + `UserZip` varchar(6) DEFAULT NULL, + `UserPhone` varchar(10) DEFAULT NULL, + `UserAddress` varchar(80) DEFAULT NULL, + `UserAddress2` varchar(80) DEFAULT NULL, PRIMARY KEY (`UserID`) ); @@ -36,6 +36,9 @@ insert into users values( ); select * from users; + +----------------------------------------------------------------------------------------- + -- Product-Categories Table Schema CREATE TABLE IF NOT EXISTS `productcategories` ( `CategoryID` int(11) NOT NULL AUTO_INCREMENT, @@ -53,6 +56,7 @@ INSERT INTO `productcategories` (`CategoryID`, `CategoryName`) VALUES select * from productcategories; +----------------------------------------------------------------------------------------- -- Product Table Schema create table Product( @@ -109,88 +113,68 @@ insert into product values (1007, "Eggs - Regular (12)", 76, 0.150, select * from product; +----------------------------------------------------------------------------------------- -- Orders Table Schema CREATE TABLE IF NOT EXISTS `orders` ( `OrderID` int(11) NOT NULL AUTO_INCREMENT, - `OrderUserID` int(11) NOT NULL, + `UserID` int(11) NOT NULL, `OrderAmount` float NOT NULL, - `OrderShipAddress` varchar(100) NOT NULL, - `OrderShipAddress2` varchar(100) NOT NULL, - `OrderCity` varchar(50) NOT NULL, - `OrderState` varchar(50) NOT NULL, - `OrderZip` varchar(20) NOT NULL, - `OrderCountry` varchar(50) NOT NULL, - `OrderPhone` varchar(20) NOT NULL, `OrderShippingCost` float NOT NULL, - `OrderTax` float NOT NULL, - `OrderEmail` varchar(100) NOT NULL, `OrderDate` date not null, - `OrderShipped` varchar(100) not null, + `OrderShipped` bool not null default false, `OrderTrackingNumber` varchar(80) DEFAULT NULL, PRIMARY KEY (`OrderID`) ); ALTER TABLE orders AUTO_INCREMENT = 1000; -insert into orders values(1000,1,12.5,'indra nagar','panchshill nagar','bhilai','c.g.','490025','india','7896545210',25.3,56.2,'g@gmail.com','2021-09-10','done','456'); -insert into orders values(1001,1,12.5,'indra nagar','panchshill nagar','bhilai','c.g.','490025','india','7896545210',25.3,56.2,'g@gmail.com','2021-09-10','done','457'); - SELECT * FROM orders; +----------------------------------------------------------------------------------------- + -- Members Table Schema create table `members`( - `UserID` int(11) NOT NULL, - `MemberID` int(11) not null AUTO_INCREMENT, + `MemberID` int(11) not null AUTO_INCREMENT, + `UserID` int(11) NOT NULL, `MemberName` varchar(20) not null, `MemberDoorNumber` int(4) not null, - `TotalItems` int(3) not null default 0, - `MemberPhone` varchar(15) not null, - `MemberTotalAmount` float not null default 0, + `TotalItems` int(4) not null default 0, + `TotalPrice` int(6) not null default 0, + `MemberPhone` varchar(10) not null, PRIMARY KEY (`MemberID`), FOREIGN KEY (`UserID`) REFERENCES users(`UserID`) ); -<<<<<<< HEAD -INSERT INTO members VALUES(100, 1, "Abhishek", 501,0,"1234512345", 0); -INSERT INTO members VALUES(100, 2, "Meera", 502,5,"12345234567", 1200); -INSERT INTO members VALUES(100, 3, "Shyam", 503,10,"1234598745", 800); -======= -INSERT INTO members VALUES(100, 1, "Abhishek", 501, 0,"1234512345", 0); -INSERT INTO members VALUES(100, 2, "Meera", 502, 5,"12345234567", 1200); -INSERT INTO members VALUES(100, 3, "Shyam", 503, 10,"1234598745", 800); ->>>>>>> 62466d63e25d717c4d1930484f1053faf246ad32 +INSERT INTO members VALUES(1, 100, "Abhis", 501, 0, 0, "1234512345"); +INSERT INTO members VALUES(2, 100, "Meera", 502, 0, 0, "1234523456"); +INSERT INTO members VALUES(3, 100, "Shyam", 503, 0, 0, "1234598745"); select * from members; +----------------------------------------------------------------------------------------- + -- Cart Table Schema CREATE TABLE IF NOT EXISTS `cart` ( - -- `CartID` int NOT NULL AUTO_INCREMENT, --- `UserID` int NOT NULL, --- `OrderID` int NOT NULL, --- `ProductName` varchar(50) NOT NULL, --- `ProductPrice` int(5) NOT NULL, --- `Quantity` int NOT NULL, --- PRIMARY KEY (`CartID`), --- FOREIGN KEY (`UserID`) REFERENCES users(`UserID`) - `ProductID` int(12) NOT NULL AUTO_INCREMENT, + `CartID` int NOT NULL AUTO_INCREMENT, + `ProductID` int(12) NOT NULL, `UserID` int NOT NULL, - `ProductName` varchar(100) NOT NULL, - `ProductPrice` float NOT NULL, - `ProductCategoryID` int(11) DEFAULT NULL, - PRIMARY KEY (`ProductID`), - FOREIGN KEY (`ProductCategoryID`) REFERENCES productcategories(`CategoryID`), - FOREIGN KEY (`UserID`) REFERENCES users(`UserID`) + `ProductCategoryID` int(11) NOT NULL, + PRIMARY KEY (`CartID`), + FOREIGN KEY (`ProductCategoryID`) REFERENCES productcategories(`CategoryID`), + FOREIGN KEY (`UserID`) REFERENCES users(`UserID`) ); -insert into cart values (1001,100,"Potato", 30,2); - select * from cart; + ALTER TABLE cart AUTO_INCREMENT = 1000; +insert into cart values (1001, 1002, 101, 2); + +select * from cart; + ----------------------------------------------------------------------------------------- drop user if exists 'testuser'; - CREATE USER 'testuser' IDENTIFIED BY 'Password123'; grant all privileges on grocery_db.* to 'testuser'@'%' with grant option;