예제 #1
0
        public static async System.Threading.Tasks.Task <ApiResultSave> SendOrderList(List <OrderList> obj, string notes, int orderOption)
        {
            ApiResultSave apiResultSave = new ApiResultSave();

            apiResultSave = await new WebApiHelper().EditAddObject("/API/SendOrderList", obj, notes, orderOption);

            return(apiResultSave);
        }
예제 #2
0
		public async System.Threading.Tasks.Task<ApiResultSave> EditAddObject(string url,Object objTask, string notes, int orderOption)
		{
			ApiResultSave apiResult = new ApiResultSave();

			try
			{
				ApiSave<Object> objApiTask = new ApiSave<Object>();

				objApiTask.UserId = Settings.UserId;

				objApiTask.RestaurantId = Settings.RestaurantId;

				objApiTask.OrderDate = Utility.GetTodayDate();

				objApiTask.Notes = notes;

				objApiTask.OrderOption = orderOption;

				objApiTask.Item = objTask;

				var jsonString = JsonConvert.SerializeObject(objApiTask);                

				string contentstring = GetJsonConentString(jsonString);

				var content = new StringContent(contentstring, Encoding.UTF8, "application/x-www-form-urlencoded");

				var response = await httpClient.PostAsync(url, content).ConfigureAwait(false);

				if (response.IsSuccessStatusCode)
				{

					var dataContent = await response.Content.ReadAsStringAsync();

					apiResult = Newtonsoft.Json.JsonConvert.DeserializeObject<ApiResultSave>(dataContent);

				}
			}
			catch (Exception)
			{
				throw;
			}

			return apiResult;
		}
예제 #3
0
        public async System.Threading.Tasks.Task <ApiResultSave> EditAddObject(string url, Object objTask, string notes, int orderOption)
        {
            ApiResultSave apiResult = new ApiResultSave();

            try
            {
                ApiSave <Object> objApiTask = new ApiSave <Object>();

                objApiTask.UserId = Settings.UserId;

                objApiTask.RestaurantId = Settings.RestaurantId;

                objApiTask.OrderDate = Utility.GetTodayDate();

                objApiTask.Notes = notes;

                objApiTask.OrderOption = orderOption;

                objApiTask.Item = objTask;

                var jsonString = JsonConvert.SerializeObject(objApiTask);

                string contentstring = GetJsonConentString(jsonString);

                var content = new StringContent(contentstring, Encoding.UTF8, "application/x-www-form-urlencoded");

                var response = await httpClient.PostAsync(url, content).ConfigureAwait(false);

                if (response.IsSuccessStatusCode)
                {
                    var dataContent = await response.Content.ReadAsStringAsync();

                    apiResult = Newtonsoft.Json.JsonConvert.DeserializeObject <ApiResultSave>(dataContent);
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(apiResult);
        }
예제 #4
0
		public static async System.Threading.Tasks.Task<ApiResultSave> SendOrderList(List<OrderList> obj, string notes, int orderOption)
		{
			ApiResultSave apiResultSave = new ApiResultSave();

			apiResultSave = await new WebApiHelper().EditAddObject("/API/SendOrderList",obj, notes,orderOption);

			return apiResultSave;
		}
예제 #5
0
        public void btSendClick(object sender, EventArgs e)
        {
            OptionSendSelected = 0;

            string[] color_options = new string[] { "Send All", "Send to Daiwa", "Send to Centre Kitchen" };


            new AlertDialog.Builder(this)
            .SetPositiveButton("Send", async(sender1, args) =>
            {
                progress = new ProgressDialog(this, Resource.Style.StyledDialog);
                progress.Indeterminate = true;
                progress.SetMessage("Please wait...");
                progress.SetCancelable(true);
                progress.Show();

                ApiResultSave result = await OrderController.SendOrderList(orderListAdapter.GetOrderList(), this.mNotes.Text, OptionSendSelected);

                if (result != null)
                {
                    if (result.Success)
                    {
                        progress.Dismiss();

                        var builder    = new AlertDialog.Builder(this);
                        string message = "";

                        if (OptionSendSelected == 0)
                        {
                            message = "Order sent all successfully.";
                            LoginController.Log(Constant.ButtonSendAllClick + "_" + Version);
                        }
                        else if (OptionSendSelected == 1)
                        {
                            message = "Order sent to Daiwa successfully.";
                            LoginController.Log(Constant.ButtonSendDWClick + "_" + Version);
                        }
                        else if (OptionSendSelected == 2)
                        {
                            message = "Order sent to Centre Kitchen successfully.";
                            LoginController.Log(Constant.ButtonSendCKClick + "_" + Version);
                        }

                        builder.SetMessage(message);
                        builder.SetPositiveButton("Ok", (s, ee) => { });
                        builder.Create().Show();
                    }
                    else
                    {
                        progress.Dismiss();

                        new AlertDialog.Builder(this).SetMessage(result.ErrorMessage)
                        .SetTitle("Done")
                        .Show();
                    }
                }
                else
                {
                    progress.Dismiss();

                    new AlertDialog.Builder(this).SetMessage("Network or Server problem. Try again")
                    .SetTitle("Done")
                    .Show();
                }
            })

            .SetSingleChoiceItems(color_options, 0, ListClicked)

            .SetNegativeButton("Cancel", (sender3, args) =>
            {
                // User pressed no
            })
            .SetTitle("Please carefully select which option you want to send order ?")
            .Show();
        }