Ejemplo n.º 1
0
        public IActionResult getCurrentInformationBar(JSONStudent prop)
        {
            var login = HttpContext.Session.GetString("Login");

            var query =
                from Onestudent in db.Student
                where Onestudent.Login == login
                select Onestudent;

            foreach (Student Onestudent in query)
            {
                prop.Login = Onestudent.Login;
                if (Onestudent.Image != null)
                {
                    prop.Image = Encoding.ASCII.GetString(Onestudent.Image);
                }
                else
                {
                    prop.Image = "No image";
                }
                return(Ok(prop));
            }

            return(Ok("notFound"));
        }
Ejemplo n.º 2
0
        public IActionResult getCurrentInformationUser()
        {
            var login = HttpContext.Session.GetString("Login");
            var query =
                from Onestudent in db.Student
                where Onestudent.Login == login
                select Onestudent;
            JSONStudent prop = new JSONStudent();


            foreach (Student Onestudent in query)
            {
                prop.Login     = Onestudent.Login;
                prop.Email     = Onestudent.Email;
                prop.Firstname = Onestudent.Firstname;
                prop.Id        = Onestudent.Id;
                prop.Lastname  = Onestudent.Lastname;
                prop.Pesel     = Onestudent.Pesel;
                prop.Phone     = Onestudent.Phone;
                prop.Surname   = Onestudent.Surname;

                if (Onestudent.Image != null)
                {
                    prop.Image = Encoding.ASCII.GetString(Onestudent.Image);
                }
                else
                {
                    prop.Image = "No image";
                }
                return(Ok(prop));
            }

            return(Ok("notFound"));
        }
        public IActionResult getImageStudent([FromBody] JSONStudent property)
        {
            var  login  = HttpContext.Session.GetString("Login");
            bool status = false;
            var  query  =
                from Onestudent in db.Student
                where Onestudent.Login == login
                select Onestudent;

            foreach (Student Onestudent in query)
            {
                Onestudent.Image = Encoding.ASCII.GetBytes(property.Image);

                status = true;
            }
            db.SaveChanges();
            if (status)
            {
                return(Ok("Success"));
            }
            else
            {
                return(Ok("notFound"));
            }
        }