public bool IsDuplicateFacebookAdapter(int accountId, int leadadapterID, string name) { int count = 0; var db = ObjectContextFactory.Create(); if (leadadapterID != 0) { var leadAdapter = db.LeadAdapters.Where(w => w.LeadAdapterAndAccountMapId != leadadapterID && w.IsDelete == false && w.LeadAdapterTypeID == (byte)LeadAdapterTypes.Facebook && w.AccountID == accountId) .Select(s => s.LeadAdapterAndAccountMapId); if (leadAdapter != null) { count = db.FacebookLeadAdapters.Count(w => leadAdapter.Contains(w.LeadAdapterAndAccountMapID) && w.Name.ToLower() == name.ToLower()); } } else { var leadAdapter = db.LeadAdapters.Where(w => w.IsDelete == false && w.LeadAdapterTypeID == (byte)LeadAdapterTypes.Facebook && w.AccountID == accountId) .Select(s => s.LeadAdapterAndAccountMapId); if (leadAdapter != null) { count = db.FacebookLeadAdapters.Count(w => leadAdapter.Contains(w.LeadAdapterAndAccountMapID) && w.Name.ToLower() == name.ToLower()); } } return(count > 0); }
/// <summary> /// Determines whether [is configured with vmta] [the specified image domain identifier]. /// </summary> /// <param name="imageDomainID">The image domain identifier.</param> /// <returns></returns> public bool IsConfiguredWithVMTA(byte imageDomainID) { var db = ObjectContextFactory.Create(); bool isconfiguredwithvmta = db.ServiceProviders.Where(i => i.ImageDomainID == imageDomainID).Count() > 0; return(isconfiguredwithvmta); }
public void UpdateTCAcceptance(int userId, int accountId) { var db = ObjectContextFactory.Create(); var settings = db.UserSettings.Where(w => w.UserID == userId).FirstOrDefault(); if (settings != null) { settings.HasAcceptedTC = true; db.Entry(settings).State = System.Data.Entity.EntityState.Modified; } else //Newely created user (Has no settings) { var accountSettings = db.Accounts.Where(w => w.AccountID == accountId).Select(s => new { CurrencyID = s.CurrencyID, CountryID = s.CountryID, TimeZone = s.TimeZone }).FirstOrDefault(); UserSettingsDb settingsDb = new UserSettingsDb(); settingsDb.AccountID = accountId; settingsDb.UserID = userId; settingsDb.ItemsPerPage = 25; //Default Items per page is 25 settingsDb.DateFormat = 2; settingsDb.CountryID = accountSettings.CountryID; settingsDb.CurrencyID = accountSettings.CurrencyID; settingsDb.TimeZone = accountSettings.TimeZone; settingsDb.HasAcceptedTC = true; db.Entry(settingsDb).State = System.Data.Entity.EntityState.Added; } db.SaveChanges(); }
/// <summary> /// Determines whether [is tour from select all] [the specified tour identifier]. /// </summary> /// <param name="tourId">The tour identifier.</param> /// <returns></returns> public bool IsTourFromSelectAll(int tourId) { var db = ObjectContextFactory.Create(); bool selectAll = db.Tours.Where(p => p.TourID == tourId).Select(p => p.SelectAll).FirstOrDefault(); return(selectAll); }
/// <summary> /// Deleting Marketing messages /// </summary> /// <param name="MarketingMessageID"></param> public void DeleteMarketingMessageContents(int MarketingMessageID) { var db = ObjectContextFactory.Create(); db.MarketingMessageContentMap.RemoveRange(db.MarketingMessageContentMap.Where(m => m.MarketingMessageID == MarketingMessageID)); db.SaveChanges(); }
/// <summary> /// Tours the completed. /// </summary> /// <param name="tourId">The tour identifier.</param> /// <param name="status">if set to <c>true</c> [status].</param> /// <param name="contactId">The contact identifier.</param> /// <param name="completedForAll">if set to <c>true</c> [completed for all].</param> /// <param name="userId">The user identifier.</param> /// <param name="updatedOn">The updated on.</param> public void TourCompleted(int tourId, bool status, int?contactId, bool completedForAll, int userId, DateTime updatedOn) { var db = ObjectContextFactory.Create(); var contactTour = new List <ContactTourMapDb>(); if (!completedForAll) { contactTour = db.ContactTours.Where(c => c.TourID == tourId && c.ContactID == contactId).ToList(); contactTour.ForEach(x => { x.IsCompleted = status; x.LastUpdatedBy = userId; x.LastUpdatedOn = updatedOn; }); } else { contactTour = db.ContactTours.Where(c => c.TourID == tourId).ToList(); contactTour.ForEach(x => { x.IsCompleted = status; x.LastUpdatedBy = userId; x.LastUpdatedOn = updatedOn; }); } db.SaveChanges(); }
/// <summary> /// Persists the user tours. /// </summary> /// <param name="tour">The tour.</param> /// <param name="tourDb">The tour database.</param> /// <param name="db">The database.</param> public void PersistUserTours(Tour tour, TourDb tourDb, CRMDb db) { var userTourDb = new List <UserTourMapDb>(); var dbData = ObjectContextFactory.Create(); var sql = @"SELECT UAM.UserID FROM UserTourMap (NOLOCK) UAM WHERE UAM.TourID = @tourId"; var dbData1 = ObjectContextFactory.Create(); var tourUsers = dbData1.Get <int>(sql, new { tourId = tour.Id }); tourUsers = tour.OwnerIds.Except(tourUsers); foreach (int userId in tourUsers) { userTourDb.Add(new UserTourMapDb() { TourID = tourDb.TourID, UserID = userId, LastUpdatedOn = DateTime.Now.ToUniversalTime(), LastUpdatedBy = tour.CreatedBy, UserEmailGuid = (tour.EmailGuid != null && tour.EmailGuid.Any()) ? tour.EmailGuid.Where(s => s.Key == userId).Select(v => v.Value).FirstOrDefault(): new Guid(), UserTextGuid = (tour.TextGuid != null && tour.TextGuid.Any()) ? tour.TextGuid.Where(s => s.Key == userId).Select(v => v.Value).FirstOrDefault() : new Guid() }); } db.UserTours.AddRange(userTourDb); var UnMapTourUsers = db.UserTours.Where(s => !tour.OwnerIds.Contains(s.UserID) && s.TourID == tour.Id).ToArray(); db.UserTours.RemoveRange(UnMapTourUsers); }
/// <summary> /// Finds the lead adapter job logs summary. /// </summary> /// <param name="predicate">The predicate.</param> /// <returns></returns> IEnumerable <LeadAdapterJobLogsDb> findLeadAdapterJobLogsSummary(System.Linq.Expressions.Expression <Func <LeadAdapterJobLogsDb, bool> > predicate) { IEnumerable <LeadAdapterJobLogsDb> leadAdapterJobLogs = ObjectContextFactory.Create().LeadAdapterJobLogs .AsExpandable() .Where(predicate).OrderByDescending(c => c.LeadAdapterAndAccountMapID).Select(a => new { LeadAdapterAndAccountMapID = a.LeadAdapterAndAccountMapID, LeadAdapterJobLogID = a.LeadAdapterJobLogID, CreatedDateTime = a.CreatedDateTime, FileName = a.FileName, Remarks = a.Remarks, LeadAdapterJobStatusID = a.LeadAdapterJobStatusID }).ToList().Select(x => new LeadAdapterJobLogsDb { LeadAdapterAndAccountMapID = x.LeadAdapterAndAccountMapID, LeadAdapterJobLogID = x.LeadAdapterJobLogID, CreatedDateTime = x.CreatedDateTime, FileName = x.FileName, Remarks = x.Remarks, LeadAdapterJobStatusID = x.LeadAdapterJobStatusID }); return(leadAdapterJobLogs); }
/// <summary> /// Finds the lead adapter job log details count. /// </summary> /// <param name="leadAdapterAndAccountMapID">The lead adapter and account map identifier.</param> /// <param name="status">if set to <c>true</c> [status].</param> /// <returns></returns> public int FindLeadAdapterJobLogDetailsCount(int leadAdapterAndAccountMapID, bool status) { var db = ObjectContextFactory.Create(); var predicate = PredicateBuilder.True <LeadAdapterJobLogDetailsDb>(); predicate = predicate.And(a => a.LeadAdapterJobLogID == leadAdapterAndAccountMapID); if (status) { predicate = predicate.And(a => a.LeadAdapterRecordStatusID == LeadAdapterRecordStatus.Added || a.LeadAdapterRecordStatusID == LeadAdapterRecordStatus.Updated); } else { predicate = predicate.And(a => a.LeadAdapterRecordStatusID == LeadAdapterRecordStatus.Duplicate || a.LeadAdapterRecordStatusID == LeadAdapterRecordStatus.ValidationFailed || a.LeadAdapterRecordStatusID == LeadAdapterRecordStatus.BuilderNumberFailed || a.LeadAdapterRecordStatusID == LeadAdapterRecordStatus.DuplicateFromFile); } int count = db.LeadAdapterJobLogDetails.AsExpandable().Where(predicate).Count(); return(count); }
/// <summary> /// Finds the leadadapters summary. /// </summary> /// <param name="predicate">The predicate.</param> /// <returns></returns> IEnumerable <LeadAdapterAndAccountMapDb> findLeadadaptersSummary(System.Linq.Expressions.Expression <Func <LeadAdapterAndAccountMapDb, bool> > predicate) { IEnumerable <LeadAdapterAndAccountMapDb> leadAdapters = ObjectContextFactory.Create().LeadAdapters.Include(x => x.LeadAdapterErrorStatus) .AsExpandable() .Where(predicate).OrderByDescending(c => c.AccountID).Select(a => new { AccountID = a.AccountID, LeadAdapterTypes = a.LeadAdapterTypes, LeadAdapterID = a.LeadAdapterAndAccountMapId, LeadAdapterTypeID = a.LeadAdapterTypeID, CreatedDate = a.CreatedDateTime, LeadAdapterError = a.LeadAdapterErrorStatus, LastProcessed = a.LastProcessed, Statuses = a.Statuses }).ToList().Select(x => new LeadAdapterAndAccountMapDb { AccountID = x.AccountID, LeadAdapterAndAccountMapId = x.LeadAdapterID, LeadAdapterTypeID = x.LeadAdapterTypeID, CreatedDateTime = x.CreatedDate, LeadAdapterErrorStatus = x.LeadAdapterError, LastProcessed = x.LastProcessed, Statuses = x.Statuses }).OrderByDescending(i => i.CreatedDateTime); return(leadAdapters); }
/// <summary> /// Finds the lead adapter job log details summary. /// </summary> /// <param name="predicate">The predicate.</param> /// <returns></returns> IEnumerable <LeadAdapterJobLogDetailsDb> findLeadAdapterJobLogDetailsSummary(System.Linq.Expressions.Expression <Func <LeadAdapterJobLogDetailsDb, bool> > predicate) { IEnumerable <LeadAdapterJobLogDetailsDb> leadAdapterJobLogs = ObjectContextFactory.Create() .LeadAdapterJobLogDetails .Include(c => c.LeadAdapterRecordStatus) .AsExpandable() .Where(predicate).OrderByDescending(c => c.LeadAdapterJobLogDetailID).Select(a => new { LeadAdapterJobLogDetailID = a.LeadAdapterJobLogDetailID, ReferenceId = a.ReferenceId, CreatedDateTime = a.CreatedDateTime, LeadAdapterRecordStatusID = a.LeadAdapterRecordStatusID, RowData = a.RowData, Remarks = a.Remarks, LeadAdapterRecordStatus = a.LeadAdapterRecordStatus }).ToList().Select(x => new LeadAdapterJobLogDetailsDb { LeadAdapterJobLogDetailID = x.LeadAdapterJobLogDetailID, ReferenceId = x.ReferenceId, CreatedDateTime = x.CreatedDateTime, LeadAdapterRecordStatusID = x.LeadAdapterRecordStatusID, RowData = x.RowData, Remarks = x.Remarks, LeadAdapterRecordStatus = x.LeadAdapterRecordStatus }); return(leadAdapterJobLogs); }
/// <summary> /// Finds all. /// </summary> /// <param name="name">The name.</param> /// <param name="limit">The limit.</param> /// <param name="pageNumber">The page number.</param> /// <param name="accountID">The account identifier.</param> /// <returns></returns> public IEnumerable <LeadAdapterAndAccountMap> FindAll(string name, int limit, int pageNumber, int accountID) { var records = (pageNumber - 1) * limit; string query = @"SELECT LACM.LeadAdapterAndAccountMapID, LACM.LeadAdapterTypeID, CreatedDateTime, LastProcessed, LT.Name AS LeadAdapterType, S.[Description] AS ServiceStatusMessage, LES.LeadAdapterErrorStatus AS LeadAdapterErrorName, ISNULL(FL.Name, '') AS FacebookLeadAdapterName,COUNT(1) OVER() as TotalCount FROM LeadAdapterAndAccountMap (NOLOCK) LACM INNER JOIN LeadAdapterTypes (NOLOCK) LT ON LT.LeadAdapterTypeID = LACM.LeadAdapterTypeID LEFT JOIN Statuses (NOLOCK) S ON S.StatusID = LACM.LeadAdapterServiceStatusID LEFT JOIN LeadAdapterErrorStatus (NOLOCK) LES ON LES.LeadAdapterErrorStatusID = LACM.LeadAdapterErrorStatusID LEFT JOIN FacebookLeadAdapter(NOLOCK) FL ON FL.LeadAdapterAndAccountMapID = LACM.LeadAdapterAndAccountMapID WHERE AccountID = @accountid AND IsDelete = 0 AND LACM.LeadAdapterTypeID != 11 ORDER BY CreatedDateTime DESC"; IEnumerable <LeadAdapterAndAccountMapDb> leadadaptersDb = ObjectContextFactory.Create().Get <LeadAdapterAndAccountMapDb>(query, new { accountid = accountID }, false); if (!string.IsNullOrEmpty(name)) { leadadaptersDb = leadadaptersDb.Where(w => w.LeadAdapterType.ToLower().Contains(name.ToLower()) || w.FacebookLeadAdapterName.ToLower().Contains(name.ToLower())); } leadadaptersDb = leadadaptersDb.AsQueryable().Skip(records).Take(limit).ToList(); foreach (LeadAdapterAndAccountMapDb da in leadadaptersDb) { yield return(ConvertToDomain(da)); } }
/// <summary> /// Converts to lead adapterjob logs domain. /// </summary> /// <param name="leadAdapterJobLogsDb">The lead adapter job logs database.</param> /// <returns></returns> public LeadAdapterJobLogs ConvertToLeadAdapterjobLogsDomain(LeadAdapterJobLogsDb leadAdapterJobLogsDb) { LeadAdapterJobLogs leadAdapterJobLogs = new LeadAdapterJobLogs(); Mapper.Map <LeadAdapterJobLogsDb, LeadAdapterJobLogs>(leadAdapterJobLogsDb, leadAdapterJobLogs); var db = ObjectContextFactory.Create(); bool successRecords = db.LeadAdapterJobLogDetails.Where(i => i.LeadAdapterJobLogID == leadAdapterJobLogsDb.LeadAdapterJobLogID && (i.LeadAdapterRecordStatusID == LeadAdapterRecordStatus.Added || i.LeadAdapterRecordStatusID == LeadAdapterRecordStatus.Updated)) .Count() > 0; bool failureRecords = db.LeadAdapterJobLogDetails.Where(i => i.LeadAdapterJobLogID == leadAdapterJobLogsDb.LeadAdapterJobLogID && (i.LeadAdapterRecordStatusID == LeadAdapterRecordStatus.ValidationFailed || i.LeadAdapterRecordStatusID == LeadAdapterRecordStatus.BuilderNumberFailed || i.LeadAdapterRecordStatusID == LeadAdapterRecordStatus.DuplicateFromFile || i.LeadAdapterRecordStatusID == LeadAdapterRecordStatus.SystemFailure || i.LeadAdapterRecordStatusID == LeadAdapterRecordStatus.CommunityNumberFailed || i.LeadAdapterRecordStatusID == LeadAdapterRecordStatus.Duplicate)) .Count() > 0; leadAdapterJobLogs.SuccessRecords = successRecords; leadAdapterJobLogs.FailureRecords = failureRecords; return(leadAdapterJobLogs); }
public IEnumerable <FacebookLeadGen> GetFacebookLeadGens(int accountMapID) { var db = ObjectContextFactory.Create(); IEnumerable <FacebookLeadGen> fbLeadGens = new List <FacebookLeadGen>(); FacebookLeadAdapterDb facebookLeadAdapter = db.FacebookLeadAdapters.Where(w => w.LeadAdapterAndAccountMapID == accountMapID).FirstOrDefault(); if (facebookLeadAdapter != null) { var sql = @";WITH CTE AS ( SELECT *, ROW_NUMBER() OVER (PARTITION BY leadgenid ORDER BY createddate DESC) AS Rank_Number FROM FacebookLeadgen where AdID = @AdID and IsProcessed = 0 ) SELECT * FROM CTE WHERE Rank_Number = 1"; var newDb = ObjectContextFactory.Create(); IEnumerable <FacebookLeadGenDb> leadGens = newDb.Get <FacebookLeadGenDb>(sql, new { AdID = facebookLeadAdapter.AddID }); if (leadGens != null) { fbLeadGens = Mapper.Map <IEnumerable <FacebookLeadGenDb>, IEnumerable <FacebookLeadGen> >(leadGens); } fbLeadGens.ForEach(f => { f.PageAccessToken = facebookLeadAdapter.PageAccessToken; }); } return(fbLeadGens); }
/// <summary> /// Finds the by. /// </summary> /// <param name="id">The identifier.</param> /// <returns></returns> public override ThirdPartyClient FindBy(string id) { var db = ObjectContextFactory.Create(); var client = db.ThirdPartyClients.Where(c => c.ID == id).FirstOrDefault(); return(ConvertToDomain(client)); }
/// <summary> /// Gets the related contacts. /// </summary> /// <param name="opportunityId">The opportunity identifier.</param> /// <returns></returns> public IEnumerable <int> GetRelatedContacts(int opportunityId) { var contacts = ObjectContextFactory.Create().OpportunityContactMap .Where(oc => oc.OpportunityID == opportunityId).Select(o => o.ContactID).ToList(); return(contacts); }
/// <summary> /// Gets the refresh token. /// </summary> /// <param name="Id">The identifier.</param> /// <returns></returns> public ClientRefreshToken GetRefreshToken(string Id) { var db = ObjectContextFactory.Create(); var refreshToken = db.ClientRefreshTokens.Find(Id); return(Mapper.Map <ClientRefreshToken>(refreshToken)); }
/// <summary> /// Finds the opportunities summary. /// </summary> /// <param name="predicate">The predicate.</param> /// <returns></returns> IEnumerable <OpportunitiesDb> findOpportunitiesSummary(System.Linq.Expressions.Expression <Func <OpportunitiesDb, bool> > predicate) { IEnumerable <OpportunitiesDb> opportunities = ObjectContextFactory.Create().Opportunities.Where(predicate) .Include("OpportunityContactMap").Include("Statuses").Include("OpportunitiesRelationshipMap") .AsExpandable() .Select(a => new { OpportunityID = a.OpportunityID, AccountID = a.AccountID, OpportunityName = a.OpportunityName, Potential = a.Potential, StageID = a.StageID, CloseDate = a.ExpectedClosingDate, Statuses = a.Statuses }).ToList().Select(x => new OpportunitiesDb { OpportunityID = x.OpportunityID, AccountID = x.AccountID, OpportunityName = x.OpportunityName, Potential = x.Potential, StageID = x.StageID, ExpectedClosingDate = x.CloseDate, Statuses = x.Statuses }); return(opportunities); }
/// <summary> /// Persists the tour outlook synchronize. /// </summary> /// <param name="tour">The tour.</param> /// <param name="toursDb">The tours database.</param> /// <param name="db">The database.</param> public void UpdateCRMOutlookMap(Tour tour, RequestOrigin?requestedFrom) { CRMOutlookSyncDb outlookSyncDb; var db = ObjectContextFactory.Create(); if (tour.Id > 0) { var taskCurrentSyncStatus = requestedFrom != RequestOrigin.Outlook ? (short)OutlookSyncStatus.NotInSync : (short)OutlookSyncStatus.InSync; outlookSyncDb = db.CRMOutlookSync.Where(o => o.EntityID == tour.Id && o.EntityType == (byte)AppModules.ContactTours).FirstOrDefault(); if (outlookSyncDb != null) { outlookSyncDb.SyncStatus = taskCurrentSyncStatus; } else { outlookSyncDb = new CRMOutlookSyncDb() { EntityID = tour.Id, SyncStatus = taskCurrentSyncStatus, LastSyncDate = tour.LastUpdatedOn, LastSyncedBy = tour.LastUpdatedBy, EntityType = (byte)AppModules.ContactTours, OutlookKey = string.Empty }; db.Entry <CRMOutlookSyncDb>(outlookSyncDb).State = System.Data.Entity.EntityState.Added; } db.SaveChanges(); } }
/// <summary> /// Oppertunities the pipelinefunnel chart details. /// </summary> /// <param name="accountID">The account identifier.</param> /// <param name="userID">The user identifier.</param> /// <param name="isAccountAdmin">if set to <c>true</c> [is account admin].</param> /// <param name="startDate">The start date.</param> /// <param name="endDate">The end date.</param> /// <returns></returns> public IEnumerable <DashboardPieChartDetails> OppertunityPipelinefunnelChartDetails(int accountID, int[] userIds, bool isAccountAdmin, DateTime startDate, DateTime endDate) { using (var db = ObjectContextFactory.Create()) { Logger.Current.Informational("Created the procedure name to get the OppertunitypipelineChartDetails for Dashboard "); var procedureName = "[dbo].[GET_Account_Opportunity_Pipeline_FunnelChart]"; Logger.Current.Informational("Created the parametes for the procedure"); var parms = new List <SqlParameter> { new SqlParameter { ParameterName = "@AccountID", Value = accountID }, new SqlParameter { ParameterName = "@FromDate", Value = startDate.Date }, new SqlParameter { ParameterName = "@ToDate ", Value = endDate.Date.AddDays(1) }, new SqlParameter { ParameterName = "@IsAdmin", Value = isAccountAdmin }, new SqlParameter { ParameterName = "@OwnerID", Value = string.Join(",", userIds) }, }; // var lstcontacts = context.ExecuteStoredProcedure<int>(procedureName, parms); return(db.ExecuteStoredProcedure <DashboardPieChartDetails>(procedureName, parms)); } }
/// <summary> /// Tours the contacts count. /// </summary> /// <param name="tourId">The tour identifier.</param> /// <returns></returns> public int TourContactsCount(int tourId) { var db = ObjectContextFactory.Create(); int tourContactsCount = db.ContactTours.Where(a => a.TourID == tourId).Select(a => a.Contact).Count(); return(tourContactsCount); }
public OpportunityTableType InsertOpportunity(OpportunityTableType opportunity) { IEnumerable <Image> images = new List <Image>(); IEnumerable <OpportunityTableType> opportunities = new List <OpportunityTableType>() { opportunity }; if (opportunity.OpportunityImage != null) { images = new List <Image>() { opportunity.OpportunityImage } } ; using (var db = ObjectContextFactory.Create()) { db.QueryStoredProc("dbo.SaveOpportunity", (reader) => { opportunity.OpportunityID = reader.Read <int>().FirstOrDefault(); }, new { opportunity = opportunities.AsTableValuedParameter("dbo.OpportunityTableType", new string[] { "OpportunityID", "OpportunityName", "Potential", "StageID", "ExpectedClosingDate", "Description", "Owner", "AccountID", "CreatedBy", "CreatedOn", "LastModifiedBy", "LastModifiedOn", "IsDeleted", "OpportunityType", "ProductType", "Address", "ImageID" }), image = images.AsTableValuedParameter("dbo.ImageType", new string[] { "ImageID", "FriendlyName", "StorageName", "OriginalName", "CreatedBy", "CreatedDate", "CategoryId", "AccountID" }), }); return(opportunity); } }
/// <summary> /// Tourses the by type bar chart details. /// </summary> /// <param name="accountID">The account identifier.</param> /// <param name="userID">The user identifier.</param> /// <param name="isAccountAdmin">if set to <c>true</c> [is account admin].</param> /// <param name="fromDate">From date.</param> /// <param name="toDate">To date.</param> /// <returns></returns> public IEnumerable <DashboardBarChart> ToursByTypeBarChartDetails(int accountID, int userID, bool isAccountAdmin, DateTime fromDate, DateTime toDate) { using (var db = ObjectContextFactory.Create()) { Logger.Current.Informational("Created the procedure name to get the ToursByLeadsourcelist for Dashboard "); var procedureName = "[dbo].[GET_Account_Traffic_Types_BarChart]"; Logger.Current.Informational("Created the parametes for the procedure"); var parms = new List <SqlParameter> { new SqlParameter { ParameterName = "@AccountID", Value = accountID }, new SqlParameter { ParameterName = "@FromDate", Value = fromDate.Date }, new SqlParameter { ParameterName = "@ToDate ", Value = toDate.Date }, new SqlParameter { ParameterName = "@IsAdmin", Value = isAccountAdmin }, new SqlParameter { ParameterName = "@OwnerID", Value = userID }, }; // var lstcontacts = context.ExecuteStoredProcedure<int>(procedureName, parms); return(db.ExecuteStoredProcedure <DashboardBarChart>(procedureName, parms)); } }
/// <summary> /// Get All Opportunities With Buyers /// </summary> /// <param name="accountId"></param> /// <param name="pageNumber"></param> /// <param name="pageSize"></param> /// <param name="query"></param> /// <param name="sortField"></param> /// <param name="direction"></param> /// <returns></returns> public IEnumerable <Opportunity> GetOpportunitiesWithBuyersList(int accountId, int pageNumber, int pageSize, string query, string sortField, int[] userIds, DateTime?startDate, DateTime?endDate, ListSortDirection direction = ListSortDirection.Descending) { using (var db = ObjectContextFactory.Create()) { List <Opportunity> Opportunities = new List <Opportunity>(); db.QueryStoredProc("[dbo].[Get_Opportunities_List]", (reader) => { Opportunities = reader.Read <Opportunity>().ToList(); }, new { AccountId = accountId, pageNumber = pageNumber, pageSize = pageSize, Query = query, SortField = sortField, Users = userIds.AsTableValuedParameter("dbo.Contact_List"), StartDate = startDate, EndDate = endDate, SortDirection = direction == ListSortDirection.Ascending ? "ASC" : "DESC" }); return(Opportunities); } }
/// <summary> /// Gets the image domains count. /// </summary> /// <returns></returns> public byte GetImageDomainsCount() { var db = ObjectContextFactory.Create(); byte imageDomainsCount = (byte)db.ImageDomains.Count(); return(imageDomainsCount); }
public bool IsDuplicateContactRelationship(ContactRelationship contactRelationship) { var db = ObjectContextFactory.Create(); int relationcount = 0; try { if (contactRelationship.Id == 0) { IQueryable <ContactRelationshipDb> contactRelation = db.ContactRelationshipMap.Where(c => c.ContactID == contactRelationship.ContactId && c.RelatedContactID == contactRelationship.RelatedContactID && c.RelationshipType == contactRelationship.RelationshipTypeID); relationcount = contactRelation.Count(); } else { IQueryable <ContactRelationshipDb> contactRelation = db.ContactRelationshipMap.Where(c => c.ContactID == contactRelationship.ContactId && c.RelatedContactID == contactRelationship.RelatedContactID && c.RelationshipType == contactRelationship.RelationshipTypeID && c.ContactRelationshipMapID != contactRelationship.Id); relationcount = contactRelation.Count(); } return(relationcount > 0); } catch (Exception ex) { Logger.Current.Error("Exception occurred while getting ontactRelations.", ex); return(true); } }
/// <summary> /// Gets the active image domains. /// </summary> /// <returns></returns> public IEnumerable <ImageDomain> GetActiveImageDomains() { var db = ObjectContextFactory.Create(); var imageDomainsDb = db.ImageDomains.ToList(); return(Mapper.Map <IEnumerable <ImageDomainsDb>, IEnumerable <ImageDomain> >(imageDomainsDb)); }
/// <summary> /// Gets the API key by identifier. /// </summary> /// <param name="apiKeyID">The API key identifier.</param> /// <returns></returns> public ThirdPartyClient GetApiKeyByID(string apiKeyID) { var db = ObjectContextFactory.Create(); var apikeyDB = db.ThirdPartyClients.FirstOrDefault(l => l.ID == apiKeyID); return(Mapper.Map <ThirdPartyClientsDb, ThirdPartyClient>(apikeyDB)); }
/// <summary> /// Gets the user modules. /// </summary> /// <param name="userId">The user identifier.</param> /// <param name="moduleId">The module identifier.</param> /// <returns></returns> public IEnumerable <int> GetUserModules(int userId, int moduleId) { var modules = ObjectContextFactory.Create().UserActivitiesLog .Where(u => u.UserID == userId && u.ModuleID == moduleId && u.UserActivityID == 1).Select(o => (int)o.ModuleID).ToList(); return(modules); }
public bool IsCommunityExists(string CommunityNumber, LeadAdapterTypes leadAdapterType, int accountId) { var db = ObjectContextFactory.Create(); bool isExists = db.LeadAdapters.Where(la => la.CommunityNumber.Contains(CommunityNumber) && la.IsDelete == false && la.LeadAdapterTypeID == (byte)leadAdapterType && la.AccountID == accountId).Count() > 0; return(isExists); }