public ActionResult Index()
        {
            var model = new AccountOverviewViewModel();

            var customer = Customers.GetCustomer(Identity.Current.CustomerID);
            var website  = ExigoDAL.GetCustomerSiteRealTime(Identity.Current.CustomerID);
            var socialNetworksResponse = ExigoDAL.GetCustomerSocialNetwork(Identity.Current.CustomerID);

            //var socialNetworksResponse = Exigo.WebService().GetCustomerSocialNetworks(new GetCustomerSocialNetworksRequest()
            //{
            //    CustomerID = Identity.Current.CustomerID
            //});

            foreach (var network in socialNetworksResponse)
            {
                switch (network.SocialNetworkID)
                {
                case (int)SocialNetworks.Facebook: model.Facebook = network.Url; break;

                case (int)SocialNetworks.Twitter: model.Twitter = network.Url; break;

                case (int)SocialNetworks.YouTube: model.YouTube = network.Url; break;

                case (int)SocialNetworks.Blog: model.Blog = network.Url; break;

                case (int)SocialNetworks.GooglePlus: model.GooglePlus = network.Url; break;

                case (int)SocialNetworks.LinkedIn: model.LinkedIn = network.Url; break;

                case (int)SocialNetworks.MySpace: model.MySpace = network.Url; break;

                case (int)SocialNetworks.Pinterest: model.Pinterest = network.Url; break;

                case (int)SocialNetworks.Instagram: model.Instagram = network.Url; break;
                }
            }

            model.Customer = customer;

            model.WebAlias = website.WebAlias;

            model.CustomerSite.FirstName        = website.FirstName;
            model.CustomerSite.LastName         = website.LastName;
            model.CustomerSite.Email            = website.Email;
            model.CustomerSite.PrimaryPhone     = website.PrimaryPhone;
            model.CustomerSite.SecondaryPhone   = website.SecondaryPhone;
            model.CustomerSite.Fax              = website.Fax;
            model.CustomerSite.Notes1           = website.Notes1;
            model.CustomerSite.Notes2           = website.Notes2;
            model.CustomerSite.Notes3           = website.Notes3;
            model.CustomerSite.Notes4           = website.Notes4;
            model.CustomerSite.Address.Address1 = website.Address.Address1;
            model.CustomerSite.Address.Address2 = website.Address.Address2;
            model.CustomerSite.Address.Country  = website.Address.Country;
            model.CustomerSite.Address.City     = website.Address.City;
            model.CustomerSite.Address.State    = website.Address.State;
            model.CustomerSite.Address.Zip      = website.Address.Zip;

            return(View(model));
        }
Exemple #2
0
        public ActionResult AutoOrdersList(int id, KendoGridRequest request = null)
        {
            if (Request.HttpMethod.ToUpper() == "GET")
            {
                return(PartialView("Partials/AutoOrdersList"));
            }

            using (var context = new KendoGridDataContext(ExigoDAL.Sql()))
            {
                return(context.Query <OrdersViewModel>(request, @"
                        Select ao.AutoOrderID
                            , CountryCode = ao.Country
                            , ao.CurrencyCode
                            , ao.LastRunDate
                            , ao.NextRunDate
                            , ao.SubTotal
                            , ao.BusinessVolumeTotal
                            , ao.CommissionableVolumeTotal                        
                        From AutoOrders ao                        
                        Where ao.CustomerID = @customerid
                            and ao.AutoOrderStatusID = @autoorderstatus
                    ", new
                {
                    customerid = id,
                    autoorderstatus = 0
                }));
            }
        }
Exemple #3
0
        public ActionResult PopoverSummary(int id)
        {
            var model = new ProfileViewModel();

            if (id == 0)
            {
                id = Identity.Current.CustomerID;
            }

            model.Customer = Customers.GetCustomer(id);

            if (model.Customer.RankID == 0)
            {
                var volumes = ExigoDAL.GetCustomerVolumes(new GetCustomerVolumesRequest
                {
                    CustomerID   = id,
                    PeriodTypeID = PeriodTypes.Default
                });

                model.Customer.RankID = volumes.PayableAsRank.RankID;
            }

            if (Request.IsAjaxRequest())
            {
                return(PartialView("Partials/_ProfilePopover", model));
            }
            else
            {
                return(View(model));
            }
        }
