Exemple #1
0
        public GiftCardUIServiceResult Apply(string giftCardCode)
        {
            giftCardCode = giftCardCode.Trim();
            var giftCard =
                _session.QueryOver <GiftCard>()
                .Where(card => card.Code == giftCardCode)
                .Cacheable()
                .List().FirstOrDefault(card => card.IsValidToUse());

            if (giftCard != null)
            {
                if (_cart.AppliedGiftCards.Contains(giftCard))
                {
                    return(new GiftCardUIServiceResult
                    {
                        Success = false,
                        Message = _stringResourceProvider.GetValue("Gift card already applied")
                    });
                }
                _cartManager.AddGiftCard(giftCard.Code);
                return(new GiftCardUIServiceResult
                {
                    Success = true,
                    Message = _stringResourceProvider.GetValue("Gift card applied")
                });
            }
            return(new GiftCardUIServiceResult
            {
                Success = false,
                Message = _stringResourceProvider.GetValue("Gift card code could not be applied")
            });
        }
Exemple #2
0
        private void AddOrderLines(ExcelPackage excelFile, OrderExportQuery exportQuery)
        {
            ExcelWorksheet    ordersWorksheet = excelFile.Workbook.Worksheets.Add("Order Lines");
            IList <OrderLine> orderLines      = GetOrderLines(exportQuery);
            Dictionary <string, Func <OrderLine, object> > columns = GetOrderLineColumns();

            List <string> keys = columns.Keys.ToList();

            for (int index = 0; index < keys.Count; index++)
            {
                string key  = keys[index];
                var    cell = ordersWorksheet.Cells[1, index + 1];
                cell.Value                     = _stringResourceProvider.GetValue("Excel Order Line Export - " + key, key);
                cell.Style.Font.Bold           = true;
                cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
            }
            for (int i = 0; i < orderLines.Count; i++)
            {
                var orderLine = orderLines[i];
                for (int index = 0; index < keys.Count; index++)
                {
                    string key   = keys[index];
                    var    row   = i + 2; // +1 for the non-zero-based index and +1 for the header row
                    var    cell  = ordersWorksheet.Cells[row, index + 1];
                    var    value = columns[key](orderLine);
                    cell.Value = value;
                    if (value is DateTime)
                    {
                        cell.Style.Numberformat.Format = "dd/mm/yyyy hh:mm:ss";
                    }
                }
            }
            ordersWorksheet.Cells.AutoFitColumns();
        }
        public ActionResult ForgottenPassword(string email)
        {
            if (string.IsNullOrEmpty(email))
            {
                TempData["message"] = _stringResourceProvider.GetValue("Login Email Not Recognized",
                                                                       "Email not recognized.");
                return(_uniquePageService.RedirectTo <ForgottenPasswordPage>());
            }

            var user = _userLookup.GetUserByEmail(email);

            if (user != null)
            {
                _resetPasswordService.SetResetPassword(user);
                TempData["message"] =
                    _stringResourceProvider.GetValue("Login Password Reset",
                                                     "We have sent password reset details to you. Please check your spam folder if this is not received shortly.");
            }
            else
            {
                TempData["message"] = _stringResourceProvider.GetValue("Login Email Not Recognized",
                                                                       "Email not recognized.");
            }

            return(_uniquePageService.RedirectTo <ForgottenPasswordPage>());
        }
Exemple #4
0
        public JsonResult IsUniqueEmail(string email)
        {
            if (_userService.IsUniqueEmail(email, CurrentRequestData.CurrentUser.Id))
            {
                return(Json(true, JsonRequestBehavior.AllowGet));
            }

            return(Json(_stringResourceProvider.GetValue("Register Email Already Registered", "Email already registered."), JsonRequestBehavior.AllowGet));
        }
