Esempio n. 1
0
        public Student GetStudent()
        {
            Student student = studentRepo.Get();

            /*if (student != null)
             *  if (!string.IsNullOrEmpty((student.Picture).ToString()))
             *      student.Picture = Path.Combine(dbFolder, "Picture", (student.Picture).ToString());*/
            return(student);
        }
Esempio n. 2
0
        public IActionResult GetStudents()
        {
            //llamada al modelo para obtener las carreras
            studentDAO = new StudentDAO(_configuration);

            List <Student> students = new List <Student>();

            students = studentDAO.Get();

            return(Json(students));
        }
        public JsonResult Get(string id)
        {
            try
            {
                Student data = dao.Get(id);

                return(Json(new
                {
                    data = data
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(new
                {
                    data = DBNull.Value.ToString()
                }, JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 4
0
        public JsonResult Login(string username, string password, int type = 0)
        {
            if (type == 0)
            {
                StudentDAO dao = new StudentDAO();

                int status = dao.Login(username, Encryptor.MD5Hash(password));
                if (status == 1)
                {
                    var student = dao.Get(username);
                    var user    = new User();
                    user.Username = student.Id;
                    user.Avatar   = student.Avatar;
                    user.FullName = student.FullName;
                    user.Gender   = student.Gender;

                    Session[Constants.USER] = user;

                    return(Json(new
                    {
                        status = status,
                        data = student
                    }));
                }
                else
                {
                    return(Json(new
                    {
                        status = status
                    }));
                }
            }
            else if (type == 1)
            {
                StaffDAO dao = new StaffDAO();

                int status = dao.Login(username, Encryptor.MD5Hash(password));
                if (status == 1)
                {
                    var staff = dao.Get(username);
                    var user  = new User();
                    user.Username = staff.Id;
                    user.Avatar   = staff.Avatar;
                    user.FullName = staff.FullName;
                    user.Gender   = staff.Gender;

                    Session[Constants.ADMIN] = user;

                    return(Json(new
                    {
                        status = status,
                        data = staff
                    }));
                }
                else
                {
                    return(Json(new
                    {
                        status = status
                    }));
                }
            }
            else
            {
                return(Json(new
                {
                    status = -1
                }));
            }
        }