Exemple #4
0
        public ActionResult OrdersList(int id, KendoGridRequest request = null)
        {
            if (Request.HttpMethod.ToUpper() == "GET")
            {
                return(PartialView("Partials/OrdersList"));
            }


            // Establish the query
            using (var context = new KendoGridDataContext(ExigoDAL.Sql()))
            {
                return(context.Query <OrdersViewModel>(request, @"
                        Select 
                              o.OrderDate
                            , CountryCode = o.Country
                            , o.CurrencyCode
                            , o.OrderID
                            , o.SubTotal
                            , o.BusinessVolumeTotal
                            , o.CommissionableVolumeTotal
                        FROM Orders o
                        WHERE o.CustomerID = @customerid
                            AND o.OrderStatusID >= @orderstatus",
                                                       new
                {
                    customerid = id,
                    orderstatus = OrderStatuses.Accepted
                }));
            }
        }
        public JsonNetResult GetLastAcceptedCommissions()
        {
            var customerID = Identity.Current.CustomerID;

            try
            {
                var lastAcceptedCommissions = Cache.Get("Dashboard_LastAcceptedCommissionsCard_{0}".FormatWith(customerID),
                                                        TimeSpan.FromMinutes(WidgetCacheTimeout),
                                                        () =>
                                                        ExigoDAL.GetDashboardCommission(customerID, PeriodTypes.Default)
                                                        );


                var html = this.RenderPartialViewToString("Cards/LastAccepted", lastAcceptedCommissions);

                return(new JsonNetResult(new
                {
                    success = true,
                    html
                }));
            }
            catch (Exception ex)
            {
                return(new JsonNetResult(new
                {
                    success = false,
                    message = ex.Message
                }));
            }
        }
        public JsonNetResult GetRecentActivity()
        {
            var customerID = Identity.Current.CustomerID;

            try
            {
                var recentActivities = Cache.Get("Dashboard_RecentActivity_{0}".FormatWith(customerID),
                                                 TimeSpan.FromMinutes(WidgetCacheTimeout),
                                                 () =>
                                                 ExigoDAL.GetCustomerRecentActivity(new GetCustomerRecentActivityRequest
                {
                    CustomerID = customerID,
                    Page       = 1,
                    RowCount   = 50
                }).Tokenize()
                                                 );


                var html = this.RenderPartialViewToString("Cards/RecentActivity", recentActivities);

                return(new JsonNetResult(new
                {
                    success = true,
                    html
                }));
            }
            catch (Exception ex)
            {
                return(new JsonNetResult(new
                {
                    success = false,
                    message = ex.Message
                }));
            }
        }
        public JsonNetResult UpdateWebsitePhoneNumbers(CustomerSite customersite)
        {
            var testa = ExigoDAL.GetCustomerSite(Identity.Current.CustomerID);

            ExigoDAL.UpdateCustomerSite(new CustomerSite
            {
                CustomerID     = Identity.Current.CustomerID,
                PrimaryPhone   = customersite.PrimaryPhone,
                SecondaryPhone = customersite.SecondaryPhone
            });

            var testb = ExigoDAL.GetCustomerSite(Identity.Current.CustomerID);

            var html = string.Format(@"
                " + Resources.Common.Primary + @": <strong>{0}</strong><br />
                " + Resources.Common.Secondary + @": <strong>{1}</strong>
                ", customersite.PrimaryPhone, customersite.SecondaryPhone);

            return(new JsonNetResult(new
            {
                success = true,
                action = "UpdateWebsitePhoneNumbers",
                html = html
            }));
        }
Exemple #8
0
        public Party UpdateParty(ExigoService.CreatePartyRequest request)
        {
            if (request.PartyID == 0)
            {
                return(null);
            }

            // Create the party
            var context = ExigoDAL.WebService();


            var eventStartDate = new DateTime(request.EventStartDate.Year, request.EventStartDate.Month, request.EventStartDate.Day, request.EventStartTime.Hour, request.EventStartTime.Minute, 0);
            var eventEndDate   = new DateTime(request.EventEndDate.Year, request.EventEndDate.Month, request.EventEndDate.Day, request.EventEndTime.Hour, request.EventEndTime.Minute, 0);

            var apirequest = new Common.Api.ExigoWebService.UpdatePartyRequest(request);

            apirequest.StartDate  = eventStartDate;
            apirequest.EventStart = eventStartDate;
            apirequest.CloseDate  = eventEndDate;
            apirequest.EventEnd   = eventEndDate;

            // Update the Party
            context.UpdateParty(apirequest);

            var partyID = request.PartyID;
            var party   = GetParties(new ExigoService.GetPartiesRequest {
                CustomerID = request.CustomerID, PartyID = partyID, IncludeHostessDetails = true
            }).FirstOrDefault();


            // Return the party
            return(party);
        }
        public ActionResult ResetPassword(ResetPasswordViewModel model)
        {
            try
            {
                ExigoDAL.UpdateCustomer(new UpdateCustomerRequest()
                {
                    CustomerID    = model.CustomerID,
                    LoginPassword = model.Password
                });


                var urlHelper = new UrlHelper(Request.RequestContext);
                var url       = GlobalSettings.Company.BaseBackofficeUrl + "/login";

                return(new JsonNetResult(new
                {
                    success = true,
                    url
                }));
            }
            catch (Exception ex)
            {
                return(new JsonNetResult(new
                {
                    success = false,
                    message = ex.Message
                }));
            }
        }
        public ActionResult EnrollmentComplete(string token)
        {
            var model        = new EnrollmentCompleteViewModel();
            var args         = Security.Decrypt(token);
            var hasOrder     = args["OrderID"] != null;
            var hasAutoOrder = args["AutoOrderID"] != null;

            model.CustomerID = Convert.ToInt32(args["CustomerID"]);
            if (hasOrder)
            {
                model.OrderID = Convert.ToInt32(args["OrderID"]);
                model.Order   = ExigoDAL.GetCustomerOrders(new GetCustomerOrdersRequest
                {
                    CustomerID          = model.CustomerID,
                    OrderID             = model.OrderID,
                    IncludeOrderDetails = true,
                    IncludePayments     = true
                }).FirstOrDefault();
            }
            if (hasAutoOrder)
            {
                model.AutoOrderID = Convert.ToInt32(args["AutoOrderID"]);
                try
                {
                    model.AutoOrder = ExigoDAL.GetCustomerAutoOrders(Identity.Customer.CustomerID, model.AutoOrderID).FirstOrDefault();
                }
                catch { }
            }

            return(View(model));
        }
        public int AuthenticateCustomer(int customerid)
        {
            var command    = new SqlHelper();
            var customerID = command.GetField("select CustomerID from Customers where CustomerID = {0}", customerid);

            if (customerID == null)
            {
                // If the SQL Customer call failed, we want to make sure we try the Webservice in case the person was not just created and the Sync db has not caught up yet
                try
                {
                    var getCustomerResponse = ExigoDAL.WebService().GetCustomers(new Api.ExigoWebService.GetCustomersRequest {
                        CustomerID = customerid
                    });
                    if (getCustomerResponse.Result.Status == Api.ExigoWebService.ResultStatus.Success && getCustomerResponse.Customers.Length > 0)
                    {
                        return(getCustomerResponse.Customers[0].CustomerID);
                    }
                    else
                    {
                        return(0);
                    }
                }
                catch { return(0); }
            }
            else
            {
                return((int)customerID);
            }
        }
        public ActionResult Packs()
        {
            var model = new PacksViewModel();

            if (ShoppingCart.Items.Where(c => c.Type == ShoppingCartItemType.EnrollmentPack).Count() > 0)
            {
                model.SelectedOrderItem = ShoppingCart.Items.Where(c => c.Type == ShoppingCartItemType.EnrollmentPack).FirstOrDefault();
            }

            model.CustomerTypeID = (PropertyBag.Customer != null) ? PropertyBag.Customer.CustomerTypeID : 1;

            model.OrderItems = ExigoDAL.GetItems(new ExigoService.GetItemsRequest
            {
                Configuration             = OrderPacksConfiguration,
                IncludeAllChildCategories = true,
                IncludeLongDescriptions   = true
            }).ToList();

            foreach (var item in model.OrderItems)
            {
                item.Type = ShoppingCartItemType.EnrollmentPack;
            }


            return(View(model));
        }
        public ActionResult ProductList()
        {
            var model = new EnrollmentProductListViewModel();

            model.OrderItems = ExigoDAL.GetItems(new ExigoService.GetItemsRequest
            {
                Configuration             = OrderConfiguration,
                IncludeAllChildCategories = true,
                IncludeGroupMembers       = true
            }).ToList();

            model.AutoOrderItems = model.OrderItems.Where(i => i.AllowOnAutoOrder).DeepClone();

            model.AutoOrderItems.ToList().ForEach(c => c.Type = ShoppingCartItemType.AutoOrder);

            foreach (var item in ShoppingCart.Items.Where(x => x.Type == ShoppingCartItemType.Order))
            {
                model.OrderItems.Where(w => w.ItemCode == item.ItemCode).Select(c => { c.Quantity = item.Quantity; return(c); }).ToList();
            }

            foreach (var item in ShoppingCart.Items.Where(x => x.Type == ShoppingCartItemType.AutoOrder))
            {
                model.AutoOrderItems.Where(w => w.ItemCode == item.ItemCode).Select(c => { c.Quantity = item.Quantity; return(c); }).ToList();
            }

            return(View(model));
        }
        public static CommissionPayout GetDirectDeposit()
        {
            var account = new CommissionPayout();

            try
            {
                var result = ExigoDAL.WebService().GetAccountDirectDeposit(new GetAccountDirectDepositRequest
                {
                    CustomerID = Identity.Current.CustomerID
                });

                if (result.Result.Status == ResultStatus.Success)
                {
                    account.AccountNumber = result.BankAccountNumberDisplay;
                    account.NameOnAccount = result.NameOnAccount;
                    account.BankName      = result.BankName;
                    account.RoutingNumber = result.BankRoutingNumber;

                    //account.BillingAddress.Address1 = result.BankAddress;
                    //account.BillingAddress.City = result.BankCity;
                    //account.BillingAddress.State = result.BankState;
                    //account.BillingAddress.Country = result.BankCountry;
                    //account.BillingAddress.Zip = result.BankZip;
                }
            }
            catch
            {
            }

            return(account);
        }
        public ActionResult ManageResources()
        {
            //set up the model/service and fetch data
            var model = new ResourceListViewModel();

            model.ResourceCategories  = ExigoDAL.GetResourceCategories(new GetResourceCategoriesRequest()).OrderBy(c => c.CategoryOrder);
            model.CountryAvailability = GlobalSettings.Markets.AvailableMarkets;
            model.Languages           = ExigoDAL.GetUniqueLanguages().ToList();
            model.ResourceTypes       = ExigoDAL.GetResourceTypes(new GetResourceTypeRequest()).OrderBy(rt => rt.SortOrder).ToList();
            model.CategoryTranslation = ExigoDAL.GetCategoryTranslations(new GetTranslatedCategoryRequest());
            model.Tags = ExigoDAL.GetTagsForResources(new GetTagsForResourcesRequest());

            //Create ListItems for the Market/Language DropDown
            List <SelectListItem> items = new List <SelectListItem>();

            foreach (var market in model.CountryAvailability)
            {
                SelectListItem item = new SelectListItem()
                {
                    Value    = market.Countries.FirstOrDefault(),
                    Text     = CommonResources.Countries(market.Countries.FirstOrDefault()),
                    Selected = Identity.Current.Country == market.Countries.FirstOrDefault()
                };
                items.Add(item);
            }
            model.CountryList = items;

            return(View(model));
        }
Exemple #16
0
        public IQueryable <Host> GetHosts(int customerID)
        {
            var hosts = new List <Host>();

            using (var context = ExigoDAL.Sql())
            {
                hosts = context.Query <Host>(@"
                        select 
                            CustomerID = c.CustomerID,
                            FirstName = c.FirstName,
                            LastName = c.LastName,
                            Address1 = c.MainAddress1,
                            Address2 = c.MainAddress2,
                            City = c.MainCity,
                            State = c.MainState,
                            Zip = c.MainZip,
                            Country = c.MainCountry,
                            Email = c.Email,
                            Phone = c.Phone
                        from Customers c
                        where c.CustomerID = @customerID 
                            or c.EnrollerID = @customerID
                        ", new { customerID }).ToList();
            }


            // Return the hosts
            return(hosts.AsQueryable());
        }
        public ActionResult OrderDetail(string token)
        {
            var orderID = Convert.ToInt32(Security.Decrypt(token, Identity.Customer.CustomerID));
            var model   = new GetCustomerOrdersResponse();

            ViewBag.IsSearch = true;

            model = ExigoDAL.GetCustomerOrders_SQL(new GetCustomerOrdersRequest
            {
                CustomerID          = Identity.Customer.CustomerID,
                Page                = 1,
                RowCount            = RowCount,
                LanguageID          = CurrentLanguage.LanguageID,
                IncludeOrderDetails = true,
                OrderID             = orderID,
                TotalRowCount       = 1
            });

            model.RowCount = RowCount;
            model.Page     = 1;

            model.OrderCount = 1;


            return(View("OrderList", model));
        }
        public JsonNetResult UpdateNotifications(Customer customer)
        {
            var html = string.Empty;

            try
            {
                var token = Security.Encrypt(new
                {
                    CustomerID = Identity.Customer.CustomerID,
                    Email      = customer.Email
                });

                if (customer.IsOptedIn)
                {
                    ExigoDAL.SendEmailVerification(Identity.Customer.CustomerID, customer.Email);
                    html = string.Format("{0}", Resources.Common.PendingOptedInStatus);
                }
                else
                {
                    ExigoDAL.OptOutCustomer(Identity.Customer.CustomerID);
                    html = string.Format("{0}", Resources.Common.OptedOutStatus);
                }
            }
            catch
            {
            }

            return(new JsonNetResult(new
            {
                success = true,
                action = "UpdateNotifications",
                html = html
            }));
        }
        public JsonNetResult GetCurrentCommissions()
        {
            var customerID = Identity.Current.CustomerID;

            try
            {
                var currentCommissions = Cache.Get("Dashboard_CurrentCommissionsCard_{0}".FormatWith(customerID),
                                                   TimeSpan.FromMinutes(WidgetCacheTimeout),
                                                   () =>
                                                   ExigoDAL.GetCustomerRealTimeCommissions(new GetCustomerRealTimeCommissionsRequest
                {
                    CustomerID       = customerID,
                    GetPeriodVolumes = false
                }).ToList()
                                                   );


                var html = this.RenderPartialViewToString("Cards/CurrentCommissions", currentCommissions);

                return(new JsonNetResult(new
                {
                    success = true,
                    html
                }));
            }
            catch (Exception ex)
            {
                return(new JsonNetResult(new
                {
                    success = false,
                    message = ex.Message
                }));
            }
        }
Exemple #20
0
        public static IEnumerable <SelectListItem> Countries(this HtmlHelper helper, IEnumerable <string> countryCodes, string defaultCountryCode = "US")
        {
            var apiCountries = ExigoDAL.GetCountries();
            var countries    = new List <Country>();
            var markets      = GlobalSettings.Markets.AvailableMarkets;

            // compare the countries in the Countries table for the company with the list of available markets in the Settings file
            foreach (var market in markets)
            {
                foreach (var country in market.Countries)
                {
                    var countryMatch = apiCountries.Where(c => c.CountryCode == country).FirstOrDefault();
                    if (countryMatch != null)
                    {
                        // ensure no duplicates are added
                        if (!countries.Any(c => c.CountryCode == countryMatch.CountryCode))
                        {
                            countries.Add(countryMatch);
                        }
                    }
                }
            }

            if (countryCodes != null && countryCodes.Count() > 0)
            {
                countries = countries.Where(c => countryCodes.Contains(c.CountryCode)).ToList();
            }

            return(countries.Select(c => new SelectListItem()
            {
                Text = c.CountryName,
                Value = c.CountryCode,
                Selected = c.CountryCode == defaultCountryCode
            }));
        }
Exemple #21
0
        public static bool VerifySqlTableExists(string connectionString, string tableName)
        {
            tableName = tableName.Replace("[", "").Replace("]", "");

            var schema = "dbo";
            var table  = tableName;

            // Check to see if we
            if (tableName.Contains("."))
            {
                schema = tableName.Split('.')[0];
                table  = tableName.Split('.')[1];
            }

            var exists = false;

            using (var context = ExigoDAL.Sql(connectionString))
            {
                exists = context.Query <bool>(@"
                    if (EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = @schema AND TABLE_NAME = @table))
                    begin select cast(1 as bit) end
                    else begin select cast(0 as bit) end
                ", new
                {
                    schema = schema,
                    table  = table
                }).FirstOrDefault();
            }

            return(exists);
        }
        public JsonNetResult LoadCategories(Guid parentCategoryID)
        {
            try
            {
                var model = new SubcategoryListViewModel();
                model.ParentCategoryID          = parentCategoryID;
                model.ParentCategoryDescription = ExigoDAL.GetResourceCategories(new GetResourceCategoriesRequest()
                {
                    CategoryID = parentCategoryID
                }).FirstOrDefault().CategoryDescription;
                model.ResourceCategories = ExigoDAL.GetResourceCategories(new GetResourceCategoriesRequest()
                {
                    ParentID = parentCategoryID
                }).OrderBy(v => v.CategoryOrder);
                var html = this.RenderPartialViewToString("partials/_categorylist", model);

                return(new JsonNetResult(new
                {
                    success = true,
                    html = html
                }));
            }
            catch (Exception ex)
            {
                return(new JsonNetResult(new
                {
                    success = false,
                    message = ex.Message
                }));
            }
        }
        public int AuthenticateCustomer(string loginname, string password)
        {
            var command    = new SqlHelper();
            var customerID = command.GetField("AuthenticateCustomer {0}, {1}", loginname, password);

            // If the SQL authentication failed, we want to make sure we try the Webservice in case the person was not just created and the Sync db has not caught up yet
            if (customerID == null)
            {
                try
                {
                    var wsAuthReponse = ExigoDAL.WebService().AuthenticateCustomer(new Api.ExigoWebService.AuthenticateCustomerRequest {
                        LoginName = loginname, Password = password
                    });
                    if (wsAuthReponse.Result.Status == Api.ExigoWebService.ResultStatus.Success)
                    {
                        return(wsAuthReponse.CustomerID);
                    }
                    else
                    {
                        return(0);
                    }
                }
                catch { return(0); }
            }
            else
            {
                return((int)customerID);
            }
        }
Exemple #24
0
        public Guest CreateGuest(Guest guest)
        {
            // Assemble our Guest creation request and get the new Guest ID
            var request = (Api.ExigoWebService.CreateGuestRequest)guest;

            // Failsafe to ensure that the Host ID is added because for some reason it has to be on the CreateGuest request
            if (request.HostID == 0)
            {
                request.HostID = GetPartyHostID(guest.PartyID);
            }

            var createGuestResponse = ExigoDAL.WebService().CreateGuest(request);

            // Get our Guest ID and add them to the appropriate Party
            var addPartyGuestRequest = new AddPartyGuestsRequest();

            addPartyGuestRequest.PartyID  = guest.PartyID;
            addPartyGuestRequest.GuestIDs = new int[1] {
                createGuestResponse.GuestID
            };
            ExigoDAL.WebService().AddPartyGuests(addPartyGuestRequest);

            guest.GuestID = createGuestResponse.GuestID;

            return(guest);
        }
Exemple #25
0
 /// <summary>
 /// Default Constructor.
 /// Initializes Event Types and Privacy Types
 /// </summary>
 public CreateEventViewModel()
 {
     this.Request      = new CalendarEvent(Identity.Current.CustomerID);
     this.EventTypes   = ExigoDAL.GetCalendarEventTypes();
     this.PrivacyTypes = ExigoDAL.GetCalendarEventPrivacyTypes();
     GetCalendarID();
 }
Exemple #26
0
        public JsonNetResult CalculateAutoOrder(ManageAutoOrderViewModel model)
        {
            try
            {
                var calculateOrderResponse = ExigoDAL.CalculateOrder(new OrderCalculationRequest
                {
                    Address           = model.AutoOrder.ShippingAddress,
                    ShipMethodID      = model.AutoOrder.ShipMethodID,
                    ReturnShipMethods = true,
                    Configuration     = Identity.Customer.Market.Configuration.AutoOrders,
                    CustomerID        = Identity.Customer.CustomerID,
                    Items             = model.AutoOrder.Details.Select(i => new ShoppingCartItem {
                        ItemCode = i.ItemCode, Quantity = i.Quantity
                    })
                });

                return(new JsonNetResult(new
                {
                    success = true,
                    shipmethods = calculateOrderResponse.ShipMethods.ToList()
                }));
            }
            catch (Exception ex)
            {
                return(new JsonNetResult(new
                {
                    success = false,
                    message = ex.Message
                }));
            }
        }
        public static IEnumerable <Address> GetCustomerAddresses(int customerID)
        {
            UserIdentity ident = null;

            try { ident = Identity.Current; } catch { } //null-safe for tests
            return(ExigoDAL.GetCustomerAddresses(customerID, (ident != null ? (customerID == ident.CustomerID) : false)));
        }
Exemple #28
0
        private void InflateManageAutoOrderViewModel(int customerID, IMarket market, IOrderConfiguration configuration, ref ManageAutoOrderViewModel viewModel)
        {
            viewModel.AvailableStartDates = Enumerable.Range(1, 27).Select(day =>
            {
                var date = new DateTime(DateTime.Now.Year, DateTime.Now.Month, day).BeginningOfDay();
                if (date < DateTime.Now.BeginningOfDay())
                {
                    date = date.AddMonths(1);
                }

                return(date);
            }).OrderBy(d => d.Day).ToList();

            viewModel.AvailableProducts = ExigoDAL.GetItems(new ExigoService.GetItemsRequest()
            {
                Configuration             = configuration,
                LanguageID                = CurrentLanguage.LanguageID,
                CategoryID                = configuration.CategoryID,
                PriceTypeID               = PriceTypes.Wholesale,
                IncludeAllChildCategories = true,
                IncludeDynamicKitChildren = false
            }).ToList();

            viewModel.AvailablePaymentMethods = ExigoDAL.GetCustomerPaymentMethods(customerID)
                                                .Where(p => p.IsValid)
                                                .Where(p => p is IAutoOrderPaymentMethod)
                                                .ToList();

            if (viewModel.AvailablePaymentMethods != null && viewModel.AvailablePaymentMethods.Count() == 1)
            {
                viewModel.NewCreditCard.Type = CreditCardType.Secondary;
            }
        }
Exemple #29
0
        public static IEnumerable <Rank> GetRanks()
        {
            var ranks = new List <Rank>();

            using (var context = ExigoDAL.Sql())
            {
                ranks = context.Query <Rank>(@"
                        SELECT 
	                        r.RankID
	                        ,r.RankDescription

                        FROM
	                        Ranks r                                
                        ").OrderBy(c => c.RankID).ToList();
            }

            //Ensure that rank 0 exists
            if (ranks.Where(c => c.RankID == 0).FirstOrDefault() == null)
            {
                ranks.Insert(0, new Rank()
                {
                    RankID = 0, RankDescription = ""
                });
            }

            foreach (var rank in ranks)
            {
                yield return(rank);
            }
        }
        public JsonNetResult CreateCategory(List <TranslatedCategory> transdesc, Guid?parentID)
        {
            try
            {
                //2015-09-08
                //Ivan S.
                //66
                //Sets the initial order for the new category to the maximum number for all the categories
                var lastCategory      = ExigoDAL.GetResourceCategories(new GetResourceCategoriesRequest()).OrderByDescending(rc => rc.CategoryOrder).FirstOrDefault();
                int?lastCategoryOrder = InitialOrderValue - 1;
                if (lastCategory != null)
                {
                    lastCategoryOrder = lastCategory.CategoryOrder;
                }
                var NewOrder   = ++lastCategoryOrder;
                var CategoryID = Guid.NewGuid();
                if (parentID == null)
                {
                    parentID = Guid.Empty;
                }
                foreach (var description in transdesc)
                {
                    //English is the Default Language and will be used as the Description on the Categories Table
                    if (description.Language == "English")
                    {
                        ResourceCategory Category = new ResourceCategory()
                        {
                            CategoryID          = CategoryID,
                            CategoryDescription = description.TranslatedCategoryDescription,
                            CategoryOrder       = NewOrder,
                            ParentID            = (Guid)parentID
                        };
                        ExigoDAL.AddResourceCategory(Category);
                    }
                    //Adds an entry for each language translation provided in the TranslatedCategoryItems table
                    ResourceTranslatedCategoryItem TCategory = new ResourceTranslatedCategoryItem()
                    {
                        TranslatedCategoryID          = Guid.NewGuid(),
                        CategoryID                    = CategoryID,
                        Language                      = description.Language,
                        TranslatedCategoryDescription = description.TranslatedCategoryDescription
                    };
                    ExigoDAL.AddCategoryTranslation(TCategory);
                }

                return(new JsonNetResult(new
                {
                    success = true
                }));
            }
            catch (Exception ex)
            {
                return(new JsonNetResult(new
                {
                    success = false,
                    message = ex.Message
                }));
            }
        }