import { Injectable } from '@angular/core' ; import { User } from 'src/app/core/models/user.model' ; @ Injectable ( { providedIn : 'root' , } ) export class UserDataService { users : User [ ] = [ ] ; constructor ( ) { let user = { userId : 1 , userName : "admin" , password : "password" , emailId : "admin@admin.com" , birthDate : new Date ( '10/28/1992' ) } ; this . users . push ( user ) ; } param userName param password getUserByUserNameAndPassword ( userName , password ) { let user = null ; this . users . forEach ( element => { if ( element . userName === userName && element . password === password ) { user = element ; } } ) ; return user ; } param userName param password param emailId param birthDate addUser ( userName , password , emailId , birthDate ) { let userId = this . users . length + 1 ; let user = new User ( ) ; user . userId = userId ; user . userName = userName ; user . password = password ; user . emailId = emailId ; user . birthDate = birthDate ; this . users . push ( user ) ; return true ; } }