Exemple #5
0
        public BulkUpdateResult Update(List <BulkWarehouseStockUpdateDTO> dtoList)
        {
            var warehouseStocks = _statelessSession.Query <WarehouseStock>()
                                  .Where(stock => stock.Site.Id == _site.Id && !stock.IsDeleted &&
                                         stock.ProductVariant != null &&
                                         stock.ProductVariant.SKU != null &&
                                         stock.Warehouse != null && !stock.ProductVariant.IsDeleted)
                                  .Fetch(stock => stock.ProductVariant)
                                  .Fetch(stock => stock.Warehouse)
                                  .ToList();
            var dictionary = warehouseStocks
                             .GroupBy(stock => stock.ProductVariant.SKU)
                             .ToDictionary(stocks => stocks.Key,
                                           stocks => stocks.ToDictionary(stock => stock.Warehouse.Id, stock => stock));

            HashSet <BulkWarehouseStockUpdateDTO> dtos = dtoList.ToHashSet();
            var stockToUpdate = new HashSet <WarehouseStock>();

            using (ITransaction transaction = _statelessSession.BeginTransaction())
            {
                foreach (BulkWarehouseStockUpdateDTO dto in dtos)
                {
                    if (!dictionary.ContainsKey(dto.SKU) || !dictionary[dto.SKU].ContainsKey(dto.WarehouseId))
                    {
                        continue;
                    }

                    WarehouseStock stock = dictionary[dto.SKU][dto.WarehouseId];
                    if (stock.StockLevel == dto.StockLevel)
                    {
                        continue;
                    }

                    stock.StockLevel = dto.StockLevel;
                    stockToUpdate.Add(stock);
                }
                foreach (WarehouseStock stock in stockToUpdate)
                {
                    _statelessSession.Update(stock);
                }
                transaction.Commit();
            }

            return(new BulkUpdateResult
            {
                IsSuccess = true,
                Messages = new List <string>
                {
                    string.Format(
                        _stringResourceProvider.GetValue("Bulk Stock Update - number processed", "{0} items processed"),
                        dtos.Count()),
                    string.Format(
                        _stringResourceProvider.GetValue("Bulk Stock Update - number updated", "{0} items updated"),
                        stockToUpdate.Count)
                }
            });
        }
Exemple #6
0
        public override object GetModel(UserLinks widget)
        {
            List <NavigationRecord> navigationRecords = new List <NavigationRecord>();

            bool loggedIn = CurrentRequestData.CurrentUser != null;

            if (loggedIn)
            {
                UserAccountPage userAccountPage = _uniquePageService.GetUniquePage <UserAccountPage>();
                if (userAccountPage != null)
                {
                    string liveUrlSegment = userAccountPage.LiveUrlSegment;
                    navigationRecords.Add(new NavigationRecord
                    {
                        Text = MvcHtmlString.Create(_stringResourceProvider.GetValue("My Account")),
                        Url  =
                            MvcHtmlString.Create(string.Format("/{0}", liveUrlSegment))
                    });
                }


                navigationRecords.Add(new NavigationRecord
                {
                    Text = MvcHtmlString.Create(_stringResourceProvider.GetValue("Logout")),
                    Url  =
                        MvcHtmlString.Create(string.Format("/logout"))
                });
            }
            else
            {
                string liveUrlSegment = _uniquePageService.GetUniquePage <LoginPage>().LiveUrlSegment;
                if (liveUrlSegment != null)
                {
                    navigationRecords.Add(new NavigationRecord
                    {
                        Text = MvcHtmlString.Create(_stringResourceProvider.GetValue("Login")),
                        Url  =
                            MvcHtmlString.Create(string.Format("/{0}", liveUrlSegment))
                    });
                    string urlSegment = _uniquePageService.GetUniquePage <RegisterPage>().LiveUrlSegment;
                    if (urlSegment != null)
                    {
                        navigationRecords.Add(new NavigationRecord
                        {
                            Text = MvcHtmlString.Create(_stringResourceProvider.GetValue("Register")),
                            Url  =
                                MvcHtmlString.Create(string.Format("/{0}", urlSegment))
                        });
                    }
                }
            }
            return(navigationRecords);
        }
