Hello Every one,
I am facing a problem in angular 6 where I post student object in angular 6 
through web api 2 and then I retrieve the list from the db. The problem is 
I don't get the recent posted object from the list. When I try to add a new 
object I get the second last object I Posted in the list as recent object. 
WHat could be the possible issue of this problem.

Here is my componenet
Enter code here...login()
{
let firstname = this.model.firstName;
let password = this.model.password;
debugger
this.postService.login(this.model.firstName,this.model.password);
debugger
this.postService.GetOnlines().subscribe( (x)=> this.Onlines = x );
}
Here is my Service

Enter code here...login(userName:string, password:string):void
{
debugger
let bool = false;
let loginpassword = JSON.stringify(userName+';'+password)
this._http.post("http://localhost:39495/Student/Login/",loginpassword,this.
httpOptions);
}
GetOnlines()
{
debugger
return this._http.get("http://localhost:39495/Student/GetOnlines/",this.
httpOptions)
}


Here is My Web api 2
Enter code here...   [Route("Student/Login")]
        [AcceptVerbs("POST", "PUT")]
        public IHttpActionResult Login([FromBody]string loginPassword)
        {
            string[] userPassword = loginPassword.Split(';');
            string userName = userPassword[0];
            string password = userPassword[1];
            HttpContext.Current.Session["ActiveUser"] = loginPassword[0];

            if (HttpContext.Current.Session["ActiveUser"] != null)
            {
                var s = db.StudentInfoes.Where(x => x.UserName == userName 
&& x.Password == password).FirstOrDefault();
                if (s != null)
                {
                    if (s.IsOnline == false)
                    {
                        s.IsOnline = true;
                        db.SaveChanges();
                    }
                }
            }

            return Ok("Session Created");
        }

        [Route("Student/GetOnlines")]
        [HttpGet]
        public IHttpActionResult GetOnlines()
        {
            return Json(db.StudentInfoes.ToList());
        }

Can Any body Identify the problem please .....

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to