예제 #1
0
        public IActionResult CategoryList()
        {
            var msg = ""; string Query = "";
            CoreSQLConnection CoreSQL = new CoreSQLConnection();
            List <Category>   CatList = new List <Category>();
            var CategoryList          = CatList;

            try
            {
                Query = "SELECT * FROM tbl_Category";
                IDataReader reader = CoreSQL.CoreSQL_GetReader(Query);
                while (reader.Read())
                {
                    Category aCat = new Category();
                    aCat.id   = Convert.ToInt32(reader["CatId"].ToString());
                    aCat.name = reader["CatName"].ToString();
                    CatList.Add(aCat);
                }
                return(Json(CategoryList));
            }
            catch (Exception ex)
            {
                msg = ex.Message;
                return(Json(msg));
            }
        }
예제 #2
0
 public User GetUser(string username)
 {
     try
     {
         string            Query = "";
         CoreSQLConnection CoreSQL = new CoreSQLConnection(); User aCat = new User();
         Query = "SELECT * FROM tbl_loginUsers where username='******'";
         IDataReader reader = CoreSQL.CoreSQL_GetReader(Query);
         while (reader.Read())
         {
             aCat.UserName     = reader["UserName"].ToString();
             aCat.PasswordHash = (byte[])(reader["PasswordHash"]);
             aCat.PasswordSalt = (byte[])reader["PasswordSalt"];
             break;
         }
         return(aCat);
     }
     catch (Exception ex)
     {
         throw (ex);
     }
     finally
     {
     }
 }
        public IActionResult GetEmaployeeById(int StudentId)
        {
            Student objEmp = new Student();
            int     ID     = Convert.ToInt32(StudentId);

            try
            {
                try
                {
                    var msg = ""; string Query = "";
                    CoreSQLConnection CoreSQL = new CoreSQLConnection();
                    List <Student>    CatList = new List <Student>();
                    var StudentList = CatList; Student aCat = new Student();
                    try
                    {
                        Query = "SELECT * FROM tbl_Student";
                        IDataReader reader = CoreSQL.CoreSQL_GetReader(Query);
                        while (reader.Read())
                        {
                            aCat             = new Student();
                            aCat.StudentId   = Convert.ToInt32(reader["StudentId"].ToString());
                            aCat.StudentName = reader["StudentName"].ToString();
                            aCat.DateOfBirth = reader["DateOfBirth"].ToString();
                            aCat.EmailId     = reader["EmailId"].ToString();
                            aCat.Address     = reader["Address"].ToString();
                            aCat.Gender      = reader["Gender"].ToString();
                            CatList.Add(aCat);
                        }
                        aCat = CatList.Where(a => a.StudentId == StudentId).FirstOrDefault();
                        return(Ok(aCat));
                    }
                    catch (Exception ex)
                    {
                        msg = ex.Message;
                        return(Json(msg));
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
 public JsonResult GetStudentList()
 {
     try
     {
         var msg = ""; string Query = "";
         CoreSQLConnection CoreSQL = new CoreSQLConnection();
         List <Student>    CatList = new List <Student>();
         var StudentList           = CatList;
         try
         {
             Query = "SELECT * FROM tbl_Student";
             IDataReader reader = CoreSQL.CoreSQL_GetReader(Query);
             while (reader.Read())
             {
                 Student aCat = new Student();
                 aCat.StudentId   = Convert.ToInt32(reader["StudentId"].ToString());
                 aCat.StudentName = reader["StudentName"].ToString();
                 aCat.DateOfBirth = reader["DateOfBirth"].ToString();
                 aCat.EmailId     = reader["EmailId"].ToString();
                 aCat.Address     = reader["Address"].ToString();
                 aCat.Gender      = reader["Gender"].ToString();
                 CatList.Add(aCat);
             }
             return(Json(StudentList));
         }
         catch (Exception ex)
         {
             msg = ex.Message;
             return(Json(msg));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }