async Task LoadProjectsFromDb()
        {
            var projects = await GetStorageService().GetProjects(Id);

            foreach (var asanaProject in projects)
            {
                var tasksCount = await SetProjectInfo(asanaProject);

                asanaProject.TasksCount        = tasksCount.Item1;
                asanaProject.OverdueTasksCount = tasksCount.Item2;
            }


            DispatcherHelper.OnUi(() =>
            {
                //model.ArchiveProjects.Clear();
                Projects.Clear();
                Projects.AddRange(projects);
                Workspace.ProjectsCount = projects.Count(x => !x.archived);

                if (IsPinned)
                {
                    PinService.CreateUpdateStartTileAsync(Workspace.name, Workspace.ProjectsCountText, PinService.GetWorkspaceDetailsUri(Id), false);
                }

                // model.ArchiveProjects.AddRange(projects.Where(x => x.archived));
            });
        }
Пример #2
0
        private async Task LoadTasksFromDb()
        {
            var tasks = await new StorageService().GetTasks(Id);


            foreach (var asanaTask in tasks)
            {
                FillTaskCommands(asanaTask);
                await MapperService.FillSubtasksInfo(asanaTask);
            }

            Tasks.Clear();
            Tasks.AddRange(tasks);



            Project.TasksCount = ActiveTasks.Count;

            if (IsPinned)
            {
                PinService.CreateUpdateStartTileAsync(Project.name, Project.TasksCountText,
                                                      PinService.GetProjectDetailsUri(Id), false);
            }



            NotifyAll();
        }
        protected override async void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            this.Id = long.Parse(NavigationManager.GetQueryParameter("id"));
            var workspace = await new StorageService().Find <AsanaWorkspace>(Id);

            Workspace = workspace;
            IsPinned  = PinService.Exists(PinService.GetWorkspaceDetailsUri(Id));
        }
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            Container.Resolve <IMessagePublisher>().Register(this);
            var userId = long.Parse(NavigationManager.GetQueryParameter("id"));

            UserId   = userId;
            IsPinned = PinService.Exists(PinService.GetUserDetailsUri(userId));
        }
Пример #5
0
 void PinToStart(object sender)
 {
     if (IsPinned)
     {
         PinService.RemoveTile(PinService.GetProjectDetailsUri(Id));
         IsPinned = false;
     }
     else
     {
         PinService.CreateUpdateStartTile(Project.name, Project.TasksCountText, PinService.GetProjectDetailsUri(Id), true);
         IsPinned = true;
     }
 }
Пример #6
0
        protected override async void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            Container.Resolve <IMessagePublisher>().Register(this);

            var id = long.Parse(NavigationManager.GetQueryParameter("id"));

            Id = id;
            var project = await new StorageService().Find <AsanaProject>(Id);

            //project.notes = TextHelper.SafeTruncate(project.notes, 100);
            Project = project;

            IsPinned = PinService.Exists(PinService.GetProjectDetailsUri(Id));
        }
        public async void LoadData(bool isUserAction = false)
        {
            IsBusy = true;
            User   = await new StorageService().Find <AsanaUser>(UserId);

            await LoadTasksFromDb();

            IsBusy = false;

            if (NavigationEventArgs.IsBackOrReset())
            {
                NotifyAll();
                return;
            }

            if (CheckInternetConnection(false))
            {
                AddOperation();



                var tasks = new List <System.Threading.Tasks.Task>();
                foreach (var w in User.GetAvailableWorkspaces())
                {
                    tasks.Add(LoadTasks(w, isUserAction));
                }


                System.Threading.Tasks.Task.Factory.ContinueWhenAll(tasks.ToArray(), x =>
                {
                    User.TasksCount =
                        ActiveTasks.Count;

                    if (IsPinned)
                    {
                        PinService.CreateUpdateStartTileAsync(User.name, User.TasksCountText, PinService.GetUserDetailsUri(UserId), false);
                    }

                    RemoveOperation();
                });
            }
            await OffineSyncTaskService.Execute(this, () => { });
        }
