Beispiel #1
0
        public ActionResult Index()
        {
            var api = XeroApiHelper.CoreApi();

            //var api1 = XeroApiHelper.User();

            try
            {
                var organisation = api.Organisation;


                //var updated_emp = api.Update(new Employee
                //{
                //    Id = emp.Id,
                //    Status = Xero.Api.Payroll.Australia.Model.Status.EmploymentStatus.Terminated,
                //    TerminationDate = DateTime.Now.AddDays(-1)

                //});



                return(View(organisation));
            }
            catch (RenewTokenException e)
            {
                return(RedirectToAction("Connect", "Home"));
            }
        }
Beispiel #2
0
        /// <summary>
        ///     Get the organisation
        /// </summary>
        /// <returns></returns>
        public static Organisation GetOrganisation()
        {
            try {
                var organisation = XeroApiHelper.CoreApi()?
                                   .Organisation;

                return(organisation);
            }
            catch (Exception)
            {
                throw new RenewTokenException();
            }
        }
Beispiel #3
0
        public ActionResult Index()
        {
            var api = XeroApiHelper.CoreApi();

            try
            {
                var organisation = api.Organisation;

                return(View(organisation));
            }
            catch (RenewTokenException e)
            {
                return(RedirectToAction("Connect", "Home"));
            }
        }
Beispiel #4
0
        public async Task <ActionResult <Organisation> > Check()
        {
            var api = XeroApiHelper.CoreApi();

            try
            {
                var organisation = await api.FindOrganisationAsync();

                return(organisation);
            }
            catch (NotSupportedException e)
            {
                return(BadRequest(e));
            }
        }
Beispiel #5
0
        /// <summary>
        ///     Get all vendors
        /// </summary>
        /// <returns></returns>
        public static IEnumerable <Contact> GetAllVendors()
        {
            try
            {
                var contacts = XeroApiHelper.CoreApi()?
                               .Contacts
                               .Find()
                               .ToList();

                return(contacts);
            }
            catch (Exception)
            {
                throw new RenewTokenException();
            }
        }
Beispiel #6
0
        /// <summary>
        ///     Get all accounts
        /// </summary>
        /// <returns></returns>
        public static IEnumerable <Account> GetAllAccounts()
        {
            try
            {
                var accounts = XeroApiHelper.CoreApi()
                               .Accounts
                               .Find()
                               .ToList();

                return(accounts);
            }
            catch (Exception)
            {
                throw new RenewTokenException();
            }
        }
        public ActionResult Index()
        {
            var api = XeroApiHelper.CoreApi();

            try
            {
                var organisation = api.FindOrganisationAsync().Result;

                return(View(organisation));
            }
            catch (RenewTokenException e)
            {
                Console.WriteLine(e);
                return(RedirectToAction("Connect", "Home"));
            }
        }
        // GET: Invoice
        public ActionResult Index()
        {
            var api = XeroApiHelper.CoreApi();

            try
            {
                var invoicesList       = api.Invoices.FindAsync().Result;
                var activeinvoicesList = invoicesList.Where(x => x.Status != InvoiceStatus.Deleted);

                return(View(activeinvoicesList));
            }
            catch (RenewTokenException e)
            {
                Console.WriteLine(e);
                return(RedirectToAction("Connect", "Home"));
            }
        }
        public ActionResult Create(Invoice invoice)
        {
            var api        = XeroApiHelper.CoreApi();
            var newInvoice = new Invoice
            {
                Contact = new Contact {
                    Name = invoice.Contact.Name, Id = new Guid()
                },
                Type            = InvoiceType.AccountsReceivable,
                Date            = DateTime.UtcNow,
                DueDate         = DateTime.UtcNow.AddDays(90),
                LineAmountTypes = LineAmountType.Exclusive,
                LineItems       = new List <LineItem>
                {
                    new LineItem
                    {
                        Description  = "Consulting services as agreed (20% off standard rate)",
                        AccountCode  = "200",
                        UnitAmount   = invoice.LineItems[0].UnitAmount,
                        Quantity     = invoice.LineItems[0].Quantity,
                        DiscountRate = invoice.LineItems[0].DiscountRate
                    }
                }
            };

            try
            {
                var CreatedAccpayInvoice = api.Invoices.CreateAsync(newInvoice);
                AddApiAuditLog(newInvoice);
                return(RedirectToAction("Index", "Invoice"));
            }
            catch (RenewTokenException e)
            {
                Console.WriteLine(e);
                return(RedirectToAction("Connect", "Home"));
            }
        }
Beispiel #10
0
        public HomeController(IOptions <XeroApiSettings> settings)
        {
            _user = XeroApiHelper.User();

            _authenticator = XeroApiHelper.MvcAuthenticator(settings.Value);
        }
Beispiel #11
0
        public HomeController()
        {
            _user = XeroApiHelper.User();

            _authenticator = XeroApiHelper.MvcAuthenticator();
        }
Beispiel #12
0
 public HomeController()
 {
     //xeroClient = new XeroClient();
     _user          = XeroApiHelper.User();
     _authenticator = XeroApiHelper.MvcAuthenticator();
 }
Beispiel #13
0
 public HomeSettingController(IOptions <ApplicationSettings> applicationSettings)
 {
     _user = XeroApiHelper.User();
     _applicationSettings = applicationSettings.Value;
     _authenticator       = XeroApiHelper.MvcAuthenticator(_applicationSettings);
 }