Exemple #7
0
 public override CheckLimitationsResult CheckLimitations(ShippingCountryIs limitation, CartModel cart)
 {
     if (cart.ShippingAddress == null)
     {
         return
             (CheckLimitationsResult.CurrentlyInvalid(_stringResourceProvider.GetValue("Shipping address is not yet set")));
     }
     return(cart.ShippingAddress.CountryCode == limitation.ShippingCountryCode
         ? CheckLimitationsResult.Successful(Enumerable.Empty <CartItem>())
         : CheckLimitationsResult.CurrentlyInvalid(
                _stringResourceProvider.GetValue("Shipping country is not valid for this discount")));
 }
        public RedirectToRouteResult TestMailSettings(TestEmailInfo info)
        {
            var result = _testSmtpSettings.TestSettings(_configurationProvider.GetSystemSettings <MailSettings>(), info);

            if (result)
            {
                TempData.SuccessMessages().Add(_resourceProvider.GetValue("Admin - Test email - Success", "Email sent."));
            }
            else
            {
                TempData.ErrorMessages().Add(_resourceProvider.GetValue("Admin - Test email - Failure", "An error occurred, check the log for details."));
            }
            return(RedirectToAction("Mail"));
        }
Exemple #9
0
        private PostCommentResponse GetResponse(Comment comment)
        {
            bool pending = comment.Approved != true;

            return(new PostCommentResponse
            {
                Valid = true,
                Pending = pending,
                Message = pending
                           ? _stringResourceProvider.GetValue(PendingApprovalMessage)
                           : _stringResourceProvider.GetValue(AddedMessage),
                RedirectUrl = "~/" + comment.Webpage.LiveUrlSegment
            });
        }
        public MergeWebpageResult Validate(MergeWebpageModel moveWebpageModel)
        {
            var webpage = GetWebpage(moveWebpageModel);
            var parent  = GetParent(moveWebpageModel);

            var validParentWebpages = GetValidParentWebpages(webpage);
            var valid = webpage != null && parent != null && validParentWebpages.Contains(parent);

            return(new MergeWebpageResult
            {
                Success = valid,
                Message = valid ? string.Empty : _resourceProvider.GetValue("Sorry, but you can't select that as a parent for this page.")
            });
        }
Exemple #11
0
        public override IEnumerable <SEOAnalysisFacet> GetFacets(Webpage webpage, HtmlNode document, string analysisTerm)
        {
            var images = document.GetElementsOfType("img").ToList();

            IEnumerable <HtmlNode> imagesWithoutAlt = images.FindAll(node => !node.Attributes.Contains("alt"));

            string hasNotGotAnAltTag = _stringResourceProvider.GetValue("Admin SEO Analysis Has not got", " has not got an alt tag");

            yield return(GetFacet(_stringResourceProvider.GetValue("Admin SEO Analysis Has not got alt tags", "All images have alt tags"),
                                  !imagesWithoutAlt.Any()
                    ? SEOAnalysisStatus.Success
                    : SEOAnalysisStatus.Error,
                                  imagesWithoutAlt.Select(node => node.GetAttributeValue("src", "") + hasNotGotAnAltTag).ToArray()));
        }
Exemple #12
0
        public ActionResult UpdateUsername(CommentingUserAccountModel model)
        {
            if (ModelState.IsValid)
            {
                _commentInfoUiService.Save(model);
                model.Message = _stringResourceProvider.GetValue("Commenting App - Username successfully updated.", "Username successfully updated.");
            }
            else
            {
                model.Message = _stringResourceProvider.GetValue("Commenting App - Please ensure to fill out the usename.", "Please ensure to fill out the usename.");
            }

            TempData["message"] = model.Message;
            return(_uniquePageService.RedirectTo <UserAccountPage>());
        }
