//EVENT
        void OnSignupClicked(object sender, EventArgs args)
        {
            var customer = new Customer
            {
                MainPhone = MainPhone,
                Email     = Email,
                Name      = FirstName + " " + LastName
            };

            if (!string.IsNullOrEmpty(Day) || !string.IsNullOrEmpty(Month) || !string.IsNullOrEmpty(Year))
            {
                var(isValidateSuccess, dayOfBirth) = FuncHelp.ValidateDateTime(Year, Month, Day);
                if (isValidateSuccess)
                {
                    customer.DateOfBirth = (DateTime)dayOfBirth;
                }
                else
                {
                    //notification error:

                    //then return
                    return;
                }
            }
            Execute(Command, customer);
        }
예제 #2
0
        static void HelpOf(Statement statement)
        {
            if (FuncHelp.TryGetValue(statement.Command, out var help))
            {
                uint count = 0;

                PrintHelp(help, ref count);
            }
            else
            {
                Program.Print(ConsoleColor.Red, $"Help by '{statement.Command}' is not found");
            }

            void PrintHelp(System.Xml.Linq.XElement element, ref uint count)
            {
                foreach (var item in element.Elements())
                {
                    if (item.Elements().ToArray().Length == 0)
                    {
                        Program.Print(ConsoleColor.Blue, $"{item.Name.LocalName.ToUpper()}:\n{new String( '\t', ( int )count + 1 )}{item.Value}\n", new String('\t', ( int )count));
                    }
                    else
                    {
                        Program.Print(ConsoleColor.Blue, $"{item.Name.LocalName.ToUpper()}:\n{new String( '\t', ( int )count + 1 )}", new String('\t', ( int )count));
                        count++;
                        PrintHelp(item, ref count);
                    }
                }
                count--;
            }
        }
예제 #3
0
        //LOGIN
        public async Task <bool> Login(User user)
        {
            var body     = "userName="******"&password="******"&grant_type=password";
            var response = await DataService.Post(FuncHelp.GetUri(Constants.URL_LOGIN), FuncHelp.EncodeString(body));

            if (response != null && response.IsSuccessStatusCode)
            {
                var content = await response.Content.ReadAsStringAsync();

                // save info of user login:
                User = JsonConvert.DeserializeObject <User>(content);

                //save access_token:
                await LocalStorage.SetAccessToken(User.Access_Token);

                //save userid:
                await LocalStorage.SetUserId(User.Id);

                //set Authorizationon request header, with access_token just get from server :
                DataService.Client.SetDefaultHeaders();

                return(true);
            }
            return(false);
        }
예제 #4
0
        //SIGNUP
        public async Task <bool> Signup(User user)
        {
            var body   = "userName="******"&email=" + user.Email + "&password="******"&grant_type=password";
            var result = await DataService.Post(FuncHelp.GetUri(Constants.URL_SIGNUP), FuncHelp.EncodeString(body));

            Debug.WriteLine(result);
            return(true);
        }
예제 #5
0
    public static async void Notification(this View view)
    {
        var page = FuncHelp.CurrentPage();
        await view.TranslateTo(-page.Width + 200, 0, 250, Easing.SinInOut);

        await Task.Delay(1600);

        await view.TranslateTo(0, 0, 250, Easing.SinInOut);
    }
예제 #6
0
        static void Boot()
        {
            bool hasFile = File.Exists(FilePath), hasData = File.Exists(DataPath);

            if (!hasFile || !hasData)
            {
                string file = !hasFile?Path.GetFileName(FilePath) : Path.GetFileName(DataPath);

                throw new Exception($"File '{file}' missing. Sorry :(");
            }

            XDocument document, data;

            try
            {
                document = XDocument.Load(FilePath);
                data     = XDocument.Load(DataPath);
            }
            catch (XmlException)
            {
                throw new Exception($"Invalid format loaded files. Sorry :(");
            }

            foreach (var item in document.Element(Tags["body"]).Elements())
            {
                FuncHelp.Add(item.Name.LocalName, item);

                if (item.Element(Tags["param"]) != null && item.Element(Tags["alias"]).Value.Trim().Length != 0)
                {
                    AliasFunc.Add(item.Name.LocalName, item.Element(Tags["alias"]).Value);
                }

                var attrs = new Dictionary <string, char> {
                };

                if (item.Element(Tags["param"]) != null)
                {
                    foreach (var attr in item.Element(Tags["param"]).Elements())
                    {
                        attrs.Add(attr.Name.LocalName, attr.Value.Trim()[0]);
                    }
                }
                else
                {
                    continue;
                }

                Attributes.Add(item.Name.LocalName, attrs);
            }

            foreach (var item in data.Element(Tags["body"]).Elements())
            {
                Accaunts.Add(item.Attribute(Tags["id"]).Value, item);
            }
        }
예제 #7
0
        //POST customer
        public async Task <bool> Post(Customer customer)
        {
            var uri           = FuncHelp.GetUri(Constants.URL_POST_CUSTOMER);
            var stringContent = FuncHelp.EncodeModel(customer);
            var response      = await DataService.Post(uri, stringContent);

            if (response != null && response.IsSuccessStatusCode)
            {
                //return:
                return(true);
            }
            return(false);
        }
        public override async Task Init()
        {
            await Task.Delay(1);

            //auto back page
            Device.StartTimer(TimeSpan.FromSeconds(15), () =>
            {
                if (FuncHelp.CurrentPage() is CustomerFinishPage)
                {
                    ExitCommand.Execute(null);
                }
                return(false); // not repeat
            });
        }
예제 #9
0
        //GET
        public async Task <HttpResponseMessage> Get(string url)
        {
            try
            {
                IsLoading = true;
                var result = await Client.GetAsync(FuncHelp.GetUri(url));

                IsLoading = false;
                return(result);
            }
            catch
            {
                return(null);
            }
        }
예제 #10
0
        //PUT customer
        public async Task <Customer?> Put(Customer customer)
        {
            var uri           = FuncHelp.GetUri(Constants.URL_PATCH_CUSTOMER);
            var stringContent = FuncHelp.EncodeModel(new { customer = customer, sourceRequest = "SunClient" });
            var response      = await DataService.Put(uri, stringContent);

            if (response != null && response.IsSuccessStatusCode)
            {
                var content = await response.Content.ReadAsStringAsync();

                if (content != null)
                {
                    //get customer already edited from server:
                    var _customer = JsonConvert.DeserializeObject <Customer>(content);

                    return(_customer);
                }
            }
            return(null);
        }