public async Task <User> Get() { string account = getCurrentUser.Get(); var policy = cachePolicyRegistry.GetAsyncPolicy <User>(ActiveDirectoryUserProfileCacheMgmt.CacheKey); return(await policy.ExecuteAsync(context => userProfileService.GetUser(account), new Context(account))); }
public string GetInfo() { Entities.People.User user = _currentUser.Get(); return(user != null ? string.Format(" by <a href=\"/Admin/User/Edit/{1}\">{0}</a>", user.Name, user.Id) : string.Empty); }
public void Execute(OrderShippedArgs args) { var currentUser = _getCurrentUser.Get(); _orderNoteService.AddOrderNoteAudit(string.Format("Order marked as shipped by {0}.", currentUser != null ? currentUser.Name : "System"), args.Order); }
public void PublishNotification(string message, PublishType publishType = PublishType.Both, NotificationType notificationType = NotificationType.All) { if (CurrentRequestData.CurrentContext.AreNotificationsDisabled()) { return; } Notification notification = new Notification { Message = message, User = _getCurrentUser.Get(), NotificationType = notificationType }; switch (publishType) { case PublishType.Transient: PushNotification(notification); break; case PublishType.Persistent: SaveNotification(notification); break; case PublishType.Both: SaveNotification(notification); PushNotification(notification); break; default: throw new ArgumentOutOfRangeException("publishType"); } }
public List <SelectListItem> Get(IAddress addressToExclude) { var addresses = new List <Address>(); if (_cart.ShippingAddress != null) { addresses.Add(_cart.ShippingAddress); } if (_cart.BillingAddress != null) { addresses.Add(_cart.BillingAddress); } var currentUser = _getCurrentUser.Get(); if (currentUser != null) { addresses.AddRange(_belongToUserLookupService.GetAll <Address>(currentUser)); } var enumerable = addresses.Distinct(AddressComparison.Comparer).OfType <Address>(); addresses = enumerable.Where(a => addressToExclude == null || !AddressComparison.Comparer.Equals(a, addressToExclude)).ToList(); return(addresses.Any() ? addresses.BuildSelectItemList(address => address.GetDescription(), address => address.ToJSON(), emptyItemText: "Select an address...") : new List <SelectListItem>()); }
public bool IsCurrentUserAllowed(Webpage webpage) { User user = _getCurrentUser.Get(); if (user != null && user.IsAdmin) { return(true); } if (webpage.InheritFrontEndRolesFromParent) { if (webpage.Parent is Webpage) { return(IsCurrentUserAllowed(webpage.Parent as Webpage)); } return(true); } if (!webpage.FrontEndAllowedRoles.Any()) { return(true); } if (webpage.FrontEndAllowedRoles.Any() && user == null) { return(false); } return(user != null && user.Roles.Intersect(webpage.FrontEndAllowedRoles).Any()); }
public void Add(ProductReview productReview) { User user = _getCurrentUser.Get(); if (user != null) { productReview.User = user; } _session.Transact(session => session.Save(productReview)); }
public Address Get(Guid userGuid) { var shippingAddress = _cartSessionManager.GetSessionValue <Address>(CartManager.CurrentShippingAddressKey, userGuid); if (shippingAddress != null) { shippingAddress.User = _getCurrentUser.Get(); } return(shippingAddress); }
private Address GetBillingAddress(CartModel cart, Guid userGuid) { Address billingAddress = _billingAddressSameAsShippingAddress.Get(cart, userGuid) && cart.RequiresShipping ? _getShippingAddress.Get(userGuid) : _cartSessionManager.GetSessionValue <Address>(CartManager.CurrentBillingAddressKey, userGuid); if (billingAddress != null) { billingAddress.User = _getCurrentUser.Get(); } return(billingAddress); }
public override object GetModel(UserOrdersList widget) { var user = _currentUser.Get(); if (user == null) { return(null); } var ordersByUser = _orderService.GetOrdersByUser(user, 1); return(new UserAccountOrdersModel(new PagedList <Order>(ordersByUser, ordersByUser.PageNumber, ordersByUser.PageSize), user.Id)); }
public void LogPageView(PageViewInfo info) { User user = _getCurrentUser.Get(); var site = _session.Get <Site>(_site.Id); DateTime now = CurrentRequestData.Now; AnalyticsUser analyticsUser = GetCurrentUser(user == null ? info.User : user.Guid); bool userIsNew = analyticsUser == null; if (userIsNew) { analyticsUser = new AnalyticsUser { User = user, CreatedOn = now, UpdatedOn = now, }; analyticsUser.SetGuid(info.User); _session.Insert(analyticsUser); } AnalyticsSession analyticsSession = GetCurrentSession(info.Session); bool sessionIsNew = analyticsSession == null; if (sessionIsNew) { analyticsSession = new AnalyticsSession { AnalyticsUser = analyticsUser, IP = _request.GetCurrentIP(), UserAgent = _request.UserAgent, Site = site, CreatedOn = now, UpdatedOn = now, }; analyticsSession.SetGuid(info.Session); _session.Insert(analyticsSession); } var pageView = new AnalyticsPageView { Webpage = GetWebpage(info.Url), Url = info.Url, AnalyticsSession = analyticsSession, Site = site, CreatedOn = now, UpdatedOn = now, }; _session.Insert(pageView); }
public PartialViewResult Add(ProductVariant productVariant) { var user = _getCurrentUser.Get(); var model = new ProductReview { ProductVariant = productVariant }; if (user != null) { model.Name = user.Name; model.Email = user.Email; } return(PartialView(model)); }
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>())); }
public string GetCurrentUser() => getCurrentUser.Get();
public void LogPageView(PageViewInfo info) { User user = _getCurrentUser.Get(); var site = _session.Get <Site>(_site.Id); DateTime now = CurrentRequestData.Now; AnalyticsUser analyticsUser = GetUser(user == null ? info.User : user.Guid); bool userIsNew = analyticsUser == null; if (userIsNew) { analyticsUser = new AnalyticsUser { User = user, CreatedOn = now, UpdatedOn = now, }; analyticsUser.SetGuid(info.User); _session.Insert(analyticsUser); } if (analyticsUser.RequiresEmailCheck && _getEmailFromRequest.CanCheck) { CheckEmail(analyticsUser, now); } AnalyticsSession analyticsSession = GetCurrentSession(info.Session); bool sessionIsNew = analyticsSession == null; var changedResult = _context.AnalyticsUserGuidHasChanged(); if (sessionIsNew) { analyticsSession = new AnalyticsSession { AnalyticsUser = analyticsUser, IP = _context.GetCurrentIP(), UserAgent = _context.Request.UserAgent, Site = site, CreatedOn = now, UpdatedOn = now, }; analyticsSession.SetGuid(info.Session); _session.Insert(analyticsSession); } // only move it if it's going to a live user else if (changedResult.Changed && analyticsUser.User != null) { UpdateOldUsersSessions(changedResult, analyticsSession, analyticsUser); } var pageView = new AnalyticsPageView { Webpage = GetWebpage(info.Url), Url = info.Url, AnalyticsSession = analyticsSession, Site = site, CreatedOn = now, UpdatedOn = now, }; _session.Insert(pageView); }
public void Execute(OnDeletedArgs <Order> args) { _orderNoteService.AddOrderNoteAudit(string.Format("Order marked as deleted by {0}.", _getCurrentUser.Get().Name), args.Item); }
public void AddAdjustment(ManualAdjustment adjustment) { adjustment.AdjustedBy = _getCurrentUser.Get(); _session.Transact(session => session.Save(adjustment)); }