Ejemplo n.º 1
0
        async void LoadEmployees()
        {
            LoadingOverlay loadO = new LoadingOverlay(UIScreen.MainScreen.Bounds);

            View.Add(loadingOverlay);

            try
            {
                var query = ParseObject.GetQuery("AliensEmployees");
                query.Include("Name").Include("Email").Include("IsRegistered");
                var iEnumerablecoll = await query.FindAsync();

                foreach (var parseObj in iEnumerablecoll)
                {
                    string emplName     = parseObj.Get <string>("Name");
                    string email        = parseObj.Get <string>("Email");
                    bool   isRegistered = parseObj.Get <bool>("IsRegistered");
                    employees.Add(new AliensEmployees(emplName, email, isRegistered));
                    employeeObjs.Add(parseObj);
                }
            }
            catch (NullReferenceException ex)
            {
                loadO.Hide();
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
            loadO.Hide();
        }
Ejemplo n.º 2
0
        public async void AddQueueOrders()
        {
            loadingOverlay = new LoadingOverlay(UIScreen.MainScreen.Bounds);
            View.Add(loadingOverlay);

            ActiveOrdersList.Clear();

            ParseQuery <ParseObject> query = from ordersTB in ParseObject.GetQuery("Orders")
                                             where ordersTB.Get <bool>("IsOrderDone") == false
                                             select ordersTB;

            IEnumerable <ParseObject> column = await query.FindAsync();

            loadingOverlay.Hide();

            foreach (ParseObject nameElements in column)
            {
                string nameOfCurrentUser = orderViewController.GetName;
                string namesColumn       = nameElements.Get <string>("PersonOrdered");
                string replacedName      = namesColumn.Replace(nameOfCurrentUser, "You");
                string time = nameElements.Get <string>("Time");
                ActiveOrdersList.Add(replacedName + "#" + time);
            }
            PopulateTable();
        }
Ejemplo n.º 3
0
        public async void AddOrders()
        {
            AdminGetOrders.Clear();

            try
            {
                loadingOverlay = new LoadingOverlay(UIScreen.MainScreen.Bounds);
                View.Add(loadingOverlay);

                ParseQuery <ParseObject> query = from ordersTb in ParseObject.GetQuery("Orders")
                                                 where ordersTb.Get <bool>("IsOrderDone") == false
                                                 select ordersTb;

                IEnumerable coll = await query.FindAsync();

                List <string> itemsOrdered;

                foreach (ParseObject parseObject in coll)
                {
                    OrderReceivedByAdmin(parseObject);
                    itemsOrdered = new List <string>();
                    string objectId      = parseObject.ObjectId;
                    string personOrdered = parseObject.Get <string>("PersonOrdered");
                    orderItems  = parseObject.Get <IList>("OrderList");
                    ChannelName = parseObject.Get <string>("UserChannel");
                    double price = parseObject.Get <double>("Price");

                    foreach (string e in orderItems)
                    {
                        itemsOrdered.Add(e);
                    }

                    AdminGetOrders.Add(new OrdersAdmin(objectId, personOrdered, ChannelName, price, itemsOrdered));
                }

                loadingOverlay.Hide();
                PopulateTable();
            }
            catch (ParseException e)
            {
                loadingOverlay.Hide();
                Debug.WriteLine(e.StackTrace);
            }
        }
Ejemplo n.º 4
0
        async void SubmittOrders(double prices)
        {
            orderWaitTime.GetOrdersTotal = Source.ordersList.Count;
            time = orderWaitTime.CalculateWaitTime();
            AlertPopUp("Order on the way", "Your order will take about " + time + " minutes", "OK");
            string[] arrSplit = VouchersLabel.Text.Split(' ');
            voucherUpdate = int.Parse(arrSplit[0]);

            loadingOverlay = new LoadingOverlay(UIScreen.MainScreen.Bounds);
            View.Add(loadingOverlay);

            try
            {
                TableNameOrders = new ParseObject("Orders");
                TableNameOrders["PersonOrdered"]        = GetName;
                TableNameOrders["OrderList"]            = items;
                TableNameOrders["Price"]                = prices;
                TableNameOrders["IsOrderDone"]          = false;
                TableNameOrders["OrderReceivedByAdmin"] = false;
                TableNameOrders["Time"]        = "" + time;
                TableNameOrders["UserChannel"] = GetUserChannelName;
                CurrentUser["Vouchers"]        = voucherUpdate;

                await TableNameOrders.SaveAsync();

                await CurrentUser.SaveAsync();

                items.Clear();

                //send push

                var push = new ParsePush();
                push.Channels = new List <string> {
                    "Admin"
                };

                push.Data = new Dictionary <string, object>
                {
                    { "alert", "New order from " + (GetName + " " + GetSurname).ToUpper() },
                    { "sound", "default" },
                    { "badge", "Increment" }
                };

                await push.SendAsync();

                Source.Ordered           = true;
                Source.GetInitialVoucher = voucherUpdate + " vouchers";
            }
            catch (ParseException q)
            {
                Debug.WriteLine(q.StackTrace);
            }

            ResetScreen();
            loadingOverlay.Hide();
        }
Ejemplo n.º 5
0
        async void LoadUsernames()
        {
            loadingOverlay = new LoadingOverlay(UIScreen.MainScreen.Bounds);
            View.Add(loadingOverlay);
            try
            {
                var query = ParseUser.Query;
                query.Include("username");

                var coll = await query.FindAsync();

                foreach (ParseObject element in coll)
                {
                    usernameCheck.Add(element.Get <string>("username"));
                }
            }
            catch (NullReferenceException)
            {
                loadingOverlay.Hide();
                AlertPopUp("Error", "No internet connection", "OK");
            }

            loadingOverlay.Hide();
        }
Ejemplo n.º 6
0
        async void UpdateRegistered()
        {
            LoadingOverlay ldOvly = new LoadingOverlay(UIScreen.MainScreen.Bounds);

            View.Add(ldOvly);

            foreach (ParseObject employeeObjsElements in employeeObjs)
            {
                string empName  = employeeObjsElements.Get <string>("Name");
                string empEmail = employeeObjsElements.Get <string>("Email");

                if (GetNameTxt.ToLower().Equals(empName.ToLower()) && GetEmailTxt.ToLower().Equals(empEmail.ToLower()))
                {
                    employeeObjsElements["IsRegistered"] = true;
                    await employeeObjsElements.SaveAsync();
                }
            }

            ldOvly.Hide();
        }
Ejemplo n.º 7
0
        async void ShowUnpaid()
        {
            LoadingOverlay lo = new LoadingOverlay(UIScreen.MainScreen.Bounds);

            View.Add(lo);
            try
            {
                var query = from unpaid in ParseObject.GetQuery("Unpaid")
                            where unpaid.Get <bool>("Paid") == false
                            select unpaid;

                var results = await query.FindAsync();

                UnpaidContainer container = new UnpaidContainer();

                foreach (var elements in results)
                {
                    string objectID    = elements.ObjectId;
                    string name        = elements.Get <string>("Name");
                    string userChannel = elements.Get <string>("UserChannel");
                    double amountOwing = elements.Get <double>("AmountOwing");

                    container.Order = new OrdersAdmin(objectID, name, userChannel, amountOwing);
                    container.InitialiseMaps();
                    container.InitialiseList(elements);
                }

                Source             = new TableSourceUnpaid(container.GetOrdersMap, container.GetParseObjectList, container.GetUnaddedOrders);
                unpaidTable.Source = Source;
                unpaidTable.ReloadData();
            }
            catch (ParseException ex)
            {
                Debug.WriteLine(ex.Message);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.GetType() + "\n" + ex.Message);
            }
            lo.Hide();
        }
