Пример #1
0
        private async void UpdateRecieptStatusClicked(object obj)
        {
            RecieptDTO recieptDTO = new RecieptDTO();

            recieptDTO.Status    = "4";
            recieptDTO.Price     = "";
            recieptDTO.StoreID   = StoreID;
            recieptDTO.RecieptID = RecieptID;
            UpdateRecieptStatusRequest updateRecieptStatusRequest = new UpdateRecieptStatusRequest();

            updateRecieptStatusRequest.AuthToken        = SessionHelper.AccessToken;
            updateRecieptStatusRequest.updatRrecieptDTO = recieptDTO;
            JsonValue updateRecieptRequest = await HttpRequestHelper <UpdateRecieptStatusRequest> .POSTreq(ServiceTypes.UpdateRecieptStatus, updateRecieptStatusRequest);

            UpdateRecieptStatusResponse updateRecieptStatusResponse = JsonConvert.DeserializeObject <UpdateRecieptStatusResponse>(updateRecieptRequest.ToString());

            if (updateRecieptStatusResponse.IsSuccess)
            {
                await App.Current.MainPage.DisplayAlert("Success", updateRecieptStatusResponse.Message, "Ok");
            }
            else
            {
                await App.Current.MainPage.DisplayAlert("Error", updateRecieptStatusResponse.Message, "Ok");
            }
        }
        private void ParseRecieptJSON(JsonValue json)
        {
            // Extract the array of name/value results for the field name "weatherObservation".
            JsonValue     recieptResults = json;
            List <string> itemList       = new List <string>();
            // Extract the "stationName" (location string) and write it to the location TextBox:
            bool isSuccess = recieptResults["IsSuccess"];

            if (isSuccess)
            {
                JsonArray         recieptArray = (JsonArray)recieptResults["reciepts"];
                List <RecieptDTO> output       = new List <RecieptDTO>();
                foreach (JsonValue item in recieptArray)
                {
                    RecieptDTO d = new RecieptDTO();
                    d.Name      = item["Name"];
                    d.RecieptID = item["RecieptID"];
                    output.Add(d);
                }
                mlist = output;
                var listView = FindViewById <ListView>(Resource.Id.lstOrderedReciepts);
                listView.ItemClick += ListView_ItemClick;
                recieptAdapter      = new RecieptAdapter(this, mlist);
                listView.Adapter    = recieptAdapter;
                Toast.MakeText(this, "Ordered reciepts recieved successfully.", ToastLength.Short).Show();
            }
            else
            {
                string errorMessage = recieptResults["Message"];
                Toast.MakeText(this, errorMessage, ToastLength.Short).Show();
            }
        }
Пример #3
0
        private async void AddRecieptClicked(object obj)
        {
            AddRecieptRequest addRecieptRequest = new AddRecieptRequest();

            addRecieptRequest.AuthToken = SessionHelper.AccessToken;
            RecieptDTO recieptDTO = new RecieptDTO();

            recieptDTO.AddedOn           = DateTime.Now.ToString();
            recieptDTO.Name              = Name;
            recieptDTO.Price             = "";
            recieptDTO.RecieptID         = 0;
            recieptDTO.Status            = ReceiptStatusEnum.New.ToString();
            recieptDTO.StoreID           = 0;
            addRecieptRequest.recieptDTO = recieptDTO;
            JsonValue AddRecieptResponse = await HttpRequestHelper <AddRecieptRequest> .POSTreq(ServiceTypes.AddReciept, addRecieptRequest);

            AddRecieptResponse addRecieptResponse = JsonConvert.DeserializeObject <AddRecieptResponse>(AddRecieptResponse.ToString());

            if (addRecieptResponse.IsSuccess)
            {
                var mdp     = (Application.Current.MainPage as MasterDetailPage);
                var navPage = mdp.Detail as NavigationPage;
                await navPage.PushAsync(new ListManagement(), true);
            }
        }
        private void ListView_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
        {
            var        select = mlist[e.Position].Name + " " + mlist[e.Position].RecieptID;
            Intent     intent = new Intent(this, typeof(OrderedProductActivity));
            RecieptDTO extras = new RecieptDTO();

            extras.RecieptID = mlist[e.Position].RecieptID;
            extras.Name      = mlist[e.Position].Name;
            intent.PutExtra("RecieptData", JsonConvert.SerializeObject(extras));
            StartActivity(intent);

            Android.Widget.Toast.MakeText(this, select, Android.Widget.ToastLength.Long).Show();
        }