Exemple #13
0
        public CheckCodeResult CheckCode(CartModel cart, string discountCode, bool fromUrl)
        {
            DateTime now   = CurrentRequestData.Now;
            var      code  = discountCode.Trim();
            var      query = _session.QueryOver <Discount>().Where(x
                                                                   => (x.Code == code && x.RequiresCode) &&
                                                                   (x.ValidFrom == null || x.ValidFrom <= now) &&
                                                                   (x.ValidUntil == null || x.ValidUntil >= now));

            if (fromUrl)
            {
                query = query.Where(x => x.CanBeAppliedFromUrl);
            }

            var discount = query.Cacheable().List().FirstOrDefault();

            var defaultRedirectUrl = "/";
            var checkCodeResult    = new CheckCodeResult
            {
                RedirectUrl = discount != null
                    ? string.IsNullOrEmpty(discount.RedirectUrl)
                        ? defaultRedirectUrl
                        : discount.RedirectUrl
                    : defaultRedirectUrl,
            };

            if (discount == null)
            {
                checkCodeResult.Message = _stringResourceProvider.GetValue("The code you entered is not valid.");
                return(checkCodeResult);
            }
            var discounts = Get(cart, cart.DiscountCodes);

            discounts.Add(discount);

            var checkLimitationsResult = _cartDiscountApplicationService.CheckLimitations(discount, cart, discounts);

            if (checkLimitationsResult.Status == CheckLimitationsResultStatus.NeverValid)
            {
                checkCodeResult.Message = checkLimitationsResult.FormattedMessage;
                return(checkCodeResult);
            }

            checkCodeResult.Status =
                checkLimitationsResult.Status == CheckLimitationsResultStatus.CurrentlyInvalid
                    ? CheckLimitationsResultStatus.CurrentlyInvalid
                    : CheckLimitationsResultStatus.Success;
            if (fromUrl && checkLimitationsResult.Status == CheckLimitationsResultStatus.CurrentlyInvalid)
            {
                checkCodeResult.Message = string.IsNullOrWhiteSpace(discount.AppliedNotYetValidMessage)
                    ? checkLimitationsResult.FormattedMessage
                    : discount.AppliedNotYetValidMessage;
            }
            else
            {
                checkCodeResult.Message = discount.SuccessMessage;
            }

            return(checkCodeResult);
        }
Exemple #14
0
        public string MoveFolders(IEnumerable <MediaCategory> folders, MediaCategory parent = null)
        {
            string message = string.Empty;

            if (folders != null)
            {
                _session.Transact(s => folders.ForEach(item =>
                {
                    var mediaFolder = s.Get <MediaCategory>(item.Id);
                    if (parent != null && mediaFolder.Id != parent.Id)
                    {
                        mediaFolder.Parent = parent;
                        s.Update(mediaFolder);
                    }
                    else if (parent == null)
                    {
                        mediaFolder.Parent = null;
                        s.Update(mediaFolder);
                    }
                    else
                    {
                        message = _stringResourceProvider.GetValue("Cannot move folder to the same folder");
                    }
                }));
            }
            return(message);
        }
Exemple #15
0
 public List <SelectListItem> GetEnumOptionsWithEmpty <T>() where T : struct
 {
     return
         (Enum.GetValues(typeof(T))
          .Cast <T>()
          .BuildSelectItemList(item => GeneralHelper.GetDescriptionFromEnum(item as Enum), item => item.ToString(), emptyItemText: _stringResourceProvider.GetValue("Please select...")));
 }
Exemple #16
0
        public CheckCodeResult CheckCode(CartModel cart, string discountCode)
        {
            DateTime now       = CurrentRequestData.Now;
            var      code      = discountCode.Trim();
            var      discounts = _session.QueryOver <Discount>()
                                 .Where(
                discount =>
                (discount.Code == code && discount.RequiresCode) &&
                (discount.ValidFrom == null || discount.ValidFrom <= now) &&
                (discount.ValidUntil == null || discount.ValidUntil >= now))
                                 .Cacheable().List();

            if (!discounts.Any())
            {
                return(new CheckCodeResult
                {
                    Message = _stringResourceProvider.GetValue("The code you entered is not valid.")
                });
            }

            var checkLimitationsResults = discounts.Select(
                discount =>
                _cartDiscountApplicationService.CheckLimitations(discount, cart)).ToList();

            if (checkLimitationsResults.All(result => result.Status == CheckLimitationsResultStatus.NeverValid))
            {
                return(new CheckCodeResult
                {
                    Message = checkLimitationsResults.First().FormattedMessage
                });
            }
            return(new CheckCodeResult {
                Success = true
            });
        }