Ejemplo n.º 8
0
        async void AddToDB(string name, string surname, string username, string password, string email, int vouchers)
        {
            loadingOverlay = new LoadingOverlay(UIScreen.MainScreen.Bounds);
            View.Add(loadingOverlay);

            var user = new ParseUser()
            {
                Username = username,
                Password = password,
                Email    = email
            };

            user["Name"]     = name;
            user["Surname"]  = surname;
            user["Vouchers"] = vouchers;
            user["IsAdmin"]  = false;

            await user.SignUpAsync();

            loadingOverlay.Hide();
        }
Ejemplo n.º 9
0
        async void LoadTableFuctionality()
        {
            DidInitiliseSource = false;
            try
            {
                loadingOverlay = new LoadingOverlay(UIScreen.MainScreen.Bounds);
                View.Add(loadingOverlay);
                ParseQuery <ParseObject> query = ParseObject.GetQuery("Coffees");
                query.Include("Title").Include("Price").Include("ImageName");

                var iEnumerableColl = await query.FindAsync();

                foreach (ParseObject coffeeElements in iEnumerableColl)
                {
                    string coffeeName = coffeeElements.Get <string>("Title");
                    string imageName  = coffeeElements.Get <string>("ImageName");
                    double price      = coffeeElements.Get <double>("Price");

                    coffeeItems.Add(new Coffee(coffeeName, imageName, "" + price));
                }

                loadingOverlay.Hide();
            }
            catch (ParseException)
            {
                loadingOverlay.Hide();
                AlertPopUp("Error", "Connection error", "OK");
            }

            Source         = new TableSourceOrdering(coffeeItems);
            Source.Voucher = VouchersLabel.Text;

            Source.Launched          = true;
            Source.Ordered           = false;
            Source.GetInitialVoucher = VouchersLabel.Text;

            ordersTable.Source = Source;
            ordersTable.ReloadData();
            DidInitiliseSource = true;

            Source.onCellForOrderName += (sender, e) =>
            {
                CellName = e;
            };

            Source.onCellSelectedForVouchers += (sender, e) =>
            {
                VoucherCount.Voucher      = e;
                VoucherCount.IsSelected   = true;
                VoucherCount.IsDeselected = false;
                VoucherCount.VoucherChange();
                VouchersLabel.Text = "" + VoucherCount.GetVoucher() + " Vouchers";
                Source.Voucher     = VouchersLabel.Text;

                if (!VoucherCount.IsVoucherDepleted)
                {                          // tag all the orders purchased by vouchers
                    taggedOrders.Add(new TagOrder(CellName));
                    taggedOrderNamesForPrice.Add(CellName);
                }
            };

            Source.onCellDeselectedForVouchers += (sender, e) =>
            {
                //increments voucher if its a tagged order

                VoucherCount.HasTag = false;

                foreach (TagOrder order in taggedOrders)
                {
                    //if (!NamesOfTaggedOrders.Contains(order.OrderName)) NamesOfTaggedOrders += order.OrderName + "*";
                    if (order.OrderName.Equals(CellName))
                    {
                        Debug.WriteLine(order.OrderName);
                        NamesOfTaggedOrders = order.OrderName;
                        taggedOrders.Remove(order);
                        VoucherCount.HasTag = true;
                        break;
                    }
                }

                if (PriceCount.Depleted)
                {
                    VoucherCount.IsDeselected = true;
                    VoucherCount.IsSelected   = false;
                    VoucherCount.VoucherChange();
                    VouchersLabel.Text = "" + VoucherCount.GetVoucher() + " Vouchers";
                    Source.Voucher     = VouchersLabel.Text;
                }
                else if (CellName.Equals(NamesOfTaggedOrders))
                {
                    VoucherCount.IsDeselected = true;
                    VoucherCount.IsSelected   = false;
                    VoucherCount.VoucherChange();
                    VouchersLabel.Text = "" + VoucherCount.GetVoucher() + " Vouchers";
                    Source.Voucher     = VouchersLabel.Text;
                }
                NamesOfTaggedOrders = string.Empty;
            };

            Source.onCellSelectedForPrice += (sender, e) =>
            {
                if (VoucherCount.IsVoucherDepleted)
                {
                    PriceCount.Price      = e;
                    PriceCount.Selected   = true;
                    PriceCount.Deselected = false;
                    PriceCount.PriceChange();
                    costText.Text = PriceCount.GetPrice().ToString("R 0.00");
                }
            };

            Source.onCellDeselectedForPrice += (sender, e) =>
            {
                const int VOUCHER_BEFORE_EXECUTION_TO_ZERO = 1;

                if (VoucherCount.IsVoucherDepleted && VoucherCount.Voucher != VOUCHER_BEFORE_EXECUTION_TO_ZERO)
                {
                    PriceCount.Price      = e;
                    PriceCount.Selected   = false;
                    PriceCount.Deselected = true;
                    PriceCount.PriceChange();
                    costText.Text = PriceCount.GetPrice().ToString("R 0.00");
                }
                else if (VoucherCount.GetVoucher() != 0 && !VoucherCount.HasTag)
                {
                    PriceCount.Price      = e;
                    PriceCount.Selected   = false;
                    PriceCount.Deselected = true;
                    PriceCount.PriceChange();
                    costText.Text = PriceCount.GetPrice().ToString("R 0.00");
                }
            };
        }
