Esempio n. 1
0
        //// GET: api/Collection
        //public IEnumerable<string> Get()
        //{
        //    return new string[] { "value1", "value2" };
        //}

        // GET: api/Collection/5
        public List <Collection> Get(int id)
        {
            DBManage          MyDBManager     = new DBManage();
            SqlCommand        Command         = null;
            SqlDataReader     Reader          = null;
            List <Collection> User_Collection = new List <Collection>();
            string            SqlString       = string.Empty;
            int RecsAff = 0;

            SqlString = "i_tefteri_sp_Get_Collection";
            MyDBManager.CommandTimeOut = 30;
            MyDBManager.ConStr         = Constr();
            try
            {
                MyDBManager.ConOpen();
                Command             = new SqlCommand();
                Command.CommandText = SqlString;
                Command.CommandType = System.Data.CommandType.StoredProcedure;
                Command.Parameters.Add("@UserID", SqlDbType.Int);
                Command.Parameters["@UserID"].Value = id;
                Reader = MyDBManager.ExecuteReader(Command);

                while (Reader.Read())
                {
                    Collection MyCollection = new Collection();
                    MyCollection.PersonID   = Reader["UserID"].ToString();
                    MyCollection.PersonName = Reader["iBankuserID"].ToString();
                    MyCollection.TransDate  = Reader["HMEROMHNIA"].ToString();
                    MyCollection.ActualDate = Reader["HMEROMHNIA_EKT"].ToString();
                    String.Format(MyCollection.TransAmount = Reader["POSO"].ToString(), "#,##0.00");
                    MyCollection.DOSEIS        = Reader["DOSEIS"].ToString();
                    MyCollection.TransactionID = Reader["TransactionID"].ToString();
                    User_Collection.Add(MyCollection);
                    MyCollection = null;
                }
                Reader.Close();
                Reader  = null;
                Command = null;
                Write2LogFile(MyDBManager, "Controller=Collection, " + "Get Users Collection", 1);
                MyDBManager.ConClose();
                MyDBManager = null;
                return(User_Collection);
            }
            catch
            {
                return(User_Collection);
            }
        }
        //// GET: api/Users
        //public IEnumerable<string> Get()
        //{
        //    return new string[] { "value1", "value2" };
        //}

        // GET: api/Users/5
        public List <Person> Get(int id)
        {
            System.Net.Http.Headers.HttpRequestHeaders headers = this.Request.Headers;
            DBManage      MyDBManager = new DBManage();
            SqlCommand    Command     = null;
            SqlDataReader Reader      = null;
            List <Person> Person      = new List <Person>();
            string        SqlString   = string.Empty;
            int           RecsAff     = 0;

            SqlString = "i_tefteri_sp_Get_Active_Users";
            MyDBManager.CommandTimeOut = 30;
            MyDBManager.ConStr         = Constr();
            if (id == -1)
            {
                try
                {
                    if (headers.Contains("Currentuser"))
                    {
                        string user = headers.GetValues("Currentuser").First();
                    }
                    MyDBManager.ConOpen();
                    Command             = new SqlCommand();
                    Command.CommandText = SqlString;
                    Command.CommandType = System.Data.CommandType.StoredProcedure;
                    Command.Parameters.Add("@What2Do", SqlDbType.VarChar, 50);
                    //Command.Parameters.Add("@Mobile_Num", SqlDbType.VarChar, 12);
                    Command.Parameters["@What2Do"].Value = "All Person";
                    //Command.Parameters["@Mobile_Num"].Value = id;
                    Reader = MyDBManager.ExecuteReader(Command);

                    while (Reader.Read())
                    {
                        Person MyPerson = new Person();
                        MyPerson.UserID        = Convert.ToInt32(Reader["UserID"]);
                        MyPerson.iBankuserID   = Reader["iBankuserID"].ToString();
                        MyPerson.BASIKOS_LOGAR = Reader["BASIKOS_LOGAR"].ToString();
                        Person.Add(MyPerson);
                        MyPerson = null;
                    }
                    Reader.Close();
                    Reader  = null;
                    Command = null;
                    Write2LogFile(MyDBManager, "Controller=Users, " + "Get ALL Active Users", 1);
                    MyDBManager.ConClose();
                    MyDBManager = null;
                    //var jsonSerialiser = new JavaScriptSerializer();
                    //var json = jsonSerialiser.Serialize(Person);
                    return(Person);//JsonConvert.SerializeObject(Person);
                }
                catch (Exception ex)
                {
                    Person MyPerson = new Person();
                    RecsAff = Write2LogFile(MyDBManager, "Controller=Users, " + "Error: " + ex.Message, 1);
                    MyDBManager.ConClose();
                    MyDBManager          = null;
                    MyPerson.iBankuserID = "Error";
                    Person.Add(MyPerson);
                    return(Person);
                }
            }
            else
            {
                try
                {
                    string Currentuser = string.Empty;
                    if (headers.Contains("Currentuser"))
                    {
                        Currentuser = headers.GetValues("Currentuser").First();
                    }
                    MyDBManager.ConOpen();
                    Command             = new SqlCommand();
                    Command.CommandText = SqlString;
                    Command.CommandType = System.Data.CommandType.StoredProcedure;
                    Command.Parameters.Add("@What2Do", SqlDbType.VarChar, 50);
                    //Command.Parameters.Add("@Mobile_Num", SqlDbType.VarChar, 12);
                    Command.Parameters["@What2Do"].Value = Currentuser;
                    //Command.Parameters["@Mobile_Num"].Value = id;
                    Reader = MyDBManager.ExecuteReader(Command);

                    while (Reader.Read())
                    {
                        Person MyPerson = new Person();
                        MyPerson.UserID        = Convert.ToInt32(Reader["UserID"]);
                        MyPerson.iBankuserID   = Reader["iBankuserID"].ToString();
                        MyPerson.BASIKOS_LOGAR = Reader["BASIKOS_LOGAR"].ToString();
                        Person.Add(MyPerson);
                        MyPerson = null;
                    }
                    Reader.Close();
                    Reader  = null;
                    Command = null;
                    Write2LogFile(MyDBManager, "Controller=Users, " + "Get 1 Active Users", 1);
                    MyDBManager.ConClose();
                    MyDBManager = null;
                    //var jsonSerialiser = new JavaScriptSerializer();
                    //var json = jsonSerialiser.Serialize(Person);
                    return(Person);//JsonConvert.SerializeObject(Person);
                }
                catch (Exception ex)
                {
                    Person MyPerson = new Person();
                    RecsAff = Write2LogFile(MyDBManager, "Controller=Users, " + "Error: " + ex.Message, 1);
                    MyDBManager.ConClose();
                    MyDBManager          = null;
                    MyPerson.iBankuserID = "Error";
                    Person.Add(MyPerson);
                    return(Person);
                }
            }
        }