public static PointAccount GetPointAccount(int pointAccountID) { PointAccount pointAccount = null; using (var context = Exigo.Sql()) { string sqlProcedure = string.Format("GetPointAccounts"); pointAccount = context.Query <PointAccount>(sqlProcedure).ToList().Where(c => c.PointAccountID == pointAccountID).FirstOrDefault(); context.Close(); } if (pointAccount == null) { return(null); } return((ExigoService.PointAccount)pointAccount); }
public static void SendSMS(SendSMSRequest request) { // Setup our request var webserviceRequest = new Common.Api.ExigoWebService.SendSmsRequest { CustomerID = request.CustomerID, Message = request.Message }; if (request.Phone.IsNotNullOrEmpty()) { webserviceRequest.Phone = request.Phone; } // Send the request to the web service var response = Exigo.WebService().SendSms(webserviceRequest); }
public static bool IsValidAutoOrderID(int customerID, int autoOrderID, bool includeCancelledAutoOrders = false) { // Get the autoorder var context = Exigo.OData(); var query = context.AutoOrders .Where(c => c.CustomerID == customerID) .Where(c => c.AutoOrderID == autoOrderID); // Only pull active auto orders if applicable if (!includeCancelledAutoOrders) { query = query.Where(c => c.AutoOrderStatusID == 1); } var autoOrder = query.FirstOrDefault(); return(autoOrder != null); }
public static void SubscribeToCustomerCalendar(int customerID, Guid calendarID) { // Check to ensure that the requested calendar exists var calendar = GetCalendars(new GetCalendarsRequest { CalendarIDs = new List <Guid>() { calendarID } }).FirstOrDefault(); if (calendar == null) { return; } // Next, ensure the customer is not subscribing to their own calendar if (calendar.CustomerID == customerID) { return; } // Next, check to ensure the provided customer is not already subscribed to this calendar var existingSubscription = GetCustomerCalendarSubscriptions(customerID) .Where(c => c.CalendarID == calendarID) .FirstOrDefault(); if (existingSubscription != null) { return; } // If we got here, we can go ahead and subscribe var context = Exigo.ODataCalendars(); var newSubscription = new CalendarContext.CalendarSubscription(); newSubscription.CustomerID = customerID; newSubscription.CalendarID = calendarID; context.AddToCalendarSubscriptions(newSubscription); context.SaveChanges(); ClearCache("GetCalendars", customerID); }
public static IEnumerable <T> GetEnrollerTree <T>(GetTreeRequest request) where T : ITreeNode { // Get the nodes var nodes = new List <T>(); var rowcount = 50; var lastResultCount = rowcount; var callsMade = 0; while (lastResultCount == rowcount) { var query = Exigo.OData().EnrollerTree .Where(c => c.TopCustomerID == request.TopCustomerID); // Filter by level var levels = (request.Levels != 0) ? request.Levels : 10; query = query.Where(c => c.Level <= levels); // Get the data var results = query .OrderBy(c => c.IndentedSort) .Skip(callsMade * rowcount) .Take(rowcount) .Select(c => c) .ToList(); results.ForEach(c => { var node = (T)Activator.CreateInstance(typeof(T)); node.CustomerID = c.CustomerID; node.ParentCustomerID = c.EnrollerID; node.Level = c.Level; node.PlacementID = 0; node.IndentedSort = c.IndentedSort; node.ChildNodeCount = c.ChildCount; nodes.Add(node); }); callsMade++; lastResultCount = results.Count; } return(nodes); }
public static bool IsCustomerInBinaryDownline(int topCustomerID, int customerID) { //if (customerID == topCustomerID) return true; //return Exigo.OData().BinaryTree // .Where(c => c.TopCustomerID == topCustomerID) // .Where(c => c.CustomerID == customerID) // .Count() != 0; List <GetEnrollerTree> nodes = new List <GetEnrollerTree>(); using (var context = Exigo.Sql()) { string sqlProcedure = string.Format(@"IsDownlineBinaryTree {0},{1}", topCustomerID, customerID); nodes = context.Query <GetEnrollerTree>(sqlProcedure).ToList(); } return(nodes.Count != 0); }
public static bool IsTaxIDAvailable(string taxID, int taxIDType = 0, int customerID = 0) { if (taxIDType == 0) { taxIDType = (int)TaxIDType.SSN; } var request = new IsTaxIDAvailableValidateRequest { TaxID = taxID, TaxTypeID = taxIDType }; if (customerID > 0) { request.ExcludeCustomerID = customerID; } var validResponse = Exigo.WebService().Validate(request); return(validResponse.IsValid); }
public static CustomerSubscription GetCustomerSubscription(int customerID, int subscriptionID) { //var subscription = Exigo.OData().CustomerSubscriptions.Expand("Subscription,SubscriptionStatus") // .Where(c => c.CustomerID == customerID) // .Where(c => c.SubscriptionID == subscriptionID) // .FirstOrDefault(); Common.Api.ExigoOData.CustomerSubscription subscription = null; using (var context = Exigo.Sql()) { string sqlProcedure = string.Format("GetCustomerSubscriptions"); subscription = context.Query <Common.Api.ExigoOData.CustomerSubscription>(sqlProcedure).ToList().Where(c => c.CustomerID == customerID).Where(c => c.SubscriptionID == subscriptionID).FirstOrDefault(); } if (subscription == null) { return(null); } return((ExigoService.CustomerSubscription)subscription); }
public byte[] GetCustomerAvatar(int customerID, AvatarType type, bool cache = true) { var bytes = new byte[0]; // Try to return the image found at the avatar path bytes = GlobalUtilities.GetExternalImageBytes(GlobalUtilities.GetCustomerAvatarUrl(customerID, type, cache)); // If we didn't find anything there, convert the default image (which is Base64) to a byte array. // We'll use that instead if (bytes == null || bytes.Length == 0) { Exigo.Images().SetCustomerAvatar(customerID, Convert.FromBase64String(GlobalSettings.Avatars.DefaultAvatarAsBase64)); return(GetCustomerAvatar(customerID, type, cache)); } return(bytes); }
public static void UpdateCustomerAutoOrderShippingAddress(int customerID, int autoOrderID, ShippingAddress address) { //var context = Exigo.OData(); // Get the autoorder //var autoOrder = context.AutoOrders // .Where(c => c.CustomerID == customerID) // .Where(c => c.AutoOrderID == autoOrderID) // .FirstOrDefault(); //get auto orders from sql using following stored procedures AutoOrder autoOrder = new AutoOrder(); using (var Context = Exigo.Sql()) { string SPGetCustomerAutoOrders = string.Format("GetCustomerAutoOrders {0},{1}", customerID, autoOrderID); autoOrder = Context.Query <AutoOrder>(SPGetCustomerAutoOrders).FirstOrDefault(); } if (autoOrder == null) { return; } // Re-create the autoorder var request = GetCreateOverridenAutoOrderRequest(customerID, autoOrderID); request.FirstName = address.FirstName; request.LastName = address.LastName; request.Company = address.Company; request.Address1 = address.Address1; request.Address2 = address.Address2; request.City = address.City; request.State = address.State; request.Zip = address.Zip; request.Country = address.Country; request.Email = address.Email; request.Phone = address.Phone; // Update the autoorder var response = Exigo.WebService().CreateAutoOrder(request); }
public bool SaveImage(string path, string filename, byte[] bytes) { try { Exigo.WebService().SetImageFile(new Common.Api.ExigoWebService.SetImageFileRequest { Name = filename, Path = path, ImageData = bytes }); } catch (Exception ex) { return(false); } // If we got here, everything should be good return(true); }
public static T Get <T>(string description) where T : IPropertyBag { // Attempt to load the bag from the cookie var cookie = HttpContext.Current.Request.Cookies[description]; if (cookie == null) { return(Create <T>(description)); } // Get the session from Exigo var sessionData = Exigo.WebService().GetSession(new GetSessionRequest() { SessionID = cookie.Value }).SessionData; if (string.IsNullOrEmpty(sessionData)) { return(Create <T>(description)); } try { // Deserialize the session data and get our bag. dynamic bag = Deserialize <T>(sessionData); // If the customer ID in the bag doesn't match the current customer ID, stop here. if (!bag.IsValid()) { return(Create <T>(description)); } // If we got here, we have a valid property bag. Populate it into the current object. return(bag); } catch { return(Create <T>(description)); } }
//Only Used for the Dashboard Card... Really all this does is return the customerID's then lets the customer model pull the avatar URL. public static List <Customer> GetNewestDistributors(GetNewestDistributorsRequest request) { var newestDistributors = new List <Customer>(); var customerTypes = request.CustomerTypes; var customerStatuses = request.CustomerStatuses; using (var context = Exigo.Sql()) { newestDistributors = context.Query <Customer>(@" SELECT TOP (@RowCount) un.DownlineCustomerID , c.CustomerID , c.FirstName , c.MiddleName , c.LastName , c.CreatedDate FROM UniLevelDownline un LEFT JOIN Customers c ON un.CustomerID = c.CustomerID WHERE un.DownlineCustomerID = @CustomerID AND c.CustomerID <> @CustomerID AND un.Level <= @Level AND c.CustomerTypeID IN @CustomerTypes AND c.CustomerStatusID IN @CustomerStatuses AND c.CreatedDate >= CASE WHEN @days > 0 THEN getdate()-@Days ELSE c.CreatedDate END ORDER BY CreatedDate ", new { CustomerID = request.CustomerID, Level = request.MaxLevel, RowCount = request.RowCount, CustomerTypes = customerTypes, CustomerStatuses = customerStatuses, Days = request.Days }).ToList(); } return(newestDistributors); }
public static bool SessionExists <T>(string description) where T : IPropertyBag { var cookie = HttpContext.Current.Request.Cookies[description]; if (null != cookie) { // Get the session from Exigo var sessionData = Exigo.WebService().GetSession(new GetSessionRequest() { SessionID = cookie.Value }).SessionData; if (!string.IsNullOrWhiteSpace(sessionData)) { return(true); } } return(false); }
public static ExigoService.Calendar CreateCalendar(CreateCalendarRequest request) { // Create the calendar var calendar = new CalendarContext.Calendar(); calendar.CalendarID = Guid.NewGuid(); calendar.CustomerID = request.CustomerID; calendar.Description = request.Description; calendar.CalendarTypeID = 1; calendar.CreatedDate = DateTime.Now; // Save the calendar var context = Exigo.ODataCalendars(); context.AddToCalendars(calendar); //TODO: Calendar: Commented out because of error -- context.SaveChanges(); // Return the new calendar return((ExigoService.Calendar)calendar); }
public static void UpdateCustomerAutoOrderRunDate(int customerID, int autoOrderID, DateTime rundate, FrequencyType frequency) { // Get the autoorder var autoOrder = Exigo.GetCustomerAutoOrder(customerID, autoOrderID); if (autoOrder == null) { return; } // Re-create the autoorder var request = GetCreateOverridenAutoOrderRequest(customerID, autoOrderID); request.StartDate = rundate; request.Frequency = FrequencyType.Monthly; // Update the autoorder var response = Exigo.WebService().CreateAutoOrder(request); }
public static Subscription GetSubscription(int subscriptionID) { //var subscription = Exigo.OData().Subscriptions // .Where(c => c.SubscriptionID == subscriptionID) // .FirstOrDefault(); Subscription subscription = null; using (var context = Exigo.Sql()) { string sqlProcedure = string.Format("GetSubscriptions"); subscription = context.Query <Subscription>(sqlProcedure).ToList().Where(c => c.SubscriptionID == subscriptionID).FirstOrDefault(); } if (subscription == null) { return(null); } return((ExigoService.Subscription)subscription); }
public static CompanyNewsItem GetCompanyNewsItem(GetCompanyNewsItemRequest request) { var api = Exigo.WebService(); CompanyNewsItem response; var newsItemResponse = (api.GetCompanyNewsItem(new Common.Api.ExigoWebService.GetCompanyNewsItemRequest { NewsID = request.NewsID })); //Convert to our model CompanyNewsItem newsItem = (CompanyNewsItem)newsItemResponse; //Only respond if the article is flagged to backoffice visbility if (newsItem.WebSettings == NewsWebSettings.AccessAvailable) { response = newsItem; } return(newsItem); }
public bool SaveCustomerAvatarToHistory(int customerID, byte[] bytes) { // Define the customer profile settings var path = "customers/{0}/avatars".FormatWith(customerID); var filename = "{0}.png".FormatWith(Path.GetRandomFileName()); var maxWidth = 300; var maxHeight = 300; // Resize the image var resizedBytes = GlobalUtilities.ResizeImage(bytes, maxWidth, maxHeight); // Determine if this avatar has already been uploaded before by looking at it's size var isUnique = Exigo.OData().ImageFiles .Where(c => c.Path == path) .Where(c => c.Size == resizedBytes.Length) .Count() == 0; // Save the image return((isUnique) ? SaveImage(path, filename, resizedBytes) : false); }
public static Subscription GetSubscription(int subscriptionID) { var subscriptions = new Subscription(); using (var context = Exigo.Sql()) { subscriptions = context.Query <Subscription>(@" SELECT SubscriptionID , SubscriptionDescription FROM Subscriptions WHERE SubscriptionID = @SubscriptionID ", new { SubscriptionID = subscriptionID }).FirstOrDefault(); } return(subscriptions); }
public static void ModifyCustomerAutoOrder(int customerID, int autoOrderID, AutoOrderStatusType status) { // Get the autoorder var context = Exigo.OData(); var autoOrder = context.AutoOrders .Where(c => c.CustomerID == customerID) .Where(c => c.AutoOrderID == autoOrderID); if (autoOrder == null) { return; } // Change the autoorder status var response = Exigo.WebService().ChangeAutoOrderStatus(new ChangeAutoOrderStatusRequest { AutoOrderID = autoOrderID, AutoOrderStatus = status }); }
public static bool IsWebAliasAvailable(int customerID, string webalias) { // Get the current webalias to see if it matches what we passed. If so, it's still valid. var currentWebAlias = Exigo.GetCustomerSite(customerID).WebAlias; if (currentWebAlias == null) { if (webalias.Equals(currentWebAlias, StringComparison.InvariantCultureIgnoreCase)) { return(true); } } // Validate the web alias return(Exigo.WebService().Validate(new IsLoginNameAvailableValidateRequest { LoginName = webalias }).IsValid); }
//This is currently being used for the Dashboard Widget //public static VolumeCollection GetCustomerVolumes2(GetCustomerVolumesRequest request) //{ // // Establish the query // var query = Exigo.OData().PeriodVolumes // .Where(c => c.CustomerID == request.CustomerID) // .Where(c => c.PeriodTypeID == PeriodTypes.Monthly) // .Where(c => c.Period.IsCurrentPeriod); // //.Where(c => c.Period.StartDate <= DateTime.Now); // // Fetch the data // var data = query.Select(c => new PeriodVolume() // { // CustomerID = c.CustomerID, // PeriodID = c.PeriodID, // Period = c.Period, // PeriodTypeID = c.PeriodTypeID, // Volume1 = c.Volume1, // Volume2 = c.Volume2, // Volume3 = c.Volume3, // Volume9 = c.Volume9, // Volume10 = c.Volume10, // Volume12 = c.Volume12, // Volume13 = c.Volume13, // Volume14 = c.Volume14 // }).FirstOrDefault(); // return (VolumeCollection)data; //} //This uses an api call rather then OData public static VolumeCollection GetCustomerVolumes3(GetCustomerVolumesRequest request) { var vc = new VolumeCollection(); //var api = Exigo.WebService(); ////Create Request //var volumeRequest = new GetVolumesRequest //{ // CustomerID = request.CustomerID, // PeriodType = request.PeriodTypeID //}; ////Get Response //var response = api.GetVolumes(volumeRequest).Volumes.FirstOrDefault(); //// here api call to SQl Server call VolumeResponse response = new VolumeResponse(); using (var context = Exigo.Sql()) { string sqlQuery = string.Format(@"GetCustomerVolumes3 {0},{1}", request.CustomerID, request.PeriodTypeID); response = context.Query <VolumeResponse>(sqlQuery).FirstOrDefault(); } if (response != null) { vc.CustomerID = response.CustomerID; vc.PayableAsRank.RankID = response.RankID; vc.Period.PeriodDescription = response.PeriodDescription; vc.Volume1 = response.Volume1; vc.Volume2 = response.Volume2; vc.Volume3 = response.Volume3; vc.Volume9 = response.Volume9; vc.Volume10 = response.Volume10; vc.Volume12 = response.Volume12; vc.Volume13 = response.Volume13; vc.Volume14 = response.Volume14; vc.PaidAsRank.RankID = response.PaidRankID; } ; return(vc); }
public static List <CompanyNewsItem> GetCompanyNews(GetCompanyNewsRequest request) { var api = Exigo.WebService(); CompanyNewsResponse[] newsResponse; var newsItems = new List <CompanyNewsItem>(); foreach (var department in request.NewsDepartments) { newsResponse = (api.GetCompanyNews(new Common.Api.ExigoWebService.GetCompanyNewsRequest { DepartmentType = department }).CompanyNews); //Convert to our model newsItems = newsResponse.Select(apiItem => (CompanyNewsItem)apiItem) .Where(newsItem => (NewsWebSettings)newsItem.WebSettings == NewsWebSettings.AccessAvailable).ToList(); //and filter out anything not flagged as available in the backoffice // If they requested the content, then loop through all the articles and add the content to each news item var tasks = new List <Task>(); foreach (var item in newsItems) { tasks.Add(Task.Factory.StartNew(() => { var newsItemResponse = (api.GetCompanyNewsItem(new Common.Api.ExigoWebService.GetCompanyNewsItemRequest { NewsID = item.NewsID })); //Add the content to the item item.Content = newsItemResponse.Content; })); Task.WaitAll(tasks.ToArray()); tasks.Clear(); } } return(newsItems); }
public static VerifyAddressResponse VerifyAddress(Address address) { var result = new VerifyAddressResponse(); result.OriginalAddress = address; result.IsValid = false; try { if (address.Country.ToUpper() == "US" && address.IsComplete) { var verifiedAddress = Exigo.WebService().VerifyAddress(new VerifyAddressRequest { Address = address.AddressDisplay, City = address.City, State = address.State, Zip = address.Zip, Country = address.Country }); result.VerifiedAddress = new Address() { AddressType = address.AddressType, Address1 = verifiedAddress.Address, Address2 = string.Empty, City = verifiedAddress.City, State = verifiedAddress.State, Zip = verifiedAddress.Zip, Country = verifiedAddress.Country }; result.IsValid = true; } } catch { return(result); } return(result); }
public static IEnumerable <Region> GetRegions(string CountryCode) { dynamic regions = new List <Region>(); using (var context = Exigo.Sql()) { regions = context.Query <Region>(@" SELECT CountryCode ,RegionCode ,RegionName = RegionDescription FROM CountryRegions WHERE CountryCode = @countryCode ORDER BY RegionCode ", new { countryCode = CountryCode }).AsEnumerable(); } return(regions); }
public static CustomerSite GetCustomerSiteRealTime(int customerID) { var site = new CustomerSite(); // The GetCustomerSite method currently throws an exception if no customer site record exists for the customer // We will set the site for this customer in the Catch and get the site again if this is the case try { var apiCustomerSite = Exigo.WebService().GetCustomerSite(new GetCustomerSiteRequest { CustomerID = customerID }); site = (CustomerSite)apiCustomerSite; } catch (Exception) { // Do Nothing } return(site); }
public static void ModifyResourceItem(ResourceItem item) { using (var context = Exigo.Sql()) { context.Execute(@" UPDATE ExigoWebContext.ResourceItems SET TypeID = @typeid, Title = @title, Url = @url, UrlThumbnail = @urlthumbnail, CreatedDate = @createddate, PostDate = @postdate, ItemDescription = @description, StatusID = @statusid, Language = @language WHERE ItemID = @itemid ", new { typeid = item.TypeID, title = item.Title, url = item.Url, urlthumbnail = item.UrlThumbnail, createddate = item.CreatedDate, postdate = item.PostDate, description = item.ItemDescription, statusid = item.StatusID, itemid = item.ItemID, language = item.Language }); } }
public static bool InEBPeriod(int customerId) { //ExigoCustomer exigoCustomer = Exigo.OData().Customers.Where(c => (c.CustomerID == ambassadorId)).FirstOrDefault(); Customer exigoCustomer = Exigo.GetCustomer(customerId); if (exigoCustomer == null) { return(false); } if (!exigoCustomer.Date1.HasValue) { return(false); } DateTime ambassadorStartDate = exigoCustomer.Date1.Value; bool isFirst100Days = IsFirst100DaysOfBecomingSa(DateTime.Now, ambassadorStartDate); return(isFirst100Days); }
public static bool IsLoginNameAvailable(string loginname, int customerID = 0) { if (customerID > 0) { // Get the current login name to see if it matches what we passed. If so, it's still valid. var currentLoginName = Exigo.GetCustomer(customerID).LoginName; if (loginname.Equals(currentLoginName, StringComparison.InvariantCultureIgnoreCase)) { return(true); } } // Validate the login name // cannot use SQL due to delay in update to replicated database var apiCustomer = Exigo.WebService().GetCustomers(new GetCustomersRequest() { LoginName = loginname }).Customers.FirstOrDefault(); return(apiCustomer == null); }