コード例 #1
0
ファイル: LoginController.cs プロジェクト: tuananh82vn/DonDon
        public LoginObject Login(string username, string password)
        {
            LoginObject obj = new LoginObject();

            string url = Settings.InstanceURL;

            url = url + "/api/logon";

            var logon = new
            {
                Item = new
                {
                    UserName = username,
                    Password = password,
                }
            };

            try {
                string results = ConnectWebAPI.Request(url, logon);

                obj = Newtonsoft.Json.JsonConvert.DeserializeObject <LoginObject> (results);

                return(obj);
            } catch (Exception ex) {
                Console.WriteLine(ex.StackTrace);

                return(null);
            }
        }
コード例 #2
0
ファイル: Utility.cs プロジェクト: tuananh82vn/DonDon
        public static DateTime GetTodayDate()
        {
            string url = Settings.InstanceURL;

            url = url + "/api/GetTodayDate";

            var logon = new
            {
            };

            try {
                string results = ConnectWebAPI.Request(url, logon);

                //too tired today , sorry about this stupid code :(
                results = results.Remove(0, 1);
                results = results.Remove(results.Length - 1, 1);

                LoginController.Log("Get Today Date :" + results);

                return(DateTime.Parse(results));
            } catch (Exception ex) {
                Console.WriteLine(ex.StackTrace);

                return(DateTime.Today);
            }
        }
コード例 #3
0
        public static string GetOrderNotes(DateTime orderDate)
        {
            string url = Settings.InstanceURL;

            url = url + "/Api/GetOrderNotes";


            var objsearch = (new
            {
                OrderDate = orderDate,
                RestaurantId = Settings.RestaurantId
            });

            try {
                string results = ConnectWebAPI.Request(url, objsearch);



                return(results);
            } catch (Exception ex) {
                Console.WriteLine(ex.StackTrace);

                return(null);
            }
        }
コード例 #4
0
        public static List <OrderList> GetOrderList(DateTime orderDate)
        {
            string url = Settings.InstanceURL;

            url = url + "/Api/GetOrderList";


            var objsearch = (new
            {
                OrderDate = orderDate,
                RestaurantId = Settings.RestaurantId
            });

            string results = ConnectWebAPI.Request(url, objsearch);

            if (results != null)
            {
                LoginController.Log(Constant.GetOrderDate + ":" + orderDate.ToShortDateString());


                ApiResultList <IEnumerable <OrderList> > objResult = Newtonsoft.Json.JsonConvert.DeserializeObject <ApiResultList <IEnumerable <OrderList> > > (results);

                List <OrderList> returnObject = new List <OrderList> ();

                if (objResult.Items != null)
                {
                    foreach (object Item in objResult.Items)
                    {
                        OrderList temp = Newtonsoft.Json.JsonConvert.DeserializeObject <OrderList> (Item.ToString());
                        returnObject.Add(temp);
                    }
                }
                else
                {
                    return(null);
                }

                return(returnObject);
            }
            else
            {
                return(null);
            }
        }
コード例 #5
0
ファイル: LoginController.cs プロジェクト: tuananh82vn/DonDon
        public static void Log(string action)
        {
            string url = Settings.InstanceURL;

            url = url + "/api/Log";

            var objsearch = (new
            {
                username = Settings.Username,
                action = action
            });

            try
            {
                ConnectWebAPI.Request(url, objsearch);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
        }
コード例 #6
0
        public static List <RestaurantList> GetRestaurantList()
        {
            string url = Settings.InstanceURL;

            url = url + "/Api/GetRestaurantList";


            var objsearch = (new
            {
            });

            string results = ConnectWebAPI.Request(url, objsearch);

            if (results != null)
            {
                ApiResultList <IEnumerable <RestaurantList> > objResult = Newtonsoft.Json.JsonConvert.DeserializeObject <ApiResultList <IEnumerable <RestaurantList> > > (results);

                List <RestaurantList> returnObject = new List <RestaurantList> ();

                if (objResult.Items != null)
                {
                    foreach (object Item in objResult.Items)
                    {
                        RestaurantList temp = Newtonsoft.Json.JsonConvert.DeserializeObject <RestaurantList> (Item.ToString());
                        returnObject.Add(temp);
                    }
                }
                else
                {
                    return(null);
                }

                return(returnObject);
            }
            else
            {
                return(null);
            }
        }