Пример #8
0
 public PinController(PinService pinService)
 => _pinService = pinService;
Пример #9
0
 public void SetUp()
 {
     _pinService = new PinService();
 }
Пример #10
0
        static void Main(string[] args)
        {
            // initialise PIN by setting your API Keys in appsettings.json
            // See:  https://pin.net.au/docs/api#keys
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
                          .AddJsonFile("appsettings.development.json", optional: true, reloadOnChange: true);

            IConfigurationRoot configuration = builder.Build();

            var options = new PinPaymentsOptions();

            configuration.GetSection("PinPayments").Bind(options);

            System.Console.WriteLine($"BaseUrl: {options.BaseUrl}");
            System.Console.WriteLine($"ApiKey: {options.ApiKey}");

            PinService ps = new PinService(options);

            // https://pin.net.au/docs/api/test-cards
            // 5520000000000000 - Test Mastercard
            // 4200000000000000 - Test Visa

            var card = new Card();

            card.CardNumber  = "5520000000000000";
            card.CVC         = "111";
            card.ExpiryMonth = DateTime.Today.Month.ToString();              // Use the real Expiry
            card.ExpiryYear  = (DateTime.Today.Year + 1).ToString();         // Not my defaults!
            card.Name        = "Roland Robot";
            card.Address1    = "42 Sevenoaks St";
            card.Address2    = null;
            card.City        = "Lathlain";
            card.Postcode    = "6454";
            card.State       = "WA";
            card.Country     = "Australia";

            System.Console.WriteLine($"Charging API");
            var response = ps.Charge(new PostCharge {
                Amount = 1500, Card = card, Currency = "AUD", Description = "Desc", Email = "*****@*****.**", IPAddress = "127.0.0.1"
            });

            System.Console.WriteLine(response.Charge.Success);
            System.Console.WriteLine(response.Charge.Token);

            // Refunds - Pin supports partial refunds
            // https://pin.net.au/docs/api/customers#get-customers-charges

            System.Console.WriteLine($"Refunding");
            var refund = ps.Refund(response.Charge.Token, 200);

            refund = ps.Refund(response.Charge.Token, 100);

            System.Console.WriteLine($"Getting refunds for token {response.Charge.Token}");
            var refunds = ps.Refunds(response.Charge.Token);

            // Searching for a Charge
            // See https://pin.net.au/docs/api/charges#search-charges for more detail

            System.Console.WriteLine($"Searching for a charge");
            var respChargesSearch = ps.ChargesSearch(new Actions.ChargeSearch {
                Query = "", Sort = ChargeSearchSortEnum.Amount, SortDirection = SortDirectionEnum.Descending
            });

            System.Console.WriteLine(respChargesSearch.Count.ToString() + " transactions found");
            foreach (var r in respChargesSearch.Response)
            {
                System.Console.WriteLine(r.Description + " " + r.Amount.ToString());
            }

            var respChargeSearch = ps.Charge(respChargesSearch.Response[0].Token);

            System.Console.WriteLine(respChargeSearch.Response.Description);


            // Create Customer
            // See: https://pin.net.au/docs/api/customers#post-customers
            System.Console.WriteLine($"Creating customer");
            var customer = new Customer();

            customer.Email            = "*****@*****.**";
            customer.Card             = new Card();
            customer.Card.CardNumber  = "5520000000000000";
            customer.Card.ExpiryMonth = DateTime.Today.Month.ToString();              // Use the real Expiry
            customer.Card.ExpiryYear  = (DateTime.Today.Year + 1).ToString();         // Not my defaults!
            customer.Card.CVC         = "123";
            customer.Card.Name        = "Roland Robot";
            customer.Card.Address1    = "42 Sevenoaks St";
            customer.Card.Address2    = "";
            customer.Card.City        = "Lathlain";
            customer.Card.Postcode    = "6454";
            customer.Card.State       = "WA";
            customer.Card.Country     = "Australia";

            var respCustomer = ps.CustomerAdd(customer);

            System.Console.WriteLine("Customer token: " + respCustomer.Response.Token);

            // Get Customer
            System.Console.WriteLine($"Getting customer");
            var customers = ps.Customers();

            // Customers supports pagination
            System.Console.WriteLine($"Paginating customers");
            if (customers.Pagination.Pages > 1)
            {
                customers = ps.Customers(1);
            }

            // Update Customer
            System.Console.WriteLine($"Updating customer");
            customer = customers.Customer[0];

            customer.Card             = new Card();
            customer.Card.CardNumber  = "5520000000000000";
            customer.Card.ExpiryMonth = DateTime.Today.Month.ToString();
            customer.Card.ExpiryYear  = (DateTime.Today.Year + 2).ToString();
            customer.Card.CVC         = "123";
            customer.Card.Name        = "Roland Robot";
            customer.Card.Address1    = "42 Sevenoaks St";
            customer.Card.Address2    = "";
            customer.Card.City        = "Lathlain";
            customer.Card.Postcode    = "6454";
            customer.Card.State       = "WA";
            customer.Card.Country     = "Australia";

            customer.State = "NSW";
            var customerUpate = ps.CustomerUpate(customer);

            // Get a customer by token
            System.Console.WriteLine($"Getting customer by token");
            var current = ps.Customer(customerUpate.Customer.Token);

            var respCustomerCharge = ps.Charge(new PostCharge {
                IPAddress = "127.0.0.1", Amount = 1000, Description = "Charge by customer token: " + customer.Email, Email = customer.Email, CustomerToken = customer.Token
            });

            // Card Token
            // https://pin.net.au/docs/api/cards
            // 5520000000000000 - Test Mastercard
            // 4200000000000000 - Test Visa

            System.Console.WriteLine($"Creating card token");

            card             = new Card();
            card.CardNumber  = "5520000000000000";
            card.CVC         = "111";
            card.ExpiryMonth = DateTime.Today.Month.ToString();              // Use the real Expiry
            card.ExpiryYear  = (DateTime.Today.Year + 1).ToString();         // Not my defaults!
            card.Name        = "Roland Robot";
            card.Address1    = "42 Sevenoaks St";
            card.Address2    = "";
            card.City        = "Lathlain";
            card.Postcode    = "6454";
            card.State       = "WA";
            card.Country     = "Australia";

            var respCardCreate = ps.CardCreate(card);

            response = ps.Charge(new PostCharge {
                Amount = 1500, CardToken = respCardCreate.Response.Token, Currency = "AUD", Description = "Desc", Email = "*****@*****.**", IPAddress = "127.0.0.1"
            });
            System.Console.WriteLine(response.Charge.Success);

            // Card tokens can only be used once.
            // If you try and use it a second time, you will get the following message:
            response = ps.Charge(new PostCharge {
                Amount = 1500, CardToken = respCardCreate.Response.Token, Currency = "AUD", Description = "Desc", Email = "*****@*****.**", IPAddress = "127.0.0.1"
            });
            System.Console.WriteLine(response.Error);             // "token_already_used"
            System.Console.WriteLine(response.Description);       // "Token already used. Card tokens can only be used once, to create a charge or assign a card to a customer."
        }