Пример #5
0
        protected async override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            //drawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawer_layout);
            //LayoutInflater inflater = (LayoutInflater)this.GetSystemService(Context.LayoutInflaterService);
            //View contentView = inflater.Inflate(Resource.Layout.Reciept, null, false);
            //drawerLayout.AddView(contentView);
            SetContentView(Resource.Layout.Reciept);
            TextView      storeUsernameText = FindViewById <TextView>(Resource.Id.txtUsername);
            SessionHelper sessionHelper     = new SessionHelper(this);
            string        Username          = sessionHelper.GetSessionKey(SessionKeys.SESSION_USERNAME_KEY);
            string        UserID            = sessionHelper.GetSessionKey(SessionKeys.SESSION_USERID_KEY);
            string        AuthToken         = sessionHelper.GetSessionKey(SessionKeys.SESSION_TOKEN_KEY);

            storeUsernameText.Text = "Hello " + Username;

            EditText recieptName   = FindViewById <EditText>(Resource.Id.editrecieptTxt);
            Button   btnAddReciept = FindViewById <Button>(Resource.Id.addreciept);

            JsonValue jsonReciept = await HttpRequestHelper <RecieptEntity> .GetRequest(ServiceTypes.GetReciepts, "/" + AuthToken + "/" + UserID);

            ParseRecieptJSON(jsonReciept);

            btnAddReciept.Click += async(sender, e) =>
            {
                try
                {
                    RecieptDTO recieptDTO = new RecieptDTO();
                    recieptDTO.CreatedOn = DateTime.Now.ToString();
                    recieptDTO.Name      = recieptName.Text;
                    recieptDTO.StoreID   = Convert.ToInt32(UserID);
                    recieptDTO.Status    = ((int)ReceiptStatusEnum.New).ToString();
                    RecieptEntity recieptEntity = new RecieptEntity {
                        AuthToken = AuthToken, recieptDTO = recieptDTO
                    };
                    JsonValue json = await HttpRequestHelper <RecieptEntity> .POSTreq(ServiceTypes.AddReciept, recieptEntity);

                    ParseJSON(json);

                    JsonValue jsonReciept1 = await HttpRequestHelper <RecieptEntity> .GetRequest(ServiceTypes.GetReciepts, "/" + AuthToken + "/" + UserID);

                    ParseRecieptJSON(jsonReciept1);
                }
                catch (Exception ex)
                {
                }
            };
        }
Пример #6
0
        public GetRecieptResponse GetOrderedRecieptsForStore(string AuthToken, string UserID)
        {
            GetRecieptResponse getRecieptResponse = new GetRecieptResponse();

            getRecieptResponse.IsSuccess = false;
            getRecieptResponse.Message   = "Error in getting ordered reciepts. Please try again";

            if (String.IsNullOrEmpty(AuthToken))
            {
                getRecieptResponse.Message = "Please pass all mandatory fields.";
                return(getRecieptResponse);
            }

            AuthenticationToken authToken = new Helper().GetAuthenticationToken(AuthToken);

            if (authToken == null)
            {
                getRecieptResponse.Message = "Unauthorizes user.";
                return(getRecieptResponse);
            }

            List <RecieptEL>  lstReciept    = orderReceiptHelper.GetOrderedRecieptsForStore(Convert.ToInt32(UserID));
            List <RecieptDTO> lstRecieptDTO = new List <RecieptDTO>();

            if (lstReciept.Count > 0)
            {
                foreach (RecieptEL item in lstReciept)
                {
                    RecieptDTO recieptDTO = new RecieptDTO();
                    recieptDTO = MapperUtility.MapTo(item, recieptDTO);
                    lstRecieptDTO.Add(recieptDTO);
                }
                getRecieptResponse.reciepts  = lstRecieptDTO;
                getRecieptResponse.IsSuccess = true;
                getRecieptResponse.Message   = "Ordered reciepts returned successfully.";
            }
            else
            {
                getRecieptResponse.Message = "No Reciepts found.";
            }

            return(getRecieptResponse);
        }
