private async Task <GetRecieptResponse> GetReciepts()
        {
            JsonValue GetRecieptResponse = await HttpRequestHelper <string> .GetRequest(ServiceTypes.GetOrderedRecieptsForStore, SessionHelper.AccessToken);

            GetRecieptResponse getRecieptResponse = JsonConvert.DeserializeObject <GetRecieptResponse>(GetRecieptResponse.ToString());

            if (getRecieptResponse.IsSuccess)
            {
                //bind data in listView
                List <QueuedOrdersModel> lstGetReciepts = getRecieptResponse.LstReciepts.Select(dc => new QueuedOrdersModel()
                {
                    CreatedOn = dc.CreatedOn,
                    Name      = dc.Name,
                    Price     = dc.Price,
                    RecieptID = dc.RecieptID,
                    Status    = dc.Status,
                    StoreID   = dc.StoreID
                }).ToList();


                RecieptsData = new ObservableCollection <QueuedOrdersModel>();

                foreach (QueuedOrdersModel getReciept in lstGetReciepts)
                {
                    RecieptsData.Add(getReciept);
                }
            }
            else
            {
                await App.Current.MainPage.DisplayAlert("Error", getRecieptResponse.Message, "Ok");
            }
            return(getRecieptResponse);
        }
Example #2
0
        private async Task <GetRecieptResponse> GetReciepts()
        {
            JsonValue GetRecieptResponse = await HttpRequestHelper <GetRecieptRequest> .GetRequest(ServiceTypes.GetReciepts, SessionHelper.AccessToken);

            GetRecieptResponse getRecieptResponse = JsonConvert.DeserializeObject <GetRecieptResponse>(GetRecieptResponse.ToString());

            if (getRecieptResponse.IsSuccess)
            {
                List <AddRecieptModel> lstGetReciepts = getRecieptResponse.LstReciepts.Select(dc => new AddRecieptModel()
                {
                    Name      = dc.Name,
                    Price     = dc.Price,
                    RecieptID = (long)dc.RecieptID,
                    Status    = dc.Status
                }).ToList();

                RecieptsData = new ObservableCollection <AddRecieptModel>();

                foreach (AddRecieptModel getReciept in lstGetReciepts)
                {
                    RecieptsData.Add(getReciept);
                }
            }
            else
            {
            }
            return(getRecieptResponse);
        }
Example #3
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);
        }