Пример #11
0
        static void Main(string[] args)
        {
            System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            // initialise PIN by passing your API Key
            // See:  https://pin.net.au/docs/api#keys
            PinService ps = new PinService(ConfigurationManager.AppSettings["Secret_API"]);

            // https://pin.net.au/docs/api/test-cards
            // 5520000000000000 - Test Mastercard
            // 4200000000000000 - Test Visa

            var card = new Card();

            card.CardNumber  = "5520000000000000";
            card.CVC         = "111";
            card.ExpiryMonth = DateTime.Today.Month.ToString();      // Use the real Expiry
            card.ExpiryYear  = (DateTime.Today.Year + 1).ToString(); // Not my defaults!
            card.Name        = "Roland Robot";
            card.Address1    = "42 Sevenoaks St";
            card.Address2    = null;
            card.City        = "Lathlain";
            card.Postcode    = "6454";
            card.State       = "WA";
            card.Country     = "Australia";

            var response = ps.Charge(new PostCharge {
                Amount = 1500, Card = card, Currency = "AUD", Description = "Desc", Email = "*****@*****.**", IPAddress = "127.0.0.1"
            });

            System.Console.WriteLine(response.Charge.Success);


            // Refunds - Pin supports partial refunds
            // https://pin.net.au/docs/api/customers#get-customers-charges

            var refund = ps.Refund(response.Token, 200);

            refund = ps.Refund(response.Token, 100);

            var refunds = ps.Refunds(response.Token);

            // Searching for a Charge
            // See https://pin.net.au/docs/api/charges#search-charges for more detail

            var respChargesSearch = ps.ChargesSearch(new Actions.ChargeSearch {
                Query = "", Sort = ChargeSearchSortEnum.Amount, SortDirection = SortDirectionEnum.Descending
            });

            System.Console.WriteLine(respChargesSearch.Count.ToString() + " transactions found");
            foreach (var r in respChargesSearch.Response)
            {
                System.Console.WriteLine(r.Description + " " + r.Amount.ToString());
            }

            var respChargeSearch = ps.Charge(respChargesSearch.Response[0].Token);

            System.Console.WriteLine(respChargeSearch.Response.Description);

            // Create Customer
            // See: https://pin.net.au/docs/api/customers#post-customers

            var customer = new Customer();

            customer.Email            = "*****@*****.**";
            customer.Card             = new Card();
            customer.Card.CardNumber  = "5520000000000000";
            customer.Card.ExpiryMonth = "05";
            customer.Card.ExpiryYear  = "2024";
            customer.Card.CVC         = "123";
            customer.Card.Name        = "Roland Robot";
            customer.Card.Address1    = "42 Sevenoaks St";
            customer.Card.Address2    = "";
            customer.Card.City        = "Lathlain";
            customer.Card.Postcode    = "6454";
            customer.Card.State       = "WA";
            customer.Card.Country     = "Australia";

            var respCustomer = ps.CustomerAdd(customer);

            System.Console.WriteLine("Customer token: " + respCustomer.Response.Token);


            var plan = new Plan();

            plan.Name         = "Recurring Plan Name";
            plan.Amount       = 2795;
            plan.Currency     = "AUD";
            plan.Interval     = 1;
            plan.IntervalUnit = "month";

            var newPlan = ps.PlanAdd(plan);

            System.Console.WriteLine("Plan token: " + newPlan.Token);

            var subs = new Subscription();

            subs.PlanToken     = newPlan.Token;
            subs.CustomerToken = respCustomer.Response.Token;

            var newSubs = ps.SubscriptionAdd(subs);

            System.Console.WriteLine("Subscription token: " + newSubs.Token);

            // Get Customer
            var customers = ps.Customers();

            // Customers supports pagination
            if (customers.Pagination.Pages > 1)
            {
                customers = ps.Customers(1);
            }

            // Update Customer
            customer = customers.Customer[0];

            customer.Card             = new Card();
            customer.Card.CardNumber  = "5520000000000000";
            customer.Card.ExpiryMonth = "05";
            customer.Card.ExpiryYear  = "2014";
            customer.Card.CVC         = "123";
            customer.Card.Name        = "Roland Robot";
            customer.Card.Address1    = "42 Sevenoaks St";
            customer.Card.Address2    = "";
            customer.Card.City        = "Lathlain";
            customer.Card.Postcode    = "6454";
            customer.Card.State       = "WA";
            customer.Card.Country     = "Australia";

            customer.State = "NSW";
            var customerUpate = ps.CustomerUpate(customer);

            // Get a customer by token
            var current = ps.Customer(customerUpate.Customer.Token);

            var respCustomerCharge = ps.Charge(new PostCharge {
                IPAddress = "127.0.0.1", Amount = 1000, Description = "Charge by customer token: " + customer.Email, Email = customer.Email, CustomerToken = customer.Token
            });

            // Card Token
            // https://pin.net.au/docs/api/cards
            // 5520000000000000 - Test Mastercard
            // 4200000000000000 - Test Visa

            card        = new Card();
            card.APIKey = ""; // OPTIONAL.  Your publishable API key, if requesting from an insecure environment.
            // card.CardNumber = "5520000000000000";
            card.CVC         = "111";
            card.ExpiryMonth = DateTime.Today.Month.ToString();      // Use the real Expiry
            card.ExpiryYear  = (DateTime.Today.Year + 1).ToString(); // Not my defaults!
            card.Name        = "Roland Robot";
            card.Address1    = "42 Sevenoaks St";
            card.Address2    = "";
            card.City        = "Lathlain";
            card.Postcode    = "6454";
            card.State       = "WA";
            card.Country     = "Australia";

            var respCardCreate = ps.CardCreate(card);

            response = ps.Charge(new PostCharge {
                Amount = 1500, CardToken = card.Token, Currency = "AUD", Description = "Desc", Email = "*****@*****.**", IPAddress = "127.0.0.1"
            });
            System.Console.WriteLine(response.Charge.Success);

            // Card tokens can only be used once.
            // If you try and use it a second time, you will get the following message:
            response = ps.Charge(new PostCharge {
                Amount = 1500, CardToken = card.Token, Currency = "AUD", Description = "Desc", Email = "*****@*****.**", IPAddress = "127.0.0.1"
            });
            System.Console.WriteLine(response.Error);       // "token_already_used"
            System.Console.WriteLine(response.Description); // "Token already used. Card tokens can only be used once, to create a charge or assign a card to a customer."
        }
