public void CaptureUserRequest(RequestBranchMoveView model) { try { CoreUserBranchMoveRequest table = new CoreUserBranchMoveRequest { ApprovedBy = -1, ApprovedDate = null, ApproverComments = null, HasBeenApproved = false, CoreBranchId = model.CoreBranchId, CoreUserId = model.CoreUserId, EffectiveDate = null, HasBeenCompleted = false, MoveRequestComment = model.MoveRequestComment, RequestedDate = DateTime.Now, WebJobUpdateCompleted = false }; db.CoreUserBranchMoveRequests.Add(table); db.SaveChanges(); } catch (Exception e) { AuditLog.ErrorLog.LogError(e, 0); } }
private void Logging(int MessengerTriggerId, int NumberOfMails) { using (JazMaxDBProdContext db = new JazMaxDBProdContext()) { MessengerTriggerLog log = new MessengerTriggerLog() { DateAdded = DateTime.Now, MessengerTriggerId = MessengerTriggerId, SendToValue = NumberOfMails.ToString() }; db.MessengerTriggerLogs.Add(log); db.SaveChanges(); } }
private void MarkAsProcessed(int MessengerTriggerId, int NumberContacts = 0) { using (JazMaxDBProdContext db = new JazMaxDBProdContext()) { MessengerTrigger table = db.MessengerTriggers?.FirstOrDefault(x => x.MessengerTriggerId == MessengerTriggerId); if (table != null) { table.HasBeenProcessed = true; table.ProcessedDateTime = DateTime.Now; table.NumberOfContacts = NumberContacts; } db.SaveChanges(); } }
public int AddNote(AdditionalNotesView Note) { using (JazMaxDBProdContext db = new JazMaxDBProdContext()) { DataAccess.CoreAdditionalNote AdditionalNotes = new DataAccess.CoreAdditionalNote() { AdditionalNoteId = Note.AdditionalNoteId, FileUploadId = Note.FileUploadId, CoreUserId = 1, DateCreated = DateTime.Now, DeletedBy = "None", DeletedDate = DateTime.Now, IsActive = true, IsSent = true, NotesArea = Note.NotesArea }; db.CoreAdditionalNotes.Add(AdditionalNotes); db.SaveChanges(); return(AdditionalNotes.AdditionalNoteId); } }
private void ProcessLeadData(LeadRawData data) { using (JazMaxDBProdContext db = new JazMaxDBProdContext()) { #region Linked Lead Check int BranchId = GetPropertyListing(data.PropertyListingId).BranchId; var LinkedLeadData = GetLeadsWithSameProspect(data.FullName, data.ContactNumber, data.Email, BranchId); #endregion #region Create New Lead int LeadID = 0; Lead lead = new Lead() { IsCompleted = false, DateCreated = DateTime.Now, LeadStatusId = 1, LeadSourceId = FindSource(data.SourceName), PropertyListingId = data.PropertyListingId, LeadTypeId = data.IsManualCapture ? (int)LeadType.NewManualLead : (int)LeadType.NewLead, HasLinkedLead = LinkedLeadData != null ? true : false, ServiceCompleted = false, CoreBranchId = BranchId, }; db.Leads.Add(lead); db.SaveChanges(); LeadID = lead.LeadId; JazMax.Core.Leads.Activity.ActivityCreation.CaptureLeadActivity(new Core.Leads.Activity.LeadActivity { CoreUserId = -999, LeadActivityId = 1, LeadId = LeadID, IsSystem = true, Description = "New Lead Has Been Created on " + DateTime.Now.ToLongDateString() }); Console.WriteLine("Lead has been inserted. LeadID - " + LeadID.ToString()); #endregion #region Prospect LeadProspect prop = new LeadProspect() { FullName = data.FullName, LeadId = LeadID, ContactNumber = data.ContactNumber, Comments = data.Comments, Email = data.Email }; db.LeadProspects.Add(prop); db.SaveChanges(); Console.WriteLine("Lead Prospect Has Been Inserted " + prop.LeadProspectId); #endregion #region Assign Agents To Lead if (data.IsManualCapture) { int?GetAgentId = GetAgentIdFromCoreUserId((int)data.CoreUserId); //FOUND AN AGENT if (GetAgentId != null) { LeadAgent agent = new LeadAgent() { LeadId = LeadID, IsActive = true, AgentId = (int)GetAgentId }; db.LeadAgents.Add(agent); db.SaveChanges(); Console.WriteLine("Manual Agent Added " + agent.LeadAgentsId); //Add Lead Activity For Manual Lead JazMax.Core.Leads.Activity.ActivityCreation.CaptureLeadActivity(new Core.Leads.Activity.LeadActivity { CoreUserId = (int)data.CoreUserId, LeadActivityId = 2, LeadId = LeadID, IsSystem = true, Description = "Manual Lead Has Been Assigned To Agent : " + GetAgentName((int)data.CoreUserId), }); } else { foreach (var PropAgent in AgentsForListing(data.PropertyListingId)) { LeadAgent agent = new LeadAgent() { LeadId = LeadID, AgentId = PropAgent.AgentId, IsActive = true }; db.LeadAgents.Add(agent); db.SaveChanges(); int cuid = GetCoreUserIdFromAgentId(PropAgent.AgentId); //Add Lead Activity For Lead JazMax.Core.Leads.Activity.ActivityCreation.CaptureLeadActivity(new Core.Leads.Activity.LeadActivity { CoreUserId = cuid, LeadActivityId = 2, LeadId = LeadID, IsSystem = true, Description = "Lead Has Been Assigned To Agent : " + GetAgentName(cuid), }); Console.WriteLine("Agents have been added to the lead " + agent.LeadAgentsId); } } } else { foreach (var PropAgent in AgentsForListing(data.PropertyListingId)) { LeadAgent agent = new LeadAgent() { LeadId = LeadID, AgentId = PropAgent.AgentId, IsActive = true }; db.LeadAgents.Add(agent); db.SaveChanges(); int cuid = GetCoreUserIdFromAgentId(PropAgent.AgentId); //Add Lead Activity For Lead JazMax.Core.Leads.Activity.ActivityCreation.CaptureLeadActivity(new Core.Leads.Activity.LeadActivity { CoreUserId = cuid, LeadActivityId = 2, LeadId = LeadID, IsSystem = true, Description = "Lead Has Been Assigned To Agent : " + GetAgentName(cuid), }); Console.WriteLine("Agents have been added to the lead " + agent.LeadAgentsId); } } #endregion #region Perform Linked Leads Magic if (LinkedLeadData != null) { var check = db.LeadWithSameProspects.FirstOrDefault(x => x.LeadId == LinkedLeadData.LeadID); if (check != null) { LeadWithSameProspectLink link = new LeadWithSameProspectLink() { LeadWithSameProspectId = check.LeadWithSameProspectId, LinkedLeadId = LeadID }; db.LeadWithSameProspectLinks.Add(link); db.SaveChanges(); JazMax.Core.Leads.Activity.ActivityCreation.CaptureLeadActivity(new Core.Leads.Activity.LeadActivity { CoreUserId = -999, LeadActivityId = 3, LeadId = LeadID, IsSystem = true, Description = "Lead Has Been Linked To " + LeadID, }); } else { LeadWithSameProspect same = new LeadWithSameProspect() { LeadId = LinkedLeadData.LeadID }; db.LeadWithSameProspects.Add(same); db.SaveChanges(); LeadWithSameProspectLink link = new LeadWithSameProspectLink() { LeadWithSameProspectId = same.LeadWithSameProspectId, LinkedLeadId = LeadID }; db.LeadWithSameProspectLinks.Add(link); db.SaveChanges(); JazMax.Core.Leads.Activity.ActivityCreation.CaptureLeadActivity(new Core.Leads.Activity.LeadActivity { CoreUserId = -999, LeadActivityId = 3, LeadId = LeadID, IsSystem = true, Description = "Lead Has Been Linked To " + LinkedLeadData.LeadID, }); } } #endregion #region Mark Raw Data As Processed And Log New Lead var record = db.LeadRawDatas.FirstOrDefault(x => x.LeadRawDataId == data.LeadRawDataId); record.ServiceCompleted = true; record.ServiceCompletedDate = DateTime.Now; db.SaveChanges(); LeadRawDataLog log = new LeadRawDataLog() { LeadId = LeadID, LeadRawDataId = data.LeadRawDataId, DateCreated = DateTime.Now, Message = "New Lead Created" }; db.LeadRawDataLogs.Add(log); db.SaveChanges(); #endregion } }