Exemple #17
0
 public override CheckLimitationsResult CheckLimitations(CartTotalGreaterThanX limitation, CartModel cart)
 {
     return(cart.TotalPreDiscount > limitation.CartTotalGreaterThanValue
         ? CheckLimitationsResult.Successful(Enumerable.Empty <CartItem>())
         : CheckLimitationsResult.CurrentlyInvalid(
                _stringResourceProvider.GetValue("Order total does not reach the threshold of " +
                                                 limitation.CartTotalGreaterThanValue.ToCurrencyFormat())));
 }
Exemple #18
0
 public override CheckLimitationsResult CheckLimitations(CartHasAtLeastXItems limitation, CartModel cart)
 {
     return(cart.ItemQuantity >= limitation.NumberOfItems
         ? CheckLimitationsResult.Successful(Enumerable.Empty <CartItem>())
         : CheckLimitationsResult.CurrentlyInvalid(
                string.Format(
                    _stringResourceProvider.GetValue("You need at least {0} items to apply this discount"),
                    limitation.NumberOfItems)));
 }
Exemple #19
0
        public override CheckLimitationsResult CheckLimitations(ItemIsInCategory limitation, CartModel cart, IList <Discount> allDiscounts)
        {
            var categoryIds = limitation.CategoryIds;
            var cartItems   = _getCartItemsByCategoryIdList.GetCartItems(cart, categoryIds);

            return(cartItems.Any()
                ? CheckLimitationsResult.Successful(cartItems)
                : CheckLimitationsResult.CurrentlyInvalid(_stringResourceProvider.GetValue("You don't have the required item(s) in your cart for this discount")));
        }
        public override CheckLimitationsResult CheckLimitations(OnlyByItself limitation, CartModel cart, IList <Discount> allDiscounts)
        {
            var discount = limitation.Discount;

            if (discount == null)
            {
                return(CheckLimitationsResult.NeverValid(
                           _stringResourceProvider.GetValue("This limitation has no discount.")));
            }

            if (allDiscounts.Any(x => x != discount))
            {
                return(CheckLimitationsResult.CurrentlyInvalid(
                           _stringResourceProvider.GetValue("This discount cannot be combined.")));
            }

            return(CheckLimitationsResult.Successful(Enumerable.Empty <CartItemData>()));
        }
Exemple #21
0
        public override CheckLimitationsResult CheckLimitations(ShippingPostcodeStartsWith limitation, CartModel cart)
        {
            if (cart.ShippingAddress == null)
            {
                return
                    (CheckLimitationsResult.CurrentlyInvalid(_stringResourceProvider.GetValue("Shipping address is not yet set")));
            }
            var postcodes =
                (limitation.ShippingPostcode ?? string.Empty).Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries)
                .Select(s => s.Trim().ToUpper())
                .ToHashSet();
            var postcode = cart.ShippingAddress.FormattedPostcode();

            return(postcodes.Any(postcode.StartsWith)
                ? CheckLimitationsResult.Successful(Enumerable.Empty <CartItem>())
                : CheckLimitationsResult.CurrentlyInvalid(
                       _stringResourceProvider.GetValue("Shipping postcode is not valid for this discount")));
        }
Exemple #22
0
        public override CheckLimitationsResult CheckLimitations(ItemHasSKU limitation, CartModel cart)
        {
            var cartItems = _getCartItemsBySKUList.GetCartItems(cart, limitation.SKUs);

            return(cartItems.Any()
                ? CheckLimitationsResult.Successful(cartItems)
                : CheckLimitationsResult.CurrentlyInvalid(
                       _stringResourceProvider.GetValue(
                           "You don't have the required item(s) in your cart for this discount")));
        }
Exemple #23
0
        public override CheckLimitationsResult CheckLimitations(SingleUsage limitation, CartModel cart)
        {
            var discountId = limitation.Discount.Id;
            var anyUsages  =
                _session.QueryOver <DiscountUsage>().Where(usage => usage.Discount.Id == discountId).Cacheable().Any();

            return(anyUsages
                ? CheckLimitationsResult.NeverValid(_stringResourceProvider.GetValue("This discount has already been used."))
                : CheckLimitationsResult.Successful(Enumerable.Empty <CartItem>()));
        }