Ejemplo n.º 10
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            NavigationController.NavigationBarHidden = true;

            DismissKeyboardOnBackgroundTap();
            RegisterForKeyboardNotifications();

            usernameText.BecomeFirstResponder();
            ShouldReturn(usernameText, passwordText);
            TextFieldKeyboardIteration(usernameText, passwordText);

            forgotPasswordButton.TouchUpInside += (o, e) =>
            {
                ClearFields(usernameText, passwordText);
                NavigationScreenController(forgotPasswordViewController);
            };

            int i = 0;

            loginButton.TouchUpInside += async(sender, evt) =>
            {
                i++;
                string username = usernameText.Text;
                string password = passwordText.Text;

                switch ((!username.Equals("") && !password.Equals("")) && (!(username.Length > 10) && !(username.Length < 5)))
                {
                case true:
                    ParseUser result = null;

                    try
                    {
                        loadingOverlay = new LoadingOverlay(UIScreen.MainScreen.Bounds);
                        View.Add(loadingOverlay);

                        result = await ParseUser.LogInAsync(TrimInput(usernameText.Text), TrimInput(passwordText.Text));
                    }
                    catch (ParseException ex)
                    {
                        Debug.WriteLine(ex.GetType());
                        loadingOverlay.Hide();
                        AlertPopUp("Login failed", "Username or password incorrect", "OK");

                        if (i == 3)
                        {
                            AlertPopUp("Login failed!!", "You failed to login 3 times we suggest \nyou either Register or retrieve lost password", "OK");
                            loginButton.Enabled = false;
                        }
                    }
                    catch (NullReferenceException)
                    {
                        loadingOverlay.Hide();
                        AlertPopUp("Login failed!!", "Please check your internet connection", "OK");
                    }

                    try
                    {
                        string name            = result.Get <string>("Name");
                        string surname         = result.Get <string>("Surname");
                        bool   isAdmin         = result.Get <bool>("IsAdmin");
                        int    vouchers        = result.Get <int>("Vouchers");
                        string userChannelName = name + surname;

                        orderViewController.GetName     = name;
                        orderViewController.GetSurname  = surname;
                        orderViewController.CurrentUser = result;
                        orderViewController.GetVouchers = vouchers;

                        orderViewController.GetUserChannelName = userChannelName;
                        // create user channel
                        var installation = ParseInstallation.CurrentInstallation;
                        //Debug.WriteLine( installation.DeviceToken);

                        if (isAdmin)
                        {
                            installation.Channels = new string[] { "Admin" };
                        }
                        else
                        {
                            installation.Channels = new string[] { userChannelName.ToLower() };
                        }

                        await installation.SaveAsync();

                        loadingOverlay.Hide();

                        if (isAdmin)
                        {
                            NavigationScreenController(adminViewController);
                        }
                        else
                        {
                            NavigationScreenController(orderViewController);
                        }
                    }
                    catch (ParseException ex)
                    {
                        loadingOverlay.Hide();
                        Debug.WriteLine(ex.Message);
                        AlertPopUp("Error", "Can't login server error, try again in a while ", "Ok");
                    }
                    catch (NullReferenceException e)
                    {
                        Debug.WriteLine(e.Message);
                    }

                    break;

                case false:

                    if (username.Length == 0 || password.Length == 0)
                    {
                        AlertPopUp("Error", "Please fill in all your credentials", "OK");
                    }
                    else if ((username.Length > 10 || username.Length < 5))
                    {
                        AlertPopUp("Error", "Username or password is too long/short", "OK");
                    }

                    break;
                }

                ClearFields(usernameText, passwordText);
            };

            registerButton.TouchUpInside += (o, e) =>
            {
                NavigationScreenController(registerViewController);
                ClearFields(usernameText, passwordText);
            };
        }