public ActionResult AddNewLead(NewLeadViewModel newLeadViewModel) { try { SetUpNewLead(newLeadViewModel); var insertNewLeadResponse = AddLead(newLeadViewModel); var result = insertNewLeadResponse < 0 ? "Error" : "Success"; var message = insertNewLeadResponse< 0? "There were errors while trying to add the new lead.":"New Lead Successfully Added"; return Json(new { Result = result, Message = message }); } catch (Exception e) { return Json(new {Result = "Error", Message = "There were errors while trying to add the new lead."}); } }
private void SetUpNewLead(NewLeadViewModel newLeadViewModel) { var userInSession = HttpContext.Session[Utils.UserKey] as UserModel; if (!userInSession.IsNull()) { //It means the user logged is an agentID if (userInSession.EmployeeId > 0) newLeadViewModel.UserAdder_empId = userInSession.EmployeeId; //Otherwise it's a Merchant and it's passed in the MID parameter else newLeadViewModel.MID = GetLoggedUserId(); } //Defining the next visit(To be changed) newLeadViewModel.Source = "Virtual Office Web Site"; newLeadViewModel.status_id = 10; newLeadViewModel.nextVisit = DateTime.Today.AddMonths(1); }
private int AddLead(NewLeadViewModel newLeadViewModel) { var getAddNewLeadRequestInfo = Utils.GetRequestInfo(Method.POST, "/api/Lead/Add"); var insertLeadResponse = _webClient.Execute<AddNewLeadResponse>(newLeadViewModel, ApiUrls.API_KEY, ApiUrls.API_SECRET, getAddNewLeadRequestInfo); return insertLeadResponse.LeadId; }