Пример #12
0
 public PeopleController(ZagsDbContext context, PinService pinService)
 {
     _context        = context;
     this.pinService = pinService;
 }
Пример #13
0
        static void Main(string[] args)
        {
            // initialise PIN by passing your API Key
            // See:  https://pin.net.au/docs/api#keys
            PinService ps = new PinService(ConfigurationManager.AppSettings["Secret_API"]);

            // https://pin.net.au/docs/api/test-cards
            // 5520000000000000 - Test Mastercard
            // 4200000000000000 - Test Visa

            var card = new Card();
            card.CardNumber = "5520000000000000";
            card.CVC = "111";
            card.ExpiryMonth = DateTime.Today.Month.ToString();  // Use the real Expiry
            card.ExpiryYear = (DateTime.Today.Year + 1).ToString(); // Not my defaults!
            card.Name = "Roland Robot";
            card.Address1 = "42 Sevenoaks St";
            card.Address2 = null;
            card.City = "Lathlain";
            card.Postcode = "6454";
            card.State = "WA";
            card.Country = "Australia";

            var response = ps.Charge(new PostCharge { Amount = 1500, Card = card, Currency = "AUD", Description = "Desc", Email = "*****@*****.**", IPAddress = "127.0.0.1" });
            System.Console.WriteLine(response.Charge.Success);

            // Refunds - Pin supports partial refunds
            // https://pin.net.au/docs/api/customers#get-customers-charges

            var refund = ps.Refund(response.Token, 200);
            refund = ps.Refund(response.Token, 100);

            var refunds = ps.Refunds(response.Token);

            // Searching for a Charge
            // See https://pin.net.au/docs/api/charges#search-charges for more detail

            var respChargesSearch = ps.ChargesSearch(new Actions.ChargeSearch { Query = "", Sort = ChargeSearchSortEnum.Amount, SortDirection = SortDirectionEnum.Descending });
            System.Console.WriteLine(respChargesSearch.Count.ToString() + " transactions found");
            foreach (var r in respChargesSearch.Response)
            {
                System.Console.WriteLine(r.Description + " " + r.Amount.ToString());
            }

            var respChargeSearch = ps.Charge(respChargesSearch.Response[0].Token);
            System.Console.WriteLine(respChargeSearch.Response.Description);

            // Create Customer
            // See: https://pin.net.au/docs/api/customers#post-customers

            var customer = new Customer();
            customer.Email = "*****@*****.**";
            customer.Card = new Card();
            customer.Card.CardNumber = "5520000000000000";
            customer.Card.ExpiryMonth = "05";
            customer.Card.ExpiryYear = "2014";
            customer.Card.CVC = "123";
            customer.Card.Name = "Roland Robot";
            customer.Card.Address1 = "42 Sevenoaks St";
            customer.Card.Address2 = "";
            customer.Card.City = "Lathlain";
            customer.Card.Postcode = "6454";
            customer.Card.State = "WA";
            customer.Card.Country = "Australia";

            var respCustomer = ps.CustomerAdd(customer);
            System.Console.WriteLine("Customer token: " + respCustomer.Response.Token);

            // Get Customer
            var customers = ps.Customers();

            // Customers supports pagination
            if (customers.Pagination.Pages > 1)
            {
                customers = ps.Customers(1);
            }

            // Update Customer
            customer = customers.Customer[0];

            customer.Card = new Card();
            customer.Card.CardNumber = "5520000000000000";
            customer.Card.ExpiryMonth = "05";
            customer.Card.ExpiryYear = "2014";
            customer.Card.CVC = "123";
            customer.Card.Name = "Roland Robot";
            customer.Card.Address1 = "42 Sevenoaks St";
            customer.Card.Address2 = "";
            customer.Card.City = "Lathlain";
            customer.Card.Postcode = "6454";
            customer.Card.State = "WA";
            customer.Card.Country = "Australia";

            customer.State = "NSW";
            var customerUpate = ps.CustomerUpate(customer);

            // Get a customer by token
            var current = ps.Customer(customerUpate.Customer.Token);

            var respCustomerCharge = ps.Charge(new PostCharge { IPAddress = "127.0.0.1", Amount = 1000, Description = "Charge by customer token: " + customer.Email, Email = customer.Email, CustomerToken = customer.Token });

            // Card Token
            // https://pin.net.au/docs/api/cards
            // 5520000000000000 - Test Mastercard
            // 4200000000000000 - Test Visa

            card = new Card();
            card.APIKey = ""; // OPTIONAL.  Your publishable API key, if requesting from an insecure environment.
            // card.CardNumber = "5520000000000000";
            card.CVC = "111";
            card.ExpiryMonth = DateTime.Today.Month.ToString();  // Use the real Expiry
            card.ExpiryYear = (DateTime.Today.Year + 1).ToString(); // Not my defaults!
            card.Name = "Roland Robot";
            card.Address1 = "42 Sevenoaks St";
            card.Address2 = "";
            card.City = "Lathlain";
            card.Postcode = "6454";
            card.State = "WA";
            card.Country = "Australia";

            var respCardCreate = ps.CardCreate(card);

            response = ps.Charge(new PostCharge { Amount = 1500, CardToken = card.Token, Currency = "AUD", Description = "Desc", Email = "*****@*****.**", IPAddress = "127.0.0.1" });
            System.Console.WriteLine(response.Charge.Success);

            // Card tokens can only be used once.
            // If you try and use it a second time, you will get the following message:
            response = ps.Charge(new PostCharge { Amount = 1500, CardToken = card.Token, Currency = "AUD", Description = "Desc", Email = "*****@*****.**", IPAddress = "127.0.0.1" });
            System.Console.WriteLine(response.Error); // "token_already_used"
            System.Console.WriteLine(response.Description); // "Token already used. Card tokens can only be used once, to create a charge or assign a card to a customer."
        }
Пример #14
0
 public BoardController(BoardService boardService, PinService pinService)
 {
     _boardService = boardService;
     _pinService   = pinService;
 }
Пример #15
0
 public async Task EstadoBotao(bool ligado)
 {
     PinService.EstadoLed(ligado);
     await Task.FromResult(0);
 }
Пример #16
0
 public PinCommands(PinService pins)
 {
     this.pins = pins;
 }