Пример #1
0
        public async Task <IActionResult> Contact(Models.ContactUsModel model)
        {
            var authClient = await _repository.GetAuthorizedVantagePointClientAsync();

            //set up the query string to post contacts:
            string requestUri = $"contact";

            //this only works because the model and the contact class in VantagePoint
            //share the same names!
            var result = await _repository.PostAsync(authClient, requestUri, model);

            return(RedirectToAction("ThankYou", model));
        }
Пример #2
0
        public async Task <ActionResult> Index(Models.ExportViewModel model)
        {
            if (string.IsNullOrEmpty(model?.ExportDefinitionName))
            {
                //return error
            }

            var authClient = await _repository.GetAuthorizedVantagePointClientAsync();

            string requestUri = $"exportutility/exportdefinitions/{model.ExportDefinitionName}";

            var contacts = await _repository.GetAsync(authClient, requestUri);

            var mailchimpmembersTyped = await _repository.GetAsync <List <Models.MailChimpMemberModel> >(authClient, requestUri);

            //remove contacts without email
            mailchimpmembersTyped.RemoveAll(x => string.IsNullOrEmpty(x.EMailAddress));

            model.Contacts = mailchimpmembersTyped;

            return(View(model));
        }
Пример #3
0
        public async Task <ActionResult> Index(Models.InvoiceViewModel model)
        {
            var authClient = await _repository.GetAuthorizedVantagePointClientAsync();

            string requestUri = $"utilities/invokecustom/getinvoiceinfo";
            Dictionary <string, object> spParams = new Dictionary <string, object>();

            spParams.Add("Invoice", model.RequestInvoice);

            //returns a structure in xml
            string invoiceInfo = await _repository.PostAsync <string>(authClient, requestUri, spParams);

            //turn structure into json
            var retvalJson = Helpers.XMLHelpers.StoredProcXMLToJObject(invoiceInfo);

            //turn structure into dicts
            var retvalDict = Helpers.XMLHelpers.StoredProcXMLToDictionary(invoiceInfo);

            //populating the model the hard way
            //with this code you have to know exactly what the stored procedure returns...
            model.Invoice     = retvalDict["Table"][0]["Invoice"].ToString();
            model.MainWBS1    = retvalDict["Table"][0]["MainWBS1"].ToString();
            model.InvoiceDate = DateTime.Parse(retvalDict["Table"][0]["InvoiceDate"].ToString());
            model.MainName    = retvalDict["Table"][0]["MainName"].ToString();
            model.Description = retvalDict["Table"][0]["Description"].ToString();
            model.ProjectName = retvalDict["Table"][0]["ProjectName"].ToString();
            model.ClientName  = retvalDict["Table"][0]["ClientName"].ToString();

            foreach (var item in retvalDict["Table1"])
            {
                Models.InvoiceSectionViewModel section = new Models.InvoiceSectionViewModel();
                section.Section     = item["section"].ToString();
                section.BaseAmount  = Decimal.Parse(item["BaseAmount"].ToString());
                section.FinalAmount = Decimal.Parse(item["FinalAmount"].ToString());
                model.Sections.Add(section);
            }

            model.TotalInvoiceAmount = model.Sections.Sum(x => x.FinalAmount);

            return(View(model));
        }
Пример #4
0
        public async Task <ActionResult> TopTen()
        {
            var authClient = await _repository.GetAuthorizedVantagePointClientAsync();

            //set up the query string to return projects:
            string requestUri = $"project?limit=10";

            //only display top level projects
            requestUri += $"&wbstype=wbs1";
            //add a fieldFilter to the query string so the API only returns fields that are needed
            requestUri += $"&{RESTHelper.GetFieldFilterParamString(new string[] {"WBS1", "Name", "LongName" })}";
            //add a search to it
            List <Helpers.FilterHash> searchItems = new List <FilterHash>()
            {
                new Helpers.FilterHash()
                {
                    name      = "ChargeType", value = "R",
                    tablename = "PR", opp = "=", searchlevel = 1
                },                                               //regular projects only
                new Helpers.FilterHash()
                {
                    name      = "ProjectType", value = "07",
                    tablename = "PR", opp = "=", searchlevel = 1
                }                                              //only items with project type 07
            };

            requestUri += RESTHelper.GetSearchFilterParamString(searchItems);

            //call with dynamic type (returns JObject)
            var TopTenList = await _repository.GetAsync(authClient, requestUri);

            //if you build a model that matches the expected result then it can be cast automatically
            var TopTenListTyped = await _repository.GetAsync <List <Models.ProjectViewModel> >(authClient, requestUri);

            return(View(TopTenListTyped));
        }