Пример #7
0
        protected async override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.OrderedProduct);
            RecieptDTO user = JsonConvert.DeserializeObject <RecieptDTO>(Intent.GetStringExtra("RecieptData"));
            //var extras = Intent.GetParcelableExtra("RecieptData") ?? String.Empty;
            string textRecieptName = user.Name;

            textRecieptID = user.RecieptID.ToString();
            TextView txtRecieptName     = FindViewById <TextView>(Resource.Id.recieptTxt);
            TextView txtProductName     = FindViewById <TextView>(Resource.Id.editProductName);
            TextView txtProductQuantity = FindViewById <TextView>(Resource.Id.editProductQuantity);

            txtRecieptName.Text = textRecieptName;
            SessionHelper sessionHelper = new SessionHelper(this);
            string        Username      = sessionHelper.GetSessionKey(SessionKeys.SESSION_USERNAME_KEY);
            string        UserID        = sessionHelper.GetSessionKey(SessionKeys.SESSION_USERID_KEY);
            string        AuthToken     = sessionHelper.GetSessionKey(SessionKeys.SESSION_TOKEN_KEY);

            JsonValue jsonProduct = await HttpRequestHelper <ProductEntity> .GetRequest(ServiceTypes.GetProducts, "/" + AuthToken + "/" + textRecieptID);

            ParseRecieptJSON(jsonProduct);

            Button SendReceiptToCustomer = FindViewById <Button>(Resource.Id.btnSendReceiptToCustomer);
            Button UpdateSubTotal        = FindViewById <Button>(Resource.Id.btnUpdateOrderAmount);

            UpdateSubTotal.Click        += UpdateSubTotal_Click;
            SendReceiptToCustomer.Click += async(sender, e) => {
                UpdateProductEntity updateProductEntity = new UpdateProductEntity {
                    AuthToken = AuthToken, productInfo = GetProductsData()
                };
                JsonValue json = await HttpRequestHelper <UpdateProductEntity> .POSTreq(ServiceTypes.UpdateProductAvailability, updateProductEntity);

                ParseJSON(json);
            };
        }
        protected async override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            //drawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawer_layout);
            //LayoutInflater inflater = (LayoutInflater)this.GetSystemService(Context.LayoutInflaterService);
            //View contentView = inflater.Inflate(Resource.Layout.Product, null, false);
            //drawerLayout.AddView(contentView);
            SetContentView(Resource.Layout.Product);
            RecieptDTO user = JsonConvert.DeserializeObject <RecieptDTO>(Intent.GetStringExtra("RecieptData"));
            //var extras = Intent.GetParcelableExtra("RecieptData") ?? String.Empty;
            string textRecieptName = user.Name;

            textRecieptID = user.RecieptID.ToString();
            TextView txtRecieptName     = FindViewById <TextView>(Resource.Id.recieptTxt);
            TextView txtProductName     = FindViewById <TextView>(Resource.Id.editProductName);
            TextView txtProductQuantity = FindViewById <TextView>(Resource.Id.editProductQuantity);

            txtRecieptName.Text = textRecieptName;
            SessionHelper sessionHelper = new SessionHelper(this);
            string        Username      = sessionHelper.GetSessionKey(SessionKeys.SESSION_USERNAME_KEY);
            string        UserID        = sessionHelper.GetSessionKey(SessionKeys.SESSION_USERID_KEY);
            string        AuthToken     = sessionHelper.GetSessionKey(SessionKeys.SESSION_TOKEN_KEY);

            ImageButton btnAddProduct = FindViewById <ImageButton>(Resource.Id.btnAddProduct);
            JsonValue   jsonProduct   = await HttpRequestHelper <ProductEntity> .GetRequest(ServiceTypes.GetProducts, "/" + AuthToken + "/" + textRecieptID);

            ParseRecieptJSON(jsonProduct);

            Button btnSendReceipt = FindViewById <Button>(Resource.Id.btnSendReceipt);

            btnSendReceipt.Click += BtnSendReceipt_Click;

            btnAddProduct.Click += async(sender, e) =>
            {
                progress = new Android.App.ProgressDialog(this);
                progress.Indeterminate = true;
                progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner);
                progress.SetMessage("Adding product... Please wait...");
                progress.SetCancelable(false);
                progress.Show();
                try
                {
                    ProductDTO productDTO = new ProductDTO();
                    productDTO.AddedOn   = DateTime.Now.ToString();
                    productDTO.Name      = txtProductName.Text;
                    productDTO.Quantity  = txtProductQuantity.Text;
                    productDTO.RecieptID = Convert.ToInt32(textRecieptID);
                    ProductEntity productEntity = new ProductEntity {
                        AuthToken = AuthToken, productInfo = productDTO
                    };
                    JsonValue json = await HttpRequestHelper <ProductEntity> .POSTreq(ServiceTypes.AddProduct, productEntity);

                    ParseJSON(json);

                    JsonValue jsonProduct1 = await HttpRequestHelper <ProductEntity> .GetRequest(ServiceTypes.GetProducts, "/" + AuthToken + "/" + textRecieptID);

                    ParseRecieptJSON(jsonProduct1);
                    progress.Hide();
                }
                catch (Exception ex)
                {
                }
            };
        }