Ejemplo n.º 1
0
        public async Task <IHttpActionResult> CreateNewAccountAsync(AccountInfo accountInfo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            await sf.SFLoginAsync();

            var recordType = "Account";

            var recordFields = new JObject();

            recordFields.Add("Name", accountInfo.AccountName);
            recordFields.Add("OwnerId", accountInfo.AccountOwnerId);
            recordFields.Add("Email__c", accountInfo.Email);
            recordFields.Add("BillingStreet", accountInfo.BillingStreet);
            recordFields.Add("BillingCity", accountInfo.BillingCity);
            recordFields.Add("BillingState", accountInfo.BillingState);
            recordFields.Add("BillingPostalCode", accountInfo.BillingZip);
            recordFields.Add("BillingCountry", accountInfo.BillingCountry);
            recordFields.Add("Phone", accountInfo.Phone);

            var record = await sf.CreateRecordAsync(recordFields, recordType);

            return(Created(new Uri(Request.RequestUri + "/"), record));
        }
Ejemplo n.º 2
0
        public async Task <IHttpActionResult> CreateNewDonationAsync(DonationInfo donationInfo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            await sf.SFLoginAsync();

            var recordType = "Donation__c";

            var recordFields = new JObject();


            recordFields.Add("Name", donationInfo.DonationName);
            recordFields.Add("Amount__c", donationInfo.Amount);
            recordFields.Add("Account_Name__c", donationInfo.AccountId);
            recordFields.Add("Donation_Date__c", donationInfo.DonationDate);

            var user = await sf.CreateRecordAsync(recordFields, recordType);

            return(Created(new Uri(Request.RequestUri + "/"), user));
        }