public async Task <HttpResponseMessage> GetLeadByID(int ID) { try { EnquiryDAL dal = new EnquiryDAL(); LeadInfo data = await dal.GetLeadByID(ID); if (data != null) { return(Request.CreateResponse <LeadInfo>(HttpStatusCode.OK, data)); } else { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, Constants.ErrorNotFound)); } } catch (DbEntityValidationException ex) { var controllerName = ControllerContext.RouteData.Values["controller"].ToString(); var actionName = ControllerContext.RouteData.Values["action"].ToString(); Logger log = new Logger(); log.ErrorLog(ex, controllerName, actionName); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, Constants.ErrorSysError)); } }
// PUT api/leads/{$prospectId}/ // FEATURE: Modificar lead existente public HttpResponseMessage Put(string id, [FromBody] LeadInfo jsonObject) { if (Authentication.VerifyToken("?")) { try { if (LeadIntegration.Update(Authentication.GetRepresentative(null), HttpUtility.UrlDecode(id), jsonObject)) { return(Request.CreateResponse(HttpStatusCode.OK)); } else { return(Request.CreateResponse(HttpStatusCode.NotFound)); } } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message)); } } else { return(Request.CreateResponse(HttpStatusCode.Forbidden)); } }
// POST api/leads/ // FEATURE: Adicionar lead public HttpResponseMessage Post([FromBody] LeadInfo jsonObject) { if (Authentication.VerifyToken("?")) { try { var operationResult = LeadIntegration.Insert(Authentication.GetRepresentative(null), jsonObject); if (operationResult == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } else { return(Request.CreateResponse(HttpStatusCode.OK, operationResult)); } } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message)); } } else { return(Request.CreateResponse(HttpStatusCode.Forbidden)); } }
static void Main(string[] args) { FenixMobilService.MobilServiceClient client = new FenixMobilService.MobilServiceClient(); string json = client.GetCustomer(1, 40, CustomerType.Contact); string json2 = client.GetMobilAppCustomer(); Console.ReadLine(); MobilService client2 = new MobilService(); GetProject(client2); string emailContact = "*****@*****.**"; CustomerDetailResult customerDetailReturn = Login(client2, emailContact); CustomerDetailResult customerDetailReturn2 = Login(client2, "*****@*****.**"); string customerId = customerDetailReturn.Customer.CustomerId; string customerId2 = customerDetailReturn2.Customer.CustomerId; CustomerType customerType = customerDetailReturn.Customer.CustomerType.Value; CustomerType customerType2 = customerDetailReturn2.Customer.CustomerType.Value; string returnValue = client2.GetFoldhome(customerId); PaymentResult paymentReturn2 = GetPaymentList(client2, customerId2, customerType2); PaymentResult paymentReturn = GetPaymentList(client2, customerId, customerType); MsCrmResult foldhomeCreateReturn = CreateFoldhome(client2, customerDetailReturn, customerId, customerType); string foldhomeId = foldhomeCreateReturn.Message; MsCrmResult foldhomeUpdateReturn = UpdateFoldhome(client2, customerDetailReturn, customerId, customerType, foldhomeId); MsCrmResult foldhomeUpdate2Return = UpdateFoldhome(client2, customerDetailReturn, customerId, customerType, foldhomeId); MsCrmResult foldhomeCancelReturn = CancelFoldhome(client2, customerDetailReturn, customerId, customerType, foldhomeId); LeadInfo lead = new LeadInfo(); lead.Customer = new CustomerInfo(); lead.Customer.Email = "*****@*****.**"; lead.Customer.Name = "Cihan"; lead.Customer.Surname = "Hancı"; lead.Customer.Phone = "+90-531-9657717"; client2.CreateLead(lead); WebCustomerInfo webInfo = new WebCustomerInfo(); webInfo.Customer = new CustomerInfo(); webInfo.CustomerInvestmentRange = new InvestmentRange(); webInfo.Quote = new Quote(); webInfo.Customer.CustomerId = customerId2; webInfo.Customer.Email = customerDetailReturn2.Customer.Email; webInfo.Customer.CustomerType = CustomerType.Contact; webInfo.CustomerInvestmentRange = InvestmentRange.optionTwo; webInfo.Quote.ProductId = customerDetailReturn.QuoteList[0].ProductId; webInfo.Quote.ProductName = customerDetailReturn.QuoteList[0].ProductName; webInfo.Quote.ProjectCode = customerDetailReturn.QuoteList[0].ProjectCode; webInfo.Quote.ProjectName = customerDetailReturn.QuoteList[0].ProjectName; client2.CreateWebForm(webInfo); }
public static void Update_LeadInfo(LeadInfo infoObj) //Don't mix CamelCase and _ Case Notation { using (MySqlConnection cn = new MySqlConnection(ConString)) { MySqlCommand cmd = new MySqlCommand(); cmd.Connection = cn; cmd.CommandText = "UPDATE Leads SET CVR = ('" + infoObj.CVR + "'), Firma = ('" + infoObj.Firma + "'), Nummer = ('" + infoObj.Nummer + "'), Addresse = ('" + infoObjAddresse + "'), Postnr = ('" + infoObj.Postnr + "'), Bynavn = ('" + infoObj.By + "'), Noter = ('" + infoObj.Noter + "'), Afholdt = ('" + infoObj.Afholdt + "'), Email = ('" + infoObj.Email + "'), Slut_Dato = ('" + infoObj.SlutDato + "') WHERE UniqueID = ('" + infoObj.UniqueID + "');"; cmd.ExecuteNonQuery(); cmd.Dispose(); cn.Close(); } }
// // GET: /SalesLead/ public async Task <ActionResult> Index() { LeadContactViewModel vm = new LeadContactViewModel(); var client = await GetExchangeClient(); var messageResults = await(from i in client.Me.Inbox.Messages where i.Subject.Contains("[SKU:") orderby i.DateTimeSent descending select i).ExecuteAsync(); foreach (var message in messageResults.CurrentPage) { LeadInfo newContact = new LeadInfo(); newContact.ID = message.Id; newContact.email = message.From.Address; newContact.message = message.BodyPreview; newContact.dateReceived = message.DateTimeReceived.Value.DateTime; //look up product from SKU var beginPos = message.Subject.IndexOf("[", 0) + 1; var endPos = message.Subject.IndexOf("]", beginPos); string skuLine = message.Subject.Substring(beginPos, endPos - beginPos); List <Product> products = await GetProducts(); var product = products.Where(p => p.Title.Contains(skuLine.Split(':')[1])).SingleOrDefault(); newContact.productRequest = product.Title; vm.leads.Add(newContact); } //get the sales staff from outlook var contactsResults = await(from i in client.Me.Contacts orderby i.DisplayName select i).ExecuteAsync(); foreach (var contact in contactsResults.CurrentPage) { SalesPerson person = new SalesPerson(); person.ID = contact.Id; person.name = contact.DisplayName; person.email = contact.EmailAddress1; vm.salesStaff.Add(person); } return(View(vm)); }
//[HttpGet] //public ReturnInfo SubmitLeadInfo() public ReturnInfo SubmitLeadInfo(LeadInfo mLeadInfo) { ReturnInfo mRetInfo = new ReturnInfo() { }; leadFunction.CreateServiceConnection(); if (leadFunction.ValidateLeadContact(mLeadInfo, ref mRetInfo)) { leadFunction.ProcessLeadInfo(mLeadInfo, ref mRetInfo); } return(mRetInfo); }
/// <summary> /// Initialvalidation for contact number of lead /// </summary> internal Boolean ValidateLeadContact(LeadInfo leadInfo, ref ReturnInfo mRetInfo) { try { if (string.IsNullOrEmpty(leadInfo.EmployerCode) && string.IsNullOrEmpty(leadInfo.EmployerName)) { mRetInfo.ErrorMessage = LeadConstants.NoEmpCode; return(false); } else if (leadInfo.MobilePreferredContact && (string.IsNullOrEmpty(leadInfo.MobilePhone))) { mRetInfo.ErrorMessage = LeadConstants.NoMobileNumber; return(false); } else if (!leadInfo.MobilePreferredContact && (string.IsNullOrEmpty(leadInfo.OtherPhone))) { mRetInfo.ErrorMessage = LeadConstants.NoOtherPhoneNumber; return(false); } } catch (Exception ex) { mRetInfo.ErrorMessage = ex.Message; } return(true); }
internal void ProcessLeadInfo(LeadInfo leadInfo, ref ReturnInfo mRetInfo) { string leadid = string.Empty; string leadStatus = string.Empty; string leadSource = string.Empty; DateTime createdOn = DateTime.Now; DateTime modifiedOn = DateTime.Now; DateTime reactivateOn = DateTime.Now; //Need to get from dynamic entity Dictionary <string, string> attributes = new Dictionary <string, string>(); try { attributes.Add(LeadConstants.AttrEmail, leadInfo.Email); DynamicEntity de = LeadDAL.SelectLead(service, attributes); if (de == null) { attributes.Clear(); attributes.Add(LeadConstants.AttrMobile, leadInfo.MobilePhone); attributes.Add(LeadConstants.AttrFirstName, leadInfo.Firstname); de = LeadDAL.SelectLead(service, attributes); if (de == null) { //Create New Lead and exit //to write //RC 1 mRetInfo.ReturnCode = 1; return; } } //Get the existing lead status foreach (Property p in de.Properties) { if (p.Name == LeadConstants.AttrLeadID) { leadid = CrmHelper.GetSourceValue(p.GetType().Name, p); } if (p.Name == LeadConstants.AttrLeadStatus) { leadStatus = CrmHelper.GetSourceValue(p.GetType().Name, p); } else if (p.Name == LeadConstants.AttrLeadSource) { leadSource = CrmHelper.GetSourceValue(p.GetType().Name, p); } else if (p.Name == LeadConstants.AttrCreatedOn) { createdOn = Convert.ToDateTime(CrmHelper.GetSourceValue(p.GetType().Name, p)); } else if (p.Name == LeadConstants.AttrModifiedOn) { modifiedOn = Convert.ToDateTime(CrmHelper.GetSourceValue(p.GetType().Name, p)); } //else if (p.Name == LeadConstants.AttrReactivateOn) //{ // reactivateOn = Convert.ToDateTime(CrmHelper.GetSourceValue(p.GetType().Name, p)); //} } Guid _leadid = new Guid(leadid); mRetInfo.LeadID = _leadid.ToString(); //UpdateOnly = False if (!leadInfo.UpdateOnly) { if (leadStatus.ToLower() == LeadConstants.StatusOpen) { if (leadSource == LeadConstants.AdminUpload) { //Send Email //need info //RC 3 mRetInfo.ReturnCode = 3; } else { //RC 2 mRetInfo.ReturnCode = 2; } //Create a Note <LeadDetails> LeadDAL.AddNoteToLead(service, _leadid, leadInfo.LeadDetails); } else { //Reactivate Lead and update info. LeadDAL.ReactivateLead(service, metaDataService, leadInfo, _leadid, de); LeadDAL.AddNoteToLead(service, _leadid, leadInfo.LeadDetails); //RC 4 mRetInfo.ReturnCode = 4; } } else { if (leadStatus.ToLower() == LeadConstants.StatusOpen) { if ((createdOn == leadInfo.CreateOn) || (reactivateOn == leadInfo.CreateOn)) { //update refferal name, lead source, enquiry source, campaign source //RC 5 mRetInfo.ReturnCode = 5; } else { //RC 7 mRetInfo.ReturnCode = 7; } //Create a Note <LeadDetails> LeadDAL.AddNoteToLead(service, _leadid, leadInfo.LeadDetails); } else { if (modifiedOn == leadInfo.CreateOn) { //RC 6 mRetInfo.ReturnCode = 6; } else { //RC 8 mRetInfo.ReturnCode = 8; } } } } catch (Exception ex) { mRetInfo.ErrorMessage = ex.Message; } }
//public static void CreateLead(CrmService service, LeadInfo leadDetails, Guid leadID, DynamicEntity crmLeadInfo) //{ // string firstName = string.Empty; // string lastName = string.Empty; // try // { // var lead = new lead(); // foreach (Property p in crmLeadInfo.Properties) // { // if (p.Name == "firstname") // { // firstName = CrmHelper.GetSourceValue(p.GetType().Name, p); // } // if (p.Name == "lastname") // { // lastName = CrmHelper.GetSourceValue(p.GetType().Name, p); // } // } // if (leadDetails.LeadOriginatorName == string.Concat(firstName, " ", lastName)) // { // //lead.ms_bdm= matched CRM user // lead.ms_staffreferrer = null; // lead.ms_referralname = null; // } // else // { // lead.ms_bdm = null; // lead.ms_staffreferrer = null; // lead.ms_referralname = leadDetails.LeadOriginatorName; // } // var crmBrand = new Picklist(); // if (leadDetails.Brand.ToLower() == "maxxia") // { // crmBrand.Value = 0; // } // else { crmBrand.Value = 1; } // lead.ms_brand = crmBrand; // //var crmProductType = new Picklist(); // //crmProductType.Value = Convert.ToInt32("Fully Maintained Novated Lease"); // //lead.ms_producttype = crmProductType; // //var crmOwnLead = new Picklist(); // //crmOwnLead.Value = Convert.ToInt32("No"); // //lead.ms_willyouownthelead = crmOwnLead; // //var crmRating = new Picklist(); // //if (string.IsNullOrEmpty(leadDetails.LeadRating)) // //{ // // crmRating.Value = Convert.ToInt32("Warm"); // //} // //else // //{ // // crmRating.Value = Convert.ToInt32(leadDetails.LeadRating); // //} // //lead.leadqualitycode = crmRating; // //var crmLeadSource = new Picklist(); // //crmLeadSource.Value = Convert.ToInt32(leadDetails.LeadSource); // //lead.leadsourcecode = crmLeadSource; // //var crmEnquirySource = new Picklist(); // //crmEnquirySource.Value = Convert.ToInt32(leadDetails.ActivityType); // //lead.ms_enquirysource = crmEnquirySource; // //var crmCampaignSource = new Picklist(); // //if (string.IsNullOrEmpty(leadDetails.CampaignSource )) // //{ // // crmCampaignSource.Value = Convert.ToInt32("None"); // //} // //else // //{ // // crmCampaignSource.Value = Convert.ToInt32(leadDetails.CampaignSource); // //} // //lead.ms_campaignsource = crmCampaignSource; // //if (!string.IsNullOrEmpty(leadDetails.VehicleType)) // //{ // // var crmVehicleType = new Picklist(); // // if (leadDetails.VehicleType == "New Car") // // { // // crmVehicleType.Value = Convert.ToInt32("New"); // // } // // else if(leadDetails.VehicleType == "Used Car") // // { // // crmVehicleType.Value = Convert.ToInt32("Used(Dealer)"); // // } // // else if(leadDetails.VehicleType == "Refinance Existing") // // { // // crmVehicleType.Value = Convert.ToInt32("Sales & Leaseback"); // // } // // lead.ms_vehicletype = crmVehicleType; // //} // //if (!string.IsNullOrEmpty(leadDetails.EmployerCode)) // //{ // //var emp = new account { accountnumber = leadDetails.EmployerCode }; // // var crmEmployer = new Lookup(); // // if (emp.accountid != null) // // { // // //crmEmployer.Value = emp; // // } // // else // // { // // emp = new account { name = leadDetails.EmployerName }; // // if (emp.accountid != null) // // { // // // crmEmployer.Value = emp; // // } // // else // // { // // // crmEmployer.Value = TestEmployer; // // //lead.TemPMessage; // // } // // } // // lead.ms_employer = crmEmployer; // // lead.ms_salarypackager = emp.ms_salarypackager1; // //} // //var crmState = new Picklist(); // //crmState.Value = Convert.ToInt32(leadDetails.State); // //lead.ms_homeaddressstate = crmState; // lead.firstname = leadDetails.Firstname; // lead.lastname = leadDetails.Surname; // lead.emailaddress2 = leadDetails.Email; // lead.mobilephone = leadDetails.MobilePhone; // //var crmPrefferedPhone = new Picklist(); // //if (leadDetails.MobilePreferredContact) // //{ // // crmPrefferedPhone.Value = Convert.ToInt32("Mobile"); // //} // //else // //{ // // crmPrefferedPhone.Value = Convert.ToInt32("Work"); // //} // //lead.ms_preferredphone = crmPrefferedPhone; // if (!string.IsNullOrEmpty(leadDetails.OtherPhone)) lead.telephone1 = leadDetails.OtherPhone; // lead.ms_preferredcontacttime = leadDetails.PreferredCallBackTime; // var crmAnnualGS = new CrmDecimal(); // if (leadDetails.AnnualGrossSalary.ToString() != "") // { // crmAnnualGS.Value = leadDetails.AnnualGrossSalary; // var crmRefferalSplit = new CrmDecimal(); // if (leadDetails.AnnualGrossSalary < 110000) // { // crmRefferalSplit.Value = (decimal)999.00; // } // else // { // //crmRefferalSplit.Value = null; // } // lead.ms_referralsplit = crmRefferalSplit; // } // else // { // crmAnnualGS.Value = 0; // } // lead.ms_annualgrosssalary = crmAnnualGS; // //lead.siteid // lead.ms_salesmessages = "Year: " + leadDetails.VehicleYear + "/ Make: " + leadDetails.VehicleMake + "/ Model: " + leadDetails.VehicleType + "\r\n" + "Lease Term: " + leadDetails.LeaseTerm + "\r\n * **\r\n" + leadDetails.OtherInformation; // //var emp = new account { ownerid = new Owner { Value = "" }; }; // //lead.ownerid= // var oppKey = new WebReferences.CrmSdk.Key { Value = leadID }; // lead.leadid = oppKey; // service.Update(lead); // } // catch (Exception ex) // { // throw ex; // } //} public static void ReactivateLead(CrmService service, MetadataService metaDataService, LeadInfo leadDetails, Guid leadID, DynamicEntity crmLeadInfo) { string firstName = string.Empty; string lastName = string.Empty; try { var lead = new lead(); foreach (Property p in crmLeadInfo.Properties) { if (p.Name == "firstname") { firstName = CrmHelper.GetSourceValue(p.GetType().Name, p); } if (p.Name == "lastname") { lastName = CrmHelper.GetSourceValue(p.GetType().Name, p); } } if (leadDetails.LeadOriginatorName == string.Concat(firstName, " ", lastName)) { //lead.ms_bdm= matched CRM user lead.ms_staffreferrer = null; lead.ms_referralname = null; } else { lead.ms_bdm = null; lead.ms_staffreferrer = null; lead.ms_referralname = leadDetails.LeadOriginatorName; } //var crmBrand = new Picklist(); //if (leadDetails.Brand.ToLower() == DALConstants.BrandM) //{ // crmBrand.Value = Convert.ToInt32(DALConstants.Brand.Maxxia) ; //} //else { crmBrand.Value = Convert.ToInt32(DALConstants.Brand.Remserv); } //lead.ms_brand = crmBrand; //var crmProductType = new Picklist //{ // name = "ms_producttype", // Value = CrmHelper.GetPickListCode(metaDataService, "ms_producttype", "ms_producttype", DALConstants.ProductTypeFMNL) //}; //lead.ms_producttype = crmProductType; //var crmOwnLead = new Picklist(); //crmOwnLead.Value = Convert.ToInt32(DALConstants.OwnTheLead.No); //lead.ms_willyouownthelead = crmOwnLead; //var crmRating = new Picklist(); //if (string.IsNullOrEmpty(leadDetails.LeadRating)) //{ // crmRating.Value = Convert.ToInt32("Warm"); //} //else //{ // crmRating.Value = Convert.ToInt32(leadDetails.LeadRating); //} //lead.leadqualitycode = crmRating; //var crmLeadSource = new Picklist //{ // name = "ms_leadsourcename", // Value = CrmHelper.GetPickListCode(metaDataService, "ms_leadsource", "ms_leadsourcename", leadDetails.LeadSource) //}; //lead.leadsourcecode = crmLeadSource; //leadsourceid required //var crmEnquirySource = new Picklist //{ // name = "ms_enquirysourcename", // Value = CrmHelper.GetPickListCode(metaDataService, "ms_enquirysource", "ms_enquirysourcename", leadDetails.ActivityType ) //}; //lead.ms_enquirysource = crmEnquirySource; //string csName = string.Empty; //if (string.IsNullOrEmpty(leadDetails.CampaignSource)) //{ // csName = "None"; //} //else //{ // csName = leadDetails.CampaignSource; //} //var crmCampaignSource = new Picklist //{ // name = "ms_campaignsourcename", // Value = CrmHelper.GetPickListCode(metaDataService, "ms_campaignsource", "ms_campaignsourcename", csName) //}; //lead.ms_campaignsource = crmCampaignSource; //string vehicleType = string.Empty; //if (!string.IsNullOrEmpty(leadDetails.VehicleType)) //{ // if (leadDetails.VehicleType == "New Car") // { // vehicleType="New"; // } // else if (leadDetails.VehicleType == "Used Car") // { // vehicleType="Used(Dealer)"; // } // else if (leadDetails.VehicleType == "Refinance Existing") // { // vehicleType="Sales & Leaseback"; // } // var crmVehicleType = new Picklist() // { // name = "ms_vehicletype1", // Value = CrmHelper.GetPickListCode(metaDataService, "ms_vehicletype", "ms_vehicletype1", vehicleType) // }; // lead.ms_vehicletype = crmVehicleType; //} //if (!string.IsNullOrEmpty(leadDetails.EmployerCode)) //{ //var emp = new account { accountnumber = leadDetails.EmployerCode }; // var crmEmployer = new Lookup(); // if (emp.accountid != null) // { // //crmEmployer.Value = emp; // } // else // { // emp = new account { name = leadDetails.EmployerName }; // if (emp.accountid != null) // { // // crmEmployer.Value = emp; // } // else // { // // crmEmployer.Value = TestEmployer; // //lead.TemPMessage; // } // } // lead.ms_employer = crmEmployer; // lead.ms_salarypackager = emp.ms_salarypackager1; //} //var crmState = new Picklist(); //crmState.Value = Convert.ToInt32(leadDetails.State); //lead.ms_homeaddressstate = crmState; lead.firstname = leadDetails.Firstname; lead.lastname = leadDetails.Surname; lead.emailaddress2 = leadDetails.Email; lead.mobilephone = leadDetails.MobilePhone; //var crmPrefferedPhone = new Picklist(); //if (leadDetails.MobilePreferredContact) //{ // crmPrefferedPhone.Value = Convert.ToInt32("Mobile"); //} //else //{ // crmPrefferedPhone.Value = Convert.ToInt32("Work"); //} //lead.ms_preferredphone = crmPrefferedPhone; if (!string.IsNullOrEmpty(leadDetails.OtherPhone)) { lead.telephone1 = leadDetails.OtherPhone; } lead.ms_preferredcontacttime = leadDetails.PreferredCallBackTime; var crmAnnualGS = new CrmDecimal(); if (leadDetails.AnnualGrossSalary.ToString() != "") { crmAnnualGS.Value = leadDetails.AnnualGrossSalary; var crmRefferalSplit = new CrmDecimal(); if (leadDetails.AnnualGrossSalary < 110000) { crmRefferalSplit.Value = (decimal)999.00; } else { //crmRefferalSplit.Value = null; } lead.ms_referralsplit = crmRefferalSplit; } else { crmAnnualGS.Value = 0; } lead.ms_annualgrosssalary = crmAnnualGS; //lead.siteid lead.ms_salesmessages = "Year: " + leadDetails.VehicleYear + "/ Make: " + leadDetails.VehicleMake + "/ Model: " + leadDetails.VehicleType + "\r\n" + "Lease Term: " + leadDetails.LeaseTerm + "\r\n * **\r\n" + leadDetails.OtherInformation; //var emp = new account { ownerid = new Owner { Value = "" }; }; //lead.ownerid= var oppKey = new WebReferences.CrmSdk.Key { Value = leadID }; lead.leadid = oppKey; service.Update(lead); } catch (Exception ex) { throw ex; } }
public async Task <ActionResult> Index(LeadContactViewModel vm) { var client = await GetExchangeClient(); var contactResults = await(from i in client.Me.Contacts select i).ExecuteAsync(); var contact = contactResults.CurrentPage.Where(c => c.Id == vm.selectedSalesStaffID).SingleOrDefault(); //USE HTTPCLIENT //get authorization token Authenticator authenticator = new Authenticator(); var authInfo = await authenticator.AuthenticateAsync(ExchangeResourceId); //send request through HttpClient HttpClient httpClient = new HttpClient(); httpClient.BaseAddress = new Uri(ExchangeResourceId); //add authorization header httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", await authInfo.GetAccessToken()); //prepare POST content for forward request ForwardMessage forwardContent = new Models.ForwardMessage(); forwardContent.Comment = "This lead has been reassigned to you"; forwardContent.ToRecipients.Add(new Recipient() { Address = contact.EmailAddress1, Name = contact.DisplayName }); //convert POST content to JSON StringContent postContent = new StringContent(JsonConvert.SerializeObject(forwardContent)); postContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); //send forward request var forwardResponse = httpClient.PostAsync("/ews/odata/Me/Inbox/Messages('" + vm.selectedLeadID + "')/Forward", postContent).Result; //delete message to remove from INBOX/Lead List //send delete request var deleteResponse = httpClient.DeleteAsync("/ews/odata/Me/Inbox/Messages('" + vm.selectedLeadID + "')").Result; //refresh leads vm.leads.Clear(); var messageResults = await(from i in client.Me.Inbox.Messages where i.Subject.Contains("[SKU:") orderby i.DateTimeSent descending select i).ExecuteAsync(); foreach (var message in messageResults.CurrentPage) { LeadInfo newContact = new LeadInfo(); newContact.ID = message.Id; newContact.email = message.From.Address; newContact.message = message.BodyPreview; newContact.dateReceived = message.DateTimeReceived.Value.DateTime; vm.leads.Add(newContact); } return(View(vm)); }