Beispiel #1
0
        public async Task SaveCustomer()
        {
            if (PSelectedCustomer != null)
            {
                CustomerDetailsResponseModel customerDetailsResponseModel = null;
                if (GlobalVariables.IsOffline)
                {
                    customerDetailsResponseModel = DataSync.GetDataSyncCustomerDetails(PSelectedCustomer.CustomerEntityID);
                }
                else
                {
                    string result = await APIRequest.Instance.GetCustomerDetailsList(new CustomerDetailsRequestModel {
                        CustomerEntityID = PSelectedCustomer.CustomerEntityID
                    });

                    if (result != null)
                    {
                        customerDetailsResponseModel = JsonConvert.DeserializeObject <CustomerDetailsResponseModel> (result);
                    }
                }

                if (customerDetailsResponseModel != null)
                {
                    try {
                        if (SQLiteDatabase.Instance.InsertCustomerDetails(customerDetailsResponseModel))
                        {
                            GlobalVariables.CustomerEntityID = PSelectedCustomer.CustomerEntityID;
                            GlobalVariables.CustomerID       = PSelectedCustomer.CustomerID;
                            GlobalVariables.CustomerName     = PSelectedCustomer.CustomerName;


                            MessagingCenter.Send <VMCustomerList> (this, Strings.CustomerList_Success);
                        }
                    } catch (Exception ex) {
                        GlobalVariables.DisplayMessage = "Error";
                        MessagingCenter.Send <VMCustomerList> (this, Strings.Display_Message);
                    }
                }
            }
            else
            {
                GlobalVariables.DisplayMessage = "Please Select Customer";
                MessagingCenter.Send <VMCustomerList> (this, Strings.Display_Message);
            }
        }
Beispiel #2
0
        public static CustomerDetailsResponseModel GetDataSyncCustomerDetails(string CustomerEntityID)
        {
            try {
                string strCustomerDetails = SQLiteDatabase.Instance.GetDataSyncCustomerDetails() [0].Data.ToDecrypt();
                CustomerDetailsResponseModel customerDetailsResponseModel = JsonConvert.DeserializeObject <CustomerDetailsResponseModel> (strCustomerDetails);

                CustomerDetailsResponseModel objCustomerDetailsResponseModel = new CustomerDetailsResponseModel();

                objCustomerDetailsResponseModel.CustomerDetails = (from customer in customerDetailsResponseModel.CustomerDetails
                                                                   where customer.CustomerEntityId == CustomerEntityID
                                                                   select customer).ToList();

                objCustomerDetailsResponseModel.AccountDetails = (from customer in customerDetailsResponseModel.AccountDetails
                                                                  where customer.CustomerEntityId == CustomerEntityID
                                                                  select customer).ToList();


                return(objCustomerDetailsResponseModel);
            } catch {
                return(null);
            }
        }
Beispiel #3
0
        public bool InsertCustomerDetails(CustomerDetailsResponseModel customerDetailsResponseModel)
        {
            try {
                database.CreateTable <CustomerDetailsModel> ();
                database.CreateTable <AccountDetailModel> ();

                try {
                    database.DeleteAll <CustomerDetailsModel> ();
                } catch {
                }

                try {
                    database.DeleteAll <AccountDetailModel> ();
                } catch {
                }

                if (customerDetailsResponseModel.CustomerDetails != null)
                {
                    foreach (CustomerDetailsModel cm in customerDetailsResponseModel.CustomerDetails)
                    {
                        database.Insert(cm);
                    }
                }

                if (customerDetailsResponseModel.AccountDetails != null)
                {
                    foreach (AccountDetailModel Account in customerDetailsResponseModel.AccountDetails)
                    {
                        database.Insert(Account);
                    }
                }


                return(true);
            } catch {
                return(false);
            }
        }