public bool SendLeadAssociationMail(LeadModel lead) { User associatedTouser = new User(); associatedTouser = userRepository.SingleOrDefault(r => r.UserId == lead.LeadOwnerId && r.RecordDeleted == false); if (associatedTouser != null) { string websiteUrl = ErucaCRM.Utility.ReadConfiguration.WebsiteUrl; string websiteLogoPath = ErucaCRM.Utility.ReadConfiguration.WebsiteLogoPath; string to = string.Empty; string subject = string.Empty; string body = string.Empty; bool IsMailSent = true; to = associatedTouser.EmailId; subject = "Lead information Eurca CRM"; body = "<div style='font-face:arial;'><img src='" + websiteLogoPath + "'><hr/>Dear Customer" + ",<br/><br/>You are assigned a new lead.<br><h2>Lead Information-</h2><br>LeadName:" + Convert.ToString(!string.IsNullOrEmpty(lead.FirstName) ? lead.FirstName : lead.Title) + "</br><br>Company Name:" + lead.LeadCompanyName + "</br><br>Amount:" + Convert.ToString(lead.Amount.HasValue ? lead.Amount.Value : 0) + "</br>Please login into Eruca CRM for more detail. <br/><br/>CRM URL: <a href=" + websiteUrl + ">Click here to navigate to CRM<a/><br/><br/><br/><br/>Thank you.<br/ >Customer Relations</div>"; //body = "<div style='font-face:arial;'><img src='{0}'><hr/>Dear Customer" + ",<br/><br/>Thanks for your registration to Eruca CRM. <br/> Please find the following details to login into Eruca CRM. <br/><br/>CRM URL: <a href='{1}'>Click here to navigate to CRM<a/><br/><br/>" + "Your Username: {2} <br/>Password: {3} <br/><br/>Thank you.<br/><br/>Customer Relations</div>"; try { MailHelper mailHelper = new MailHelper(); mailHelper.SendMailMessage(to, subject, body); } catch (Exception ex) { IsMailSent = false; } return(IsMailSent); } else { return(false); } }
public ActionResult AddLead(LeadModel newLeadModel) { LeadEntity newLeadEntity = manage.ConvertLeadModelToEntity(newLeadModel); accessBusinessLayer.AddLead(newLeadEntity); return(View("Index")); }
private void BindValue(LeadModel model) { cbbArea.SelectedIndexChanged -= new EventHandler(cbbArea_SelectedIndexChanged); cbbUnit.SelectedIndexChanged -= new EventHandler(cbbUnit_SelectedIndexChanged); cbbArea.SelectedValue = model.Area; cbbUnit.SelectedValue = model.DepartmentID; txtMSBGDZ.Text = model.SecretaryAddress; txtMSCZ.Text = model.SecretaryFax; txtMSHJ.Text = model.SecretaryRedPhone; txtMSName.Text = model.Secretary; txtMSPJ.Text = model.SecretaryDormitoryRedPhone; txtMSSJ.Text = model.SecretaryAnyCall; txtMSZZDZ.Text = model.SecretaryDormitoryAddress; txtRemark.Text = model.Mark1; txtUnitPY.Text = model.DepartmentPinyin; txtUpdateRecord.Text = model.Mark2; txtYHBGDZ.Text = model.OfficeAddress; txtYHBGHJ.Text = model.OfficeRedPhone; txtYHBGPJ.Text = model.Phone; txtYHCZ.Text = model.Fax; txtYHSJ.Text = model.AnyCall; txtYHSSDZ.Text = model.DormitoryAddress; txtYHXM.Text = model.AName; txtYHXMJP.Text = model.NamePinyin; txtYHZSHJ.Text = model.DormitoryRedPhone; txtYHZSPJ.Text = model.DormitoryPhone; txtZW.Text = model.Duty; txtUnitPY.Text = model.DepartmentPinyin; lbID.Text = model.ID.ToString(); cbbArea.SelectedIndexChanged += new EventHandler(cbbArea_SelectedIndexChanged); cbbUnit.SelectedIndexChanged += new EventHandler(cbbUnit_SelectedIndexChanged); }
public JsonResult GetEventInfo(string EventId) { objResponse Response = new objResponse(); Response = objCalender.GetEventInfo(Convert.ToInt32(EventId)); List <string> temp1 = new List <string>(); List <string> temp2 = new List <string>(); LeadModel objModel = new LeadModel(); objModel.DBA = Response.ResponseData.Tables[0].Rows[0]["DBA"].ToString(); objModel.ContName = Response.ResponseData.Tables[0].Rows[0]["ContactName"].ToString(); objModel.bPhone = Response.ResponseData.Tables[0].Rows[0]["BusinessPhone"].ToString(); objModel.Email = Response.ResponseData.Tables[0].Rows[0]["Email"].ToString(); string LeadEventStart = Convert.ToDateTime(Response.ResponseData.Tables[0].Rows[0]["event_start"]).ToString("MM/dd/yy hh:mm tt"); temp1 = LeadEventStart.Split(' ').ToList(); objModel.LeadEventStartDate = temp1[0]; objModel.LeadEventStartTime = temp1[1] + " " + temp1[2]; //string LeadEventEnd = Convert.ToDateTime(Response.ResponseData.Tables[0].Rows[0]["event_end"]).AddDays(-1).ToString("MM/dd/yyyy hh:mm tt"); string LeadEventEnd = Convert.ToDateTime(Response.ResponseData.Tables[0].Rows[0]["event_end"]).ToString("MM/dd/yy hh:mm tt"); temp2 = LeadEventEnd.Split(' ').ToList(); objModel.LeadEventEndDate = temp2[0]; objModel.LeadEventEndTime = temp2[1] + " " + temp2[2]; return(Json(objModel, JsonRequestBehavior.AllowGet)); }
private void txtYHBGHJ_TextChanged(object sender, EventArgs e) { if (Status == 1 && txtYHBGHJ.Text.Trim() != string.Empty) { CurrentModel = ItemsSource.FirstOrDefault(x => x.OfficeRedPhone == txtYHBGHJ.Text); if (CurrentModel != null) { BindValue(CurrentModel); } else { foreach (Control ctl in this.groupBox1.Controls) { if (ctl is TextBox && ctl.Name != "txtYHBGHJ") { ctl.Text = string.Empty; ctl.Enabled = false; } } cbbArea.Enabled = false; cbbUnit.Enabled = false; cbbArea.SelectedIndex = -1; cbbUnit.SelectedIndex = -1; cbbUnit.Text = ""; } } }
private void 一个ToolStripMenuItem_Click(object sender, EventArgs e) { SelectedToolButton(this.一个ToolStripMenuItem); if (CurrentModel == null) { MessageBox.Show("当前记录为空,请选择记录!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Code.Common.Iterator <LeadModel> iteratorSS = new ConcreteIterator <LeadModel>(ItemsSource); var cModel = ItemsSource.FirstOrDefault(x => x.ID == CurrentModel.ID); if (cModel != null) { iteratorSS.SetCurrent(cModel); if (iteratorSS.MoveNext()) { CurrentModel = iteratorSS.Next(); BindValue(CurrentModel); } else { MessageBox.Show("已经到了最后的记录!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } }
private void 新增ToolStripMenuItem_Click(object sender, EventArgs e) { SelectedToolButton(this.新增ToolStripMenuItem); Status = 0; SetBtnSave(); foreach (Control ctl in this.groupBox1.Controls) { if (ctl is TextBox) { if (ctl.Name == "txtUnitPY") { ctl.Enabled = true; } else { ctl.Text = string.Empty; ctl.Enabled = true; } } } // cbbArea.SelectedIndex = -1; // cbbUnit.SelectedIndex = -1; cbbArea.Enabled = true; cbbUnit.Enabled = true; // cbbUnit.Text = ""; CurrentModel = null; }
public void PopulateFieldsTest() { // create Partners var Partner1 = new Partner { Id = 1, Name = "Partner1" }; var Partner2 = new Partner { Id = 2, Name = "Partner2" }; this.Partners.Add(Partner1); this.Partners.Add(Partner2); //create sources var source1 = new Source { Id = 1, Name = "Source1" }; var source2 = new Source { Id = 2, Name = "Source2" }; this.Sources.Add(source1); this.Sources.Add(source2); // create LeadModel to be added to the table var LeadModel = new LeadModel { Id = 1, Partner = "Partner Test", Statute = "StatuteTest", FirstName = "Dan" }; var LeadModel2 = new LeadModel { Id = 2, Partner = "Partner2 Test", Statute = "StatuteTest2", FirstName = "Dan2" }; var LeadModel3 = new LeadModel { Id = 3, Partner = "Partner3 Test3", Statute = "StatuteTest3", FirstName = "Dan3" }; this.LeadModelList.Add(LeadModel); this.LeadModelList.Add(LeadModel2); this.LeadModelList.Add(LeadModel3); }
public void ShowModel(LeadModel model, int x, int y) { lX = x; lY = y; //model.OfficeAddress = "阿斯蒂芬三等奖分开了就是打开房间失控的风景独守空房就算到了疯狂就算到了看福建省电力防水堵漏分散到了看分就是打开浪费加速度发生的发生的发生的"; //model.DormitoryAddress = "阿斯蒂芬三等奖分开了就是打开房间失控的风景独守空房就算到了疯狂就算到了看福建省电力防水堵漏分散到了看分就是打开浪费加速度发生的发生的发生的"; //model.Secretary = "阿斯蒂芬三等奖分开了就是打开房间失控的风景独守空房就算到了疯狂就算到了看福建省电力防水堵漏分散到了看分就是打开浪费加速度发生的发生的发生的"; if (DisplayModel == null || DisplayModel.ID == model.ID) { DisplayModel = model; if (CurrentVisible) { HideGlass(); } else { ShowGlass(); } } else { DisplayModel = model; ShowGlass(); } }
public ActionResult AjaxAddTask(string Titele, string StartDate, string EndDate, string StartTime, string EndTime, string RelateTo, string Description, string RemindMe, string Hours, string Minutes, string AssignTo) { objResponse Response = new objResponse(); session = new SessionHelper(); LeadModel objModel = new LeadModel(); try { if (AssignTo == "" || AssignTo == null) { AssignTo = session.UserSession.UserId.ToString(); } Response = objTaskManager.AddTask(Titele, BAL.Helper.Helper.ConvertToDateNullable(StartDate + " " + StartTime, "dd/MM/yyyy HH:mm"), BAL.Helper.Helper.ConvertToDateNullable(StartDate + " " + StartTime, "dd/MM/yyyy HH:mm"), Convert.ToInt64(RelateTo), Description, RemindMe, Hours, Minutes, "Planed", AssignTo, session.UserSession.UserId); if (Response.ErrorCode == 0) { //objModel.Task = UtilityManager.getTasksByRelateToID(Convert.ToInt64(RelateTo), session.UserSession.UserType, session.UserSession.UserId); //return View(objModel); return(Json("Success", JsonRequestBehavior.AllowGet)); } else { return(Json("Fail", JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { BAL.Common.LogManager.LogError("AjaxAddTask conto Method", 1, Convert.ToString(ex.Source), Convert.ToString(ex.Message), Convert.ToString(ex.StackTrace)); return(Json("Fail", JsonRequestBehavior.AllowGet)); } }
public LeadModel GetLeadDetail(int leadId) { LeadModel leadModel = new LeadModel(); Lead lead = leadRepository.SingleOrDefault(x => x.LeadId == leadId && x.RecordDeleted == false); AutoMapper.Mapper.Map(lead, leadModel); if (leadModel.Stage.IsLastStage == true) { if (leadModel.IsClosedWin != null) { leadModel.Rating.Icons = CommonFunctions.GetRatingImage("", true, (bool)leadModel.IsClosedWin); } } if (lead != null) { if (lead.Address != null) { AutoMapper.Mapper.Map(lead.Address, leadModel.AddressModel); AutoMapper.Mapper.Map(lead.Address.Country, leadModel.AddressModel.CountryModel); } //AutoMapper.Mapper.Map(lead.FileAttachments, leadModel.FileAttachmentModels); //AutoMapper.Mapper.Map(lead.Industry, leadModel.IndustryModel); //AutoMapper.Mapper.Map(lead.LeadSource, leadModel.LeadSourceModel); //AutoMapper.Mapper.Map(lead.LeadStatu, leadModel.LeadStatusModel); //AutoMapper.Mapper.Map(lead.ProductLeadAssociations, leadModel.ProductLeadAssociationModels); //AutoMapper.Mapper.Map(lead.User, leadModel.UserModel); leadModel.FinalStageId = stageRepository.SingleOrDefault(r => r.IsLastStage == true && r.CompanyId == lead.CompanyId).StageId; } if (lead == null) { leadModel.RecordDeleted = true; } return(leadModel); }
/// <summary> /// Insert records to Dynamics Entity /// </summary> /// <param name="result"></param> /// <returns></returns> public string PostToCrm([FromBody] LeadModel leadModel) { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; CrmServiceClient service = new CrmServiceClient(ConfigurationManager.ConnectionStrings["CRMConnection"].ConnectionString); Entity leadRecord = new Entity("new_businesscardlead"); leadRecord.Attributes.Add("new_name", leadModel.Name); leadRecord.Attributes.Add("new_company", leadModel.Company); leadRecord.Attributes.Add("new_title", leadModel.Title); leadRecord.Attributes.Add("new_citystatezip", leadModel.CityStateZip); leadRecord.Attributes.Add("new_email", leadModel.Email); leadRecord.Attributes.Add("new_website", leadModel.Website); leadRecord.Attributes.Add("new_facebook", leadModel.Facebook); leadRecord.Attributes.Add("new_twitter", leadModel.Twitter); leadRecord.Attributes.Add("new_phone", leadModel.Phone); leadRecord.Attributes.Add("new_fax", leadModel.Fax); leadRecord.Attributes.Add("new_cell", leadModel.Cell); var guid = service.Create(leadRecord); string id = guid.ToString(); string response = $"Lead has been created for {leadModel.Name} : lead Id : {id}."; return(response); }
public static Lead Create(LeadModel model, string userId) { var lead = new Lead { FirstName = model.FirstName, LastName = model.LastName, Email = model.Email, Website = model.Website, Mobile = model.Mobile, LeadSourceId = model.LeadSourceId, LeadStatusId = model.LeadStatusId, Status = Constants.RecordStatus.Active, Phone = model.Phone, CreatedBy = userId ?? "0", CreatedOn = Utility.GetDateTime(), Address = new Address { CountryId = model.Address.CountryId, StateId = model.Address.StateId, CityId = model.Address.CityId, PostalCode = model.Address.PostalCode, StreetName = model.Address.StreetName } }; return(lead); }
public ActionResult ShowSingleLead(int id) { if (Session["UserId"] == null) { return(RedirectToAction("Login", "Account")); } else { GetLeadType(); GetTimeZone(); GetUser(); Lead vlead = db.Leads.Where(p => p.ID == id).FirstOrDefault(); LeadModel Lmodel = new LeadModel(); Lmodel.ID = vlead.ID; Lmodel.LeadDate = vlead.LeadDate; Lmodel.LeadTime = vlead.LeadTime; Lmodel.LeadTypeID = vlead.LeadType; Lmodel.ClientName = vlead.ClientName; Lmodel.ContactNo = vlead.ContactNo; Lmodel.Email = vlead.Email; Lmodel.TimeZoneID = vlead.TimeZone; Lmodel.Location = vlead.Location; Lmodel.IPAddress = vlead.IPAddress; Lmodel.LeadStatus = vlead.LeadStatus; Lmodel.Budget = vlead.Budget; Lmodel.NextPlan = vlead.NextPlan; Lmodel.LastStatus = vlead.LastStatus; Lmodel.IntialRequirements = vlead.IntialRequirements; Lmodel.AssignedToUSerID = vlead.AssignedToUSerID; return(View("AddLead", Lmodel)); } }
public static void Create(LeadModel model, Lead entity, string userId) { entity.FirstName = model.FirstName; entity.LastName = model.LastName; entity.Email = model.Email; entity.Website = model.Website; entity.Mobile = model.Mobile; entity.LeadSourceId = model.LeadSourceId; entity.LeadStatusId = model.LeadStatusId; entity.Phone = model.Phone; entity.UpdatedBy = userId ?? "0"; entity.UpdatedOn = Utility.GetDateTime(); entity.CompanyName = model.CompanyName; //if (!model.Address.Id.HasValue && model.Address.IsAllNullOrEmpty()) //{ // return; //} if (entity.Address != null) { entity.Address.CountryId = model.Address.CountryId; entity.Address.StateId = model.Address.StateId; entity.Address.CityId = model.Address.CityId; entity.Address.PostalCode = model.Address.PostalCode; entity.Address.StreetName = model.Address.StreetName; } }
public IActionResult Register(LeadModel leadModel) { if (ModelState.IsValid) { var content = new StringContent(JsonConvert.SerializeObject(leadModel), System.Text.Encoding.UTF8, "application/json"); HttpResponseMessage model; if (leadModel.ID > 0) { model = _apiClient.PutAsync("leads", content).Result; } else { model = _apiClient.PostAsync("leads", content).Result; } if (model.IsSuccessStatusCode) { return(RedirectToAction("Index")); } else { ModelState.AddModelError("Save", "Error saving lead"); } } leadModel.LeadTypeList = GetLeadList(); return(View(leadModel)); }
/// <summary> /// Create a Service Lead /// </summary> /// <param name="ownerPartyId"></param> /// <param name="orgExternalRef"></param> /// <param name="contactExternalRef"></param> /// <param name="name"></param> /// <returns></returns> public long?CreateServiceLead(long?ownerPartyId, long?orgExternalRef, long?contactExternalRef, string name) { ILeadService service = LeadService.GetService(); LeadModel model = new LeadModel(); model.Name = name; if (orgExternalRef != null) { model.CustomerId = (long)orgExternalRef; model.CustomerIdSpecified = true; } model.OwnerId = (long)ownerPartyId; model.OwnerIdSpecified = true; model.PrimaryContactId = (long)contactExternalRef; model.PrimaryContactIdSpecified = true; LeadModel result = service.CreateServiceLead(model); if (result != null && result.LeadId != null) { return(result.LeadId); } return(null); }
public async Task Update(LeadModel lead) { var entity = _mapper.Map <LeadEntity>(lead); await _dbRepository.Update(entity); await _dbRepository.SaveChangesAsync(); }
public async Task EditAsync(LeadModel model) { var lead = await _leadRepository.GetAsync(model.Id); LeadFactory.Create(model, lead, _userId); _leadRepository.Edit(lead); await _unitOfWork.SaveChangesAsync(); }
public LeadModel AddLead(LeadModel leadModel) { Lead lead = new Lead(); LeadModel _leadmodel = new LeadModel(); RatingModel ratingModel = new RatingModel(); if (!leadModel.LeadSourceId.HasValue || leadModel.LeadSourceId.Value == 0) { leadModel.LeadSourceId = null; leadModel.LeadSourceModel = null; } if (!leadModel.LeadStatusId.HasValue || leadModel.LeadStatusId.Value == 0) { leadModel.LeadStatusId = null; leadModel.LeadStatusModel = null; } if (!leadModel.IndustryId.HasValue || leadModel.IndustryId.Value == 0) { leadModel.IndustryId = null; leadModel.IndustryModel = null; } AutoMapper.Mapper.Map(leadModel, lead); lead.RatingId = leadModel.RatingId > 0 ? leadModel.RatingId : null; lead.CreatedDate = DateTime.UtcNow; lead.CreatedBy = leadModel.CreatedBy; lead.ModifiedDate = DateTime.UtcNow; // StageModel stageModel = stageBusiness.GetIntialStage((int)leadModel.CompanyId); List <Stage> stageList = new List <Stage>(); stageList = stageRepository.GetAll(r => r.CompanyId == lead.CompanyId && r.RecordDeleted == false).OrderBy(r => r.StageOrder).ToList(); if (lead.AccountId > 0) { if (stageList.Count > 2) { Stage stage = stageList.FirstOrDefault(r => r.StageOrder >= Constants.ACCOUNT_LEAD_STAGE); lead.StageId = stage.StageId; lead.RatingId = stage.Rating.RatingId; } else { lead.StageId = stageList.SingleOrDefault(r => r.IsInitialStage == true).StageId; } } else { lead.StageId = stageList.SingleOrDefault(r => r.IsInitialStage == true).StageId; } lead.Address = ValidateAddress(lead.Address, leadModel.AddressModel); leadRepository.Insert(lead); AddLeadToDateAudit(lead, false); AutoMapper.Mapper.Map(lead, _leadmodel); _leadmodel.Rating = ratingModel; return(_leadmodel); }
public Guid Create(LeadModel lead) { try { Guid leadId = leadservice.CreateLead(lead); return(leadId); } catch (Exception e) { throw e; } }
public LeadModel GetLeadDetailForEdit(int leadId) { LeadModel leadModel = new LeadModel(); Lead lead = leadRepository.SingleOrDefault(x => x.LeadId == leadId && x.RecordDeleted == false); AutoMapper.Mapper.Map(lead, leadModel); AutoMapper.Mapper.Map(lead.Address, leadModel.AddressModel); // AutoMapper.Mapper.Map(lead.Address.Country, leadModel.AddressModel.CountryModel); return(leadModel); }
public InitiateCalculateOfferCommand(ArrangementKind arrangementKind, string currency, decimal amount, decimal annuity, string term, decimal interestRate, decimal downpaymentAmount, decimal invoiceAmount, decimal minimalDownpaymentPercentage, string channel, decimal?riskScore, string creditRating, decimal?customerValue, decimal?debtToIncome, string customerSegment, string partOfBundle, string collateralModel, ProductConditions productConditions, Conditions conditions, LeadModel campaign, List <ProductOption> productOptions, Dictionary <string, JToken> bundledComponents, decimal downpaymentPercentage, List <ScheduledPeriod> scheduledPeriods, DateTime?calculationDate, DateTime?requestDate, DateTime?approvalDate, DateTime?signingDate, DateTime?disbursmentDate, DateTime?firstInstallmentDate, DateTime?maturityDate, string gracePeriod, DateTime?gracePeriodStartDate, string drawdownPeriod, DateTime?drawdownPeriodStartDate, RepaymentType?repaymentType, int numberOfInstallments, int minimumDaysForFirstInstallment, bool adjustFirstInstallment, bool payFeeFromDisbursement, SimpleSchedule installmentSchedule, IntercalarInterestRepaymentType intercalarInterestRepaymentType) { ArrangementKind = arrangementKind; Currency = currency; Amount = amount; Annuity = annuity; Term = term; InterestRate = interestRate; DownpaymentAmount = downpaymentAmount; InvoiceAmount = invoiceAmount; MinimalDownpaymentPercentage = minimalDownpaymentPercentage; Channel = channel; RiskScore = riskScore; CreditRating = creditRating; CustomerValue = customerValue; DebtToIncome = debtToIncome; CustomerSegment = customerSegment; PartOfBundle = partOfBundle; CollateralModel = collateralModel; ProductConditions = productConditions; Conditions = conditions; Campaign = campaign; ProductOptions = productOptions; BundledComponents = bundledComponents; DownpaymentPercentage = downpaymentPercentage; ScheduledPeriods = scheduledPeriods; CalculationDate = calculationDate ?? DateTime.Now; RequestDate = requestDate ?? DateTime.Now; ApprovalDate = approvalDate; SigningDate = signingDate; DisbursmentDate = disbursmentDate; FirstInstallmentDate = firstInstallmentDate; MaturityDate = maturityDate; GracePeriod = gracePeriod; GracePeriodStartDate = gracePeriodStartDate; DrawdownPeriod = drawdownPeriod; DrawdownPeriodStartDate = drawdownPeriodStartDate; RepaymentType = repaymentType ?? Domain.Calculations.InstallmentPlanCalculation.RepaymentType.FixedAnnuity; NumberOfInstallments = numberOfInstallments; MinimumDaysForFirstInstallment = minimumDaysForFirstInstallment; AdjustFirstInstallment = adjustFirstInstallment; PayFeeFromDisbursement = payFeeFromDisbursement; InstallmentSchedule = installmentSchedule; IntercalarInterestRepaymentType = intercalarInterestRepaymentType; }
public LeadModel UpdateLeadRating(int leadId, int ratingId, int ModifiedBy) { LeadModel leadModel = new LeadModel(); leadModel.LeadId = leadId; leadModel.RatingId = ratingId; leadModel.ModifiedBy = ModifiedBy; leadModel = Update(leadModel); return(leadModel); }
public LeadModel UpdateLead(int leadId, int stageId, int ratingId) { LeadModel leadModel = new LeadModel(); leadModel.LeadId = leadId; leadModel.StageId = stageId; leadModel.RatingId = ratingId; leadModel = Update(leadModel); return(leadModel); }
public async Task <Guid> Create(LeadModel lead) { var entity = _mapper.Map <LeadEntity>(lead); entity.UserCreated = _currentUser.Id; var result = await _dbRepository.Add(entity); await _dbRepository.SaveChangesAsync(); return(result); }
public async Task <IActionResult> AddLead([FromBody] LeadModel obj) { try { if (ModelState.IsValid) { ClaimsIdentity claimsIdentity = User.Identity as ClaimsIdentity; var currentLoginUserid = new UserClaims(claimsIdentity).LoggedInUserId; var currentLoginUserOrgid = new UserClaims(claimsIdentity).OrgId; var config = new MapperConfiguration(cfg => { cfg.CreateMap <LeadModel, LeadInfoDTO>(); }); obj.createdBy = currentLoginUserid; obj.orgId = currentLoginUserOrgid; IMapper mapperResponse = config.CreateMapper(); var leadDTO = mapperResponse.Map <LeadModel, LeadInfoDTO>(obj); using (var uow = new UnitOfWork(_configs.Value.DbConnectionString)) { string result = await uow.AdvanceLeadCreator.AddUpdateLeadAsync(leadDTO); uow.Commit(); if (result == "1") { return(Ok(new ApiResponse { message = ApiMessageConstants.commonUpdated })); } return(Ok(new ApiResponse { message = ApiMessageConstants.commonAdded, data = result })); } } else { return(BadRequest(new ApiResponse { message = ApiMessageConstants.someThingWentWrong })); } } catch (Exception ex) { return(BadRequest(new ApiResponse { message = ex.Message })); } }
public static LeadModel ToLead(this LeadInputModel model) { var lead = new LeadModel { PhoneNumber = model.ContactNumber, Person = { FirstName = model.FirstName, LastName = model.LastName } }; return(lead); }
public void CreateLead(LeadModel lead, CrmSession session) { var leadUrl = "https://saxohack.api.crm11.dynamics.com/api/data/v9.1/leads"; var client = GetClient(session); var leadString = JsonConvert.SerializeObject(lead, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); HttpContent leadJsonContent = new StringContent(leadString, Encoding.UTF8, "application/json"); var createLeadResponse = client.PostAsync(leadUrl, leadJsonContent).Result; lead.CreatedLeadGuid = createLeadResponse.Headers.Location.Segments[4]; lead.LeadId = lead.CreatedLeadGuid.Substring(4, lead.CreatedLeadGuid.Length - 6); }
public ActionResult Create(LeadModel vm) { try { var newPerson = new Person { Email = vm.Email, PhoneNo = vm.Phone, Country = vm.Country, FirstName = !string.IsNullOrEmpty(vm.FirstName) ? vm.FirstName : "Unknown", LastName = !string.IsNullOrEmpty(vm.LastName) ? vm.LastName : "Unknown" }; _personRepository.Create(newPerson); var newCRMLead = new CRMLead { Description = vm.Message, AssignedToUserId = vm.CreatedByUserId, LeadSourceId = vm.LeadSourceId, CategoryId = vm.CategoryId, LeadStatusId = vm.StatusId, PersonId = newPerson.Id, RecievedOn = DateTime.UtcNow, CreatedByUserId = vm.CreatedByUserId }; _crmLeadRepository.Create(newCRMLead); _unitOfWork.Commit(); var result = new ApiResult <bool> { Status = true, Message = "Success" }; return(Json(result)); } catch (Exception ex) { var result = new ApiResult <bool> { Status = false, Message = ex.Message }; return(Json(result)); } }