Exemple #24
0
        public override CheckLimitationsResult CheckLimitations(SingleUsagePerCustomer limitation, CartModel cart)
        {
            var user = _getCurrentUser.Get();

            if (user == null)
            {
                return(CheckLimitationsResult.NeverValid(_stringResourceProvider.GetValue("This discount requires an account.")));
            }

            var discountId = limitation.Discount.Id;
            var anyUsages  =
                _session.Query <DiscountUsage>()
                .Where(usage => usage.Discount.Id == discountId && usage.Order.User.Id == user.Id)
                .Cacheable()
                .Any();

            return(anyUsages
                ? CheckLimitationsResult.NeverValid(_stringResourceProvider.GetValue("This discount has already been used."))
                : CheckLimitationsResult.Successful(Enumerable.Empty <CartItem>()));
        }
Exemple #25
0
        private IEnumerable <string> GetHeadersForExport(Webpage webpage)
        {
            var headers = new List <string>();

            foreach (FormPosting posting in webpage.FormPostings)
            {
                headers.AddRange(posting.FormValues.Select(x => x.Key).Distinct());
            }
            headers.Add(_stringResourceProvider.GetValue("Admin Form Postings Posted On", "Posted On"));
            return(headers.Distinct().ToList());
        }
Exemple #26
0
        public BulkUpdateResult Update(IEnumerable <BulkStockUpdateDataTransferObject> items)
        {
            var allVariants =
                _statelessSession.QueryOver <ProductVariant>()
                .Where(variant => variant.Site.Id == _site.Id && !variant.IsDeleted && variant.SKU != null)
                .List().ToDictionary(variant => variant.SKU, variant => variant);


            var bulkStockUpdateDataTransferObjects = items.ToHashSet();

            using (var transaction = _statelessSession.BeginTransaction())
            {
                foreach (var dto in bulkStockUpdateDataTransferObjects)
                {
                    ProductVariant variant = allVariants.ContainsKey(dto.SKU) ? allVariants[dto.SKU] : null;

                    if (variant != null && variant.StockRemaining != dto.StockRemaining)
                    {
                        variant.StockRemaining = dto.StockRemaining;
                        _variantsToUpdate.Add(variant);
                    }
                }
                _variantsToUpdate.ForEach(_statelessSession.Update);
                transaction.Commit();
            }

            return(new BulkUpdateResult
            {
                IsSuccess = true,
                Messages = new List <string>
                {
                    string.Format(
                        _stringResourceProvider.GetValue("Bulk Stock Update - number processed", "{0} items processed"),
                        bulkStockUpdateDataTransferObjects.Count()),
                    string.Format(
                        _stringResourceProvider.GetValue("Bulk Stock Update - number updated", "{0} items updated"),
                        _variantsToUpdate.Count)
                }
            });
        }
Exemple #27
0
        public GenerateStockResult GenerateStock(StockGenerationModel model)
        {
            var warehouse = _session.Get <Warehouse>(model.WarehouseId);

            if (warehouse == null)
            {
                var message = _stringResourceProvider.GetValue(string.Format("{0}Warehouse not found", ResourcePrefix), "Cannot find the warehouse to add stock to");
                return(GenerateStockResult.Failure(message));
            }
            var productVariantsToTrack =
                _session.QueryOver <ProductVariant>()
                .Where(variant => variant.TrackingPolicy == TrackingPolicy.Track)
                .Cacheable()
                .List()
                .ToHashSet();
            var newWarehouseStocks = productVariantsToTrack.Select(variant => new WarehouseStock
            {
                ProductVariant = variant,
                Warehouse      = warehouse
            }).ToHashSet();

            switch (model.StockGenerationType)
            {
            case StockGenerationType.FixedValue:
                newWarehouseStocks.ForEach(stock => stock.StockLevel = model.FixedValue);
                break;

            case StockGenerationType.CopyFromSystemValues:
                newWarehouseStocks.ForEach(stock => stock.StockLevel = stock.ProductVariant.StockRemaining);
                break;

            case StockGenerationType.CopyFromWarehouse:
                var stockLevels = _session.QueryOver <WarehouseStock>()
                                  .Where(stock => stock.Warehouse.Id == model.WarehouseToCopyId)
                                  .Cacheable()
                                  .List()
                                  .ToDictionary(stock => stock.ProductVariant.Id, stock => stock.StockLevel);
                newWarehouseStocks.ForEach(stock =>
                {
                    stock.StockLevel = stockLevels.ContainsKey(stock.ProductVariant.Id)
                            ? stockLevels[stock.ProductVariant.Id]
                            : 0;
                });
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            _session.Transact(session => newWarehouseStocks.ForEach(stock => session.Save(stock)));
            return(GenerateStockResult.Success("Stock generated successfully"));
        }
        public override object GetModel(EcommerceUserLinks widget)
        {
            var navigationRecords = new List <NavigationRecord>();
            var loggedIn          = CurrentRequestData.CurrentUser != null;

            if (loggedIn)
            {
                navigationRecords.AddRange(_getUserAccountLinks.Get());

                navigationRecords.Add(new NavigationRecord
                {
                    Text = MvcHtmlString.Create(_stringResourceProvider.GetValue("Logout")),
                    Url  = MvcHtmlString.Create(string.Format("/logout"))
                });
            }
            else
            {
                var loginPageLiveUrlSegment = _uniquePageService.GetUniquePage <LoginPage>().LiveUrlSegment;
                if (loginPageLiveUrlSegment != null)
                {
                    navigationRecords.Add(new NavigationRecord
                    {
                        Text = MvcHtmlString.Create(_stringResourceProvider.GetValue("Login")),
                        Url  = MvcHtmlString.Create(string.Format("/{0}", loginPageLiveUrlSegment))
                    });
                }
                var registerPageLiveUrlSegment = _uniquePageService.GetUniquePage <RegisterPage>().LiveUrlSegment;
                if (registerPageLiveUrlSegment != null)
                {
                    navigationRecords.Add(new NavigationRecord
                    {
                        Text = MvcHtmlString.Create(_stringResourceProvider.GetValue("Register")),
                        Url  = MvcHtmlString.Create(string.Format("/{0}", registerPageLiveUrlSegment))
                    });
                }
            }

            return(navigationRecords);
        }
        public MoveWebpageResult Validate(MoveWebpageModel moveWebpageModel)
        {
            var webpage = GetWebpage(moveWebpageModel);
            var parent  = GetParent(moveWebpageModel);

            if (parent == webpage.Parent.Unproxy())
            {
                return(new MoveWebpageResult
                {
                    Success = false,
                    Message = _resourceProvider.GetValue("The webpage already has this parent")
                });
            }

            var validParentWebpages = GetValidParentWebpages(webpage);
            var valid = parent == null?IsRootAllowed(webpage) : validParentWebpages.Contains(parent);

            return(new MoveWebpageResult
            {
                Success = valid,
                Message = valid ? string.Empty : _resourceProvider.GetValue("Sorry, but you can't select that as a parent for this page.")
            });
        }
        public UpdatePasswordResult Update(UpdatePasswordModel model)
        {
            var user = CurrentRequestData.CurrentUser;

            // Check old password
            if (!_passwordManagementService.ValidateUser(user, model.CurrentPassword))
            {
                return(new UpdatePasswordResult
                {
                    Success = false,
                    Message = _stringResourceProvider.GetValue("Incorrect Current Password", "Current Password is incorrect.")
                });
            }

            // Change password
            _passwordManagementService.SetPassword(user, model.NewPassword, model.ConfirmNewPassword);
            _session.Transact(session => session.Update(user));

            return(new UpdatePasswordResult
            {
                Success = true,
                Message = _stringResourceProvider.GetValue("User Password Updated", "Password successfully changed.")
            });
        }