/// <summary>
 /// 删除一个用户 业务角度来说 其实是不需要的
 /// </summary>
 /// <param name="entity">memberiship用户</param>
 /// <returns>领域处理结果</returns>
 public DomainResult DeleteUser(Entity.MemberShip.Membership entity)
 {
     if (IsExistUser(entity.Users.UserName).isSuccess)
     {
         var result = DomainResult.GetDefault();
         try
         {
             Membership.DeleteUser(entity.Users.UserName);
             using (var content = new SiteContext())
             {
                 var other = content.OtherInformations
                     .Where(r => r.Email == entity.Users.UserName).FirstOrDefault();
                 if (other != null)
                 {
                     content.OtherInformations.Remove(other);
                     content.SaveChanges();
                 }
             }
         }
         catch (Exception ex)
         {
             result.isSuccess = false;
             result.error = ex;
             result.ResultMsg = ex.Message;
         }
         return result;
     }
     else
     {
         return new DomainResult(false) { ResultMsg = "用户不存在" };
     }
 }
Exemplo n.º 2
0
 public ProcessInboundRulesResult ProcessRequestUrl(Uri requestUri, List<InboundRule> inboundRules, SiteContext siteContext)
 {
     using (new SiteContextSwitcher(siteContext))
     {
         return ProcessRequestUrl(requestUri, inboundRules);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// 获取物品信息新旧程度相关信息
 /// </summary>
 /// <returns>新旧程度信息列表</returns>
 public List<Entity.FxSite.GoodsCondition> GoodsConditions()
 {
     using (var content = new SiteContext())
     {
         return content.GoodsConditions.OrderBy(r => r.Sorted).ToList();
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// 获取所有的地区包括其级联城市
 /// </summary>
 /// <returns>地区列表(包含相应城市数据)</returns>
 public List<Entity.FxSite.Area> GetAreaDomain()
 {
     using (var content = new SiteContext())
     {
         return content.Areas.Include(r => r.Cities).ToList();
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// 获取所有的地区 顺序排序
 /// </summary>
 /// <returns>地区列表</returns>
 public List<Entity.FxSite.Area> GetAreas()
 {
     using (var content = new SiteContext())
     {
         return content.Areas.OrderBy(r => r.Sorted).ToList();
     }
 }
Exemplo n.º 6
0
 /// <summary>
 /// 获取地区对应的城市 顺序排序
 /// </summary>
 /// <returns>城市列表</returns>
 public List<Entity.FxSite.City> GetCitys(int AreaId)
 {
     using (var content = new SiteContext())
     {
         return content.Cities.Where(r => r.AreaID == AreaId).OrderBy(r => r.Sorted).ToList();
     }
 }
 /// <summary>
 /// 获取所有的一级频道列表
 /// </summary>
 /// <returns></returns>
 public List<Channel> GetAllChannels()
 {
     using (var content = new SiteContext())
     {
         return content.Channels.Include(r=>r.ChannelLists).OrderBy(r => r.Sorted).ToList();
     }
 }
Exemplo n.º 8
0
        public SitecoreSiteLogic(ISitecoreContext currentContext)
        {
            _siteContext = Sitecore.Context.Site;
            _currentContext = currentContext;

            LoadSettings();
        }
Exemplo n.º 9
0
        public IEnumerable<Blog> GetBlogs(SiteContext context)
        {

            var service = GetService(context);
            var items = service.GetCollectionContentItems("blogs");

            if (items == null)
            {
                return null;
            }

            // segment posts by blogs
            var segments = items.Select(x => x.FileName.Split('/')[2]).Distinct();

            var blogs = new List<Blog>();
            foreach(var segment in segments)
            {
                var prefix = string.Format("/blogs/{0}", segment);
                var articles = items.Where(x=>x.FileName.StartsWith(prefix)).Select(x => x.AsArticleWebModel());
                var blog = new Blog() { Id = segment, Handle = segment, Url = prefix, Title = segment, AllArticles = articles.ToArray() };
                blogs.Add(blog);
            }

            return blogs;
        }
        protected virtual WildcardRuleContext RunRules(Item item, SiteContext site)
        {
            Assert.ArgumentNotNull(item, "item");
            //
            //
            var ruleContext = new WildcardRuleContext(item, site);

            if (item.Fields["RoutesPath"] != null)
            {
                RoutesPath = item.Fields["RoutesPath"].Value;
            }

            //find the first route that matches the item
            var query = string.Format(QUERY_ROUTE, RoutesPath, item.ID.ToString());
            var queryItem = Sitecore.Context.Database.SelectSingleItem(query);
            if (queryItem == null)
            {
                return ruleContext;
            }
            //
            //run the rules
            var field = queryItem.Fields["Rules"];
            if (field == null)
            {
                return ruleContext;
            }
            var rules = RuleFactory.GetRules<WildcardRuleContext>(field);
            if (rules == null || rules.Count == 0)
            {
                return null;
            }
            rules.Run(ruleContext);
            return ruleContext;
        }
        public static string GetItemUrl(Item item, SiteContext site)
        {
            Sitecore.Links.UrlOptions options = Sitecore.Links.UrlOptions.DefaultOptions;

            options.SiteResolving = Sitecore.Configuration.Settings.Rendering.SiteResolving;
            options.Site = SiteContext.GetSite(site.Name);
            options.AlwaysIncludeServerUrl = false;

            string url = Sitecore.Links.LinkManager.GetItemUrl(item, options);

            var serverUrl = (new SitemapManagerConfiguration(site.Name)).ServerUrl;

            if (serverUrl.Contains("http://"))
            {
                serverUrl = serverUrl.Substring("http://".Length);
            }
            else if (serverUrl.Contains("https://"))
            {
                serverUrl = serverUrl.Substring("https://".Length);
            }

            StringBuilder sb = new StringBuilder();

            if (!string.IsNullOrEmpty(serverUrl))
            {
                if (url.Contains("://") && !url.Contains("http"))
                {
                    sb.Append("http://");
                    sb.Append(serverUrl);
                    if (url.IndexOf("/", 3) > 0)
                        sb.Append(url.Substring(url.IndexOf("/", 3)));
                }
                else
                {
                    sb.Append("http://");
                    sb.Append(serverUrl);
                    sb.Append(url);
                }
            }
            else if (!string.IsNullOrEmpty(site.Properties["hostname"]))
            {
                sb.Append("http://");
                sb.Append(site.Properties["hostname"]);
                sb.Append(url);
            }
            else
            {
                if (url.Contains("://") && !url.Contains("http"))
                {
                    sb.Append("http://");
                    sb.Append(url);
                }
                else
                {
                    sb.Append(Sitecore.Web.WebUtil.GetFullUrl(url));
                }
            }

            return sb.ToString();
        }
Exemplo n.º 12
0
 /// <summary>
 /// 获取所有的城市数据
 /// </summary>
 /// <returns>城市列表</returns>
 public List<Entity.FxSite.City> GetCities()
 {
     using (var content = new SiteContext())
     {
         return content.Cities.ToList();
     }
 }
		/// <summary>
		/// The crawl.
		/// </summary>
		/// <param name="site">
		/// The site.
		/// </param>
		/// <param name="doc">
		/// The doc.
		/// </param>
		public void Crawl(SiteContext site, XmlDocument doc)
		{
			/*
			 *  We're going to crawl the site layer-by-layer which will put the upper levels
			 *  of the site nearer the top of the sitemap.xml document as opposed to crawling
			 *  the tree by parent/child relationships, which will go deep on each branch before
			 *  crawling the entire site.
			 */
			var max = global::Sitecore.Configuration.Settings.MaxTreeDepth;

			var query = new StringBuilder("fast:" + site.StartPath);

			for (var i = 0; i < max; i++)
			{
				var items = site.Database.SelectItems(DatasourceResolver.EncodeQuery(query.ToString()));

				if (items != null)
				{
					foreach (var item in items)
					{
						var node = SitemapGenerator.CreateNode(item, site);

						if (node.IsPage && node.IsListedInNavigation && node.ShouldIndex)
						{
							SitemapGenerator.AppendUrlElement(doc, node);
						}
					}
				}

				query.Append("/*");
			}
		}
Exemplo n.º 14
0
 public Paginator(SiteContext site, int offset =0)
 {
     this.site = site;
     per_page = Convert.ToInt32(site.Config["paginate"]);
     total_pages = (int)Math.Ceiling(site.Posts.Count / Convert.ToDouble(site.Config["paginate"]));
     total_posts = site.Pages.Count;
     page = offset;
 }
 /// <summary>
 /// Gets a WildcardTokenizedString that represents the URL for the specified item. The return value is built using the Sitecore rules engine.
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public virtual WildcardTokenizedString GetWildcardUrl(Item item, SiteContext site)
 {
     Assert.ArgumentNotNull(item, "item");
     // The item's url is: /blogs/groupa/blog1.aspx
     // 1. Find the Sitecore item that handles the URL
     // 2. Find the wildcard rule that applies to that item
     var context = RunRules(item, site);
     return context.TokenizedString;
 }
 /// <summary>
 /// Determines whether [is fallback enabled for display mode] [the specified site context].
 /// </summary>
 /// <param name="siteContext">The site context.</param>
 /// <returns>
 ///   <c>true</c> if [is fallback enabled for display mode] [the specified site context]; otherwise, <c>false</c>.
 /// </returns>
 public bool IsFallbackEnabledForDisplayMode(SiteContext siteContext)
 {
     return siteContext != null &&
                 (
                     siteContext.DisplayMode == DisplayMode.Normal ||
                     (siteContext.DisplayMode == DisplayMode.Preview && Config.PreviewEnabled) ||
                     (siteContext.DisplayMode == DisplayMode.Edit && Config.EditEnabled)
                 );
 }
Exemplo n.º 17
0
    /// <summary>
    /// Initializes a new instance of the <see cref="ShopContext"/> class.
    /// </summary>
    /// <param name="innerSite">The inner site.</param>
    public ShopContext([NotNull] SiteContext innerSite)
    {
      Assert.ArgumentNotNull(innerSite, "innerSite");

      this.innerSite = innerSite;
      this.database = innerSite.Database;
      this.ordersDatabaseName = innerSite.Properties[OrdersDatabaseKey];
      this.loggingDatabaseName = innerSite.Properties[LoggingDatabaseKey];
    }
Exemplo n.º 18
0
 public Dictionary Get(SiteContext site)
 {
   return new Dictionary()
          {
            Site = site,
            AutoCreate = this.GetAutoCreateSetting(site),
            Root = this.GetDictionaryRoot(site),
          };
 }
Exemplo n.º 19
0
 public void GetSiteDefinition_ItemInSiteHierarcy_ShouldReturnHierarchicalSiteDefinition(SiteContext siteContext, DbItem item , Db db, string siteName)
 {
   var siteDefinitionId = ID.NewID;
   db.Add(new DbItem(siteName, siteDefinitionId, Templates.Site.ID) {item});
   var contextItem = db.GetItem(item.ID);
   var definitionItem = db.GetItem(siteDefinitionId);
   var siteDefinition = siteContext.GetSiteDefinition(contextItem);
   siteDefinition.Item.ID.ShouldBeEquivalentTo(definitionItem.ID);
 }
Exemplo n.º 20
0
    public void GetSiteDefinition_ProviderReturnsEmpty_ShouldReturnNull(ISiteDefinitionsProvider provider, DbItem item, Db db, string siteName)
    {
      db.Add(item);
      var contextItem = db.GetItem(item.ID);

      provider.GetContextSiteDefinition(Arg.Any<Item>()).Returns((SiteDefinition)null);

      var siteContext = new SiteContext(provider);
      siteContext.GetSiteDefinition(contextItem).ShouldBeEquivalentTo(null);
    }
Exemplo n.º 21
0
 private Item GetDictionaryRoot(SiteContext site)
 {
   var dictionaryPath = site.Properties["dictionaryPath"];
   if (dictionaryPath == null)
     throw new ConfigurationErrorsException("No dictionaryPath was specified on the <site> definition.");
   var rootItem = site.Database.GetItem(dictionaryPath);
   if (rootItem == null)
     throw new ConfigurationErrorsException("The root item specified in the dictionaryPath on the <site> definition was not found.");
   return rootItem;
 }
Exemplo n.º 22
0
 private bool GetAutoCreateSetting(SiteContext site)
 {
   var autoCreateSetting = site.Properties["dictionaryAutoCreate"];
   if (autoCreateSetting == null)
     return false;
   bool autoCreate;
   if (!bool.TryParse(autoCreateSetting, out autoCreate))
     return false;
   return autoCreate && (site.Database.Name.Equals(MasterDatabaseName, StringComparison.InvariantCultureIgnoreCase));
 }
Exemplo n.º 23
0
        public void CompressSitemap_compress_existing_sitemap()
        {
            // arrange
            var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData> { { @"C:\website\_site\sitemap.xml", MockFileData.NullObject } });
            var siteContext = new SiteContext { OutputFolder = @"C:\website\_site" };
            
            // act
            new LiquidEngine().CompressSitemap(siteContext, fileSystem);

            // assert
            Assert.True(fileSystem.File.Exists(@"C:\website\_site\sitemap.xml.gz"));
        }
Exemplo n.º 24
0
        public void CompressSitemap_without_existing_sitemap_do_nothing()
        {
            // arrange
            var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData> { });
            var siteContext = new SiteContext { OutputFolder = @"C:\website\_site" };

            // act
            new LiquidEngine().CompressSitemap(siteContext, fileSystem);

            // assert
            Assert.False(fileSystem.File.Exists(@"C:\website\_site\sitemap.xml.gz"));
        }
        public FakeSiteContextSwitcher(SiteContext site) : base(site)
        {
            if (site == null) throw new ArgumentNullException("site");

            _pocket.AddRange(SiteContextFactory.Sites);
            //SiteContextFactory stores cashed data in _searchTable so clearing .Sites is not enough
            SiteContextFactory.Reset();
            //Returning back all sites except Context to avoid duplication
            AddOnlyNew(SiteContextFactory.Sites, _pocket.Where(t => t.Name != site.Name));

            SiteContextFactory.Sites.Add(new SiteInfo(new StringDictionary(ToDictionary(site.Properties))));
        }
Exemplo n.º 26
0
        public override void Process()
        {
            SiteInfo site = ResolveSite(UrlContext.Item);
            SiteContext siteContext = new SiteContext(site);

            UrlOptions options = LinkManager.GetDefaultUrlOptions();
            options.Site = siteContext;
            options.LanguageEmbedding = LanguageEmbedding.Never;
            options.AlwaysIncludeServerUrl = false;

            if (UrlContext.Item.Languages.Count() > 1)
            {
                options.LanguageEmbedding = LanguageEmbedding.AsNeeded;
            }

            SiteUrl siteUrlItem = SiteUrl.GetSiteInfo_ByName(site.Name);
            if(siteUrlItem == null)
            {
                UrlContext.Messages.Add("Unable to find mapping of site to url.");
                return;
            }

            string host = siteUrlItem.Url;
            UrlContext.Url = LinkManager.GetItemUrl(UrlContext.Item, options);
            if(string.IsNullOrEmpty(UrlContext.Url))
            {
                UrlContext.Messages.Add("No Url was returned from Sitecore.");
                return;
            }

            if (UrlContext.Url.Contains("http"))
            {
                Uri uriContext = new Uri(UrlContext.Url);
                // get only the item path
                UrlContext.Url = uriContext.AbsolutePath;
            }

            //remove the 443 port for secured Sitecore instance (if any)
            UrlContext.Url = UrlContext.Url.Replace(":443", "");

            //verify we are not adding the host to a url that already contains a host
            if (!UrlContext.Url.ToLower().Contains(host.ToLower()))
            {
                UrlContext.Url = string.Format("{0}{1}", host, UrlContext.Url);
            }

            //get device item
            if (UrlContext.Device != null && !string.IsNullOrEmpty(UrlContext.Device.QueryString))
            {
                char appender = UrlContext.Url.Contains("?") ? '&' : '?';
                UrlContext.Url = string.Format("{0}{1}{2}", UrlContext.Url, appender, UrlContext.Device.QueryString);
            }
        }
Exemplo n.º 27
0
        public IEnumerable<Page> GetCollection(SiteContext context, string collectioName)
        {
            var service = GetService(context);

            var items = service.GetCollectionContentItems(collectioName);

            if (items == null)
            {
                return null;
            }

            return items.Select(x=>x.AsPageWebModel());
        }
 public VideoReviewsRepository(Item contextItem, SiteContext currentSite)
 {
     if (contextItem == null) 
     {
         throw new ArgumentNullException(nameof(contextItem));
     }
     if (currentSite == null)
     {
         throw new ArgumentNullException(nameof(currentSite));
     }
     this.ContextItem = contextItem;
     this.CurrentSite = currentSite;
 }
Exemplo n.º 29
0
    public virtual SiteInfo GetCurrentSiteInfo(Item contextItem)
    {
      var context = new SiteContext();

      var currentDefinition = context.GetSiteDefinition(contextItem);
      if (currentDefinition == null)
      {
        {
          return null;
        }
      }

      var siteInfo = Factory.GetSiteInfo(currentDefinition.Name);
      return siteInfo;
    }
 /// <summary>
 /// Gets the path.
 /// 
 /// </summary>
 /// <param name="basePath">The base path.</param><param name="path">The path.</param><param name="context">The context.</param>
 /// <returns/>
 protected string GetPath(string basePath, string path, SiteContext context)
 {
     string virtualFolder = context.VirtualFolder;
     if (virtualFolder.Length > 0 && virtualFolder != "/")
     {
         string str = StringUtil.EnsurePostfix('/', virtualFolder);
         if (StringUtil.EnsurePostfix('/', path).StartsWith(str, StringComparison.InvariantCultureIgnoreCase))
             path = StringUtil.Mid(path, str.Length);
     }
     if (basePath.Length > 0 && basePath != "/")
         path = FileUtil.MakePath(basePath, path, '/');
     if (path.Length > 0 && path[0] != 47)
         path = '/' + path;
     return path;
 }
Exemplo n.º 31
0
        public static string GetItemUrl(Item item, SiteContext site, SitemapManagerConfiguration config, Language language = null)
        {
            var options = UrlOptions.DefaultOptions;

            options.SiteResolving          = Sitecore.Configuration.Settings.Rendering.SiteResolving;
            options.Site                   = SiteContext.GetSite(site.Name);
            options.AlwaysIncludeServerUrl = false;
            options.UseDisplayName         = config.UseDisplayName;
            if (language != null)
            {
                options.LanguageEmbedding = config.EnableLanguageEmbedding? LanguageEmbedding.Always: LanguageEmbedding.Never;
                options.Language          = language;
            }

            var url = LinkManager.GetItemUrl(item, options);

            //Sitecore OOTB does not use display name for the home page URLs even if configured.
            //That needs to be corrected
            if (item.Paths.FullPath.Equals(site.StartPath) && !url.EndsWith(item.DisplayName) && config.UseDisplayName)
            {
                url = string.Concat(url, url.EndsWith("/")? "": "/", item.DisplayName);
            }

            var serverUrl = config.ServerUrl;

            var isHttps = false;

            if (serverUrl.Contains("http://"))
            {
                serverUrl = serverUrl.Substring("http://".Length);
            }
            else if (serverUrl.Contains("https://"))
            {
                serverUrl = serverUrl.Substring("https://".Length);
                isHttps   = true;
            }

            var sb = new StringBuilder();

            if (!string.IsNullOrEmpty(serverUrl))
            {
                if (url.Contains("://") && !url.Contains("http"))
                {
                    sb.Append(isHttps ? "https://" : "http://");
                    sb.Append(serverUrl);
                    if (url.IndexOf("/", 3) > 0)
                    {
                        sb.Append(url.Substring(url.IndexOf("/", 3)));
                    }
                }
                else
                {
                    sb.Append(isHttps ? "https://" : "http://");
                    sb.Append(serverUrl);
                    sb.Append(url);
                }
            }
            else if (!string.IsNullOrEmpty(site.Properties["hostname"]))
            {
                sb.Append(isHttps ? "https://" : "http://");
                sb.Append(site.Properties["hostname"]);
                sb.Append(url);
            }
            else
            {
                if (url.Contains("://") && !url.Contains("http"))
                {
                    sb.Append(isHttps ? "https://" : "http://");
                    sb.Append(url);
                }
                else
                {
                    sb.Append(Sitecore.Web.WebUtil.GetFullUrl(url));
                }
            }
            return(sb.ToString());
        }
Exemplo n.º 32
0
 public ReviewRepository(SiteContext db)
 {
     this.db = db;
 }
Exemplo n.º 33
0
 public CreateModel(SiteContext context, UserManager <SiteUser> userManager, IConfiguration configuration)
 {
     _context       = context;
     _userManager   = userManager;
     _configuration = configuration;
 }
        private OpenIdConnectOptions CreateOptions(string name, SiteContext tenant)
        {
            var options = _factory.Create(name);

            // will throw an error if these are not populated
            options.ClientId     = "placeholder";
            options.ClientSecret = "placeholder";
            options.Authority    = "https://placeholder.com";
            options.SignInScheme = IdentityConstants.ExternalScheme;


            if (_environment.IsDevelopment())
            {
                options.RequireHttpsMetadata = false;
            }

            ConfigureTenantOptions(tenant, options);

            if (string.IsNullOrWhiteSpace(options.SignInScheme))
            {
                options.SignInScheme = IdentityConstants.ExternalScheme;
            }

            if (string.IsNullOrEmpty(options.SignOutScheme))
            {
                options.SignOutScheme = options.SignInScheme;
            }

            if (string.IsNullOrEmpty(options.TokenValidationParameters.ValidAudience) && !string.IsNullOrEmpty(options.ClientId))
            {
                options.TokenValidationParameters.ValidAudience = options.ClientId;
            }

            if (options.ConfigurationManager == null)
            {
                if (options.Configuration != null)
                {
                    options.ConfigurationManager = new StaticConfigurationManager <OpenIdConnectConfiguration>(options.Configuration);
                }
                else if (!(string.IsNullOrEmpty(options.MetadataAddress) && string.IsNullOrEmpty(options.Authority)))
                {
                    if (string.IsNullOrEmpty(options.MetadataAddress) && !string.IsNullOrEmpty(options.Authority))
                    {
                        options.MetadataAddress = options.Authority;
                        if (!options.MetadataAddress.EndsWith("/", StringComparison.Ordinal))
                        {
                            options.MetadataAddress += "/";
                        }

                        options.MetadataAddress += ".well-known/openid-configuration";
                    }

                    if (options.RequireHttpsMetadata && !options.MetadataAddress.StartsWith("https://", StringComparison.OrdinalIgnoreCase))
                    {
                        throw new InvalidOperationException("The MetadataAddress or Authority must use HTTPS unless disabled for development by setting RequireHttpsMetadata=false.");
                    }

                    options.ConfigurationManager = new ConfigurationManager <OpenIdConnectConfiguration>(options.MetadataAddress, new OpenIdConnectConfigurationRetriever(),
                                                                                                         new HttpDocumentRetriever(options.Backchannel)
                    {
                        RequireHttps = options.RequireHttpsMetadata
                    });
                }
            }

            return(options);
        }
Exemplo n.º 35
0
 public MakeDeckController(SiteContext db, IHttpContextAccessor httpContextAccessor)
 {
     dataBase          = db;
     curentHttpContent = httpContextAccessor.HttpContext;
 }
Exemplo n.º 36
0
        protected override RenderingReference DoActivateCondition(RenderingDefinition rendering, ID conditionID, Language lang, Database database, Item item, SiteContext site)
        {
            // Copied from Sitecore
            Assert.ArgumentNotNull(rendering, "rendering");
            Assert.ArgumentNotNull(conditionID, "conditionID");
            Assert.ArgumentNotNull(lang, "lang");
            Assert.ArgumentNotNull(database, "database");
            Assert.ArgumentNotNull(item, "item");
            Assert.ArgumentNotNull(site, "site");
            RenderingReference renderingReference             = new RenderingReference(rendering, lang, database);
            RuleList <ConditionalRenderingsRuleContext> rules = renderingReference.Settings.Rules;
            Rule <ConditionalRenderingsRuleContext>     rule  = rules.Rules.FirstOrDefault <Rule <ConditionalRenderingsRuleContext> >((Rule <ConditionalRenderingsRuleContext> r) => r.UniqueId == conditionID);

            if (rule == null)
            {
                return(renderingReference);
            }
            List <RenderingReference> renderingReferences = new List <RenderingReference>()
            {
                renderingReference
            };
            ConditionalRenderingsRuleContext conditionalRenderingsRuleContext = new ConditionalRenderingsRuleContext(renderingReferences, renderingReference)
            {
                Item = item
            };

            rule.SetCondition(new TrueCondition <ConditionalRenderingsRuleContext>());
            rules = new RuleList <ConditionalRenderingsRuleContext>(rule);
            using (SiteContextSwitcher siteContextSwitcher = new SiteContextSwitcher(site))
            {
                using (DatabaseSwitcher databaseSwitcher = new DatabaseSwitcher(item.Database))
                {
                    rules.Run(conditionalRenderingsRuleContext);
                }
            }
            Assert.IsTrue(conditionalRenderingsRuleContext.References.Count == 1, "The references count should equal 1");
            RenderingReference renderingReference1 = conditionalRenderingsRuleContext.References[0];

            Assert.IsNotNull(renderingReference1, "result");
            rendering.Datasource = renderingReference1.Settings.DataSource;
            if (renderingReference1.RenderingItem != null)
            {
                rendering.ItemID = renderingReference1.RenderingItem.ID.ToString();
            }
            // End copied from Sitecore

            // Apply Parameters Too
            rendering.Parameters = renderingReference1.Settings.Parameters;

            return(renderingReference1);
        }
Exemplo n.º 37
0
        public IEnumerable <SitemapModel> GetSitemapItems(SitemapDefinitionModel sitemapDefinition, SiteContext siteContext)
        {
            var sitemapitems = new List <SitemapModel>();
            var urlList      = new List <string>();

            var embedLanguage = sitemapDefinition.EmbedLanguage;
            var db            = Context.Database != null ? Context.Database : Factory.GetDatabase(Sitemap.Constants.WebDatabase);

            var urlOptions = UrlOptions.DefaultOptions;

            urlOptions.AlwaysIncludeServerUrl = true;

            urlOptions.LanguageEmbedding = embedLanguage ? LanguageEmbedding.Always : LanguageEmbedding.Never;

            var items = db.SelectItems($"fast:{siteContext.StartPath}//*")
                        .Where(i => IsSitemapItem(i, sitemapDefinition))
                        .ToList();

            var dynamicItems = this.GetDynamicWildcardItems(siteContext);

            items.AddRange(dynamicItems);

            var startItem = siteContext.GetStartItem();

            if (IsSitemapItem(startItem, sitemapDefinition))
            {
                items.Insert(0, startItem);
            }
            foreach (var item in items)
            {
                var regex = new Regex(@"(\/[A-Za-z0-9]\/)");
                var url   = LinkManager.GetItemUrl(item, urlOptions);
                url = regex.Replace(url, "/").ToLowerInvariant();
                if (urlList.Contains(url))
                {
                    continue;
                }

                urlList.Add(url);
                sitemapitems.Add(new SitemapModel
                {
                    Url          = url,
                    LastModified = item.Statistics.Updated
                });
            }
            return(sitemapitems);
        }
Exemplo n.º 38
0
 public VotesController(SiteContext context)
 {
     _context = context;
 }
Exemplo n.º 39
0
 private static SiteContext GetExmSiteContext()
 {
     return(SiteContext.GetSite(Sitecore.EmailCampaign.Model.Constants.ExmSiteName));
 }
Exemplo n.º 40
0
        public static string GetItemUrl(Item item, SiteContext site)
        {
            Sitecore.Links.UrlOptions options = Sitecore.Links.UrlOptions.DefaultOptions;

            options.SiteResolving          = Sitecore.Configuration.Settings.Rendering.SiteResolving;
            options.Site                   = SiteContext.GetSite(site.Name);
            options.AlwaysIncludeServerUrl = false;

            string url = Sitecore.Links.LinkManager.GetItemUrl(item, options);

            var serverUrl = (new SitemapManagerConfiguration(site.Name)).ServerUrl;

            if (serverUrl.Contains("http://"))
            {
                serverUrl = serverUrl.Substring("http://".Length);
            }
            else if (serverUrl.Contains("https://"))
            {
                serverUrl = serverUrl.Substring("https://".Length);
            }

            StringBuilder sb = new StringBuilder();

            if (!string.IsNullOrEmpty(serverUrl))
            {
                if (url.Contains("://") && !url.Contains("http"))
                {
                    sb.Append("http://");
                    sb.Append(serverUrl);
                    if (url.IndexOf("/", 3) > 0)
                    {
                        sb.Append(url.Substring(url.IndexOf("/", 3)));
                    }
                }
                else
                {
                    sb.Append("http://");
                    sb.Append(serverUrl);
                    sb.Append(url);
                }
            }
            else if (!string.IsNullOrEmpty(site.Properties["hostname"]))
            {
                sb.Append("http://");
                sb.Append(site.Properties["hostname"]);
                sb.Append(url);
            }
            else
            {
                if (url.Contains("://") && !url.Contains("http"))
                {
                    sb.Append("http://");
                    sb.Append(url);
                }
                else
                {
                    sb.Append(Sitecore.Web.WebUtil.GetFullUrl(url));
                }
            }

            return(sb.ToString());
        }
Exemplo n.º 41
0
        protected override void Seed(SiteContext context)
        {
            var users = new List <User>
            {
                new User {
                    Username = "******", Email = "*****@*****.**", Password = "******", Role = Role.user, UserImage = "/Images/generic-user-icon-19.jpg"
                },
                new User {
                    Username = "******", Email = "*****@*****.**", Password = "******", Role = Role.user, UserImage = "/Images/generic-user-icon-19.jpg"
                },
                new User {
                    Username = "******", Email = "*****@*****.**", Password = "******", Role = Role.user, UserImage = "/Images/generic-user-icon-19.jpg"
                },
                new User {
                    Username = "******", Email = "*****@*****.**", Password = "******", Role = Role.user, UserImage = "/Images/generic-user-icon-19.jpg"
                },
                new User {
                    Username = "******", Email = "*****@*****.**", Password = "******", Role = Role.user, UserImage = "/Images/generic-user-icon-19.jpg"
                },
                new User {
                    Username = "******", Email = "*****@*****.**", Password = "******", Role = Role.admin, UserImage = "/Images/generic-user-icon-19.jpg"
                }
            };

            users.ForEach(s => context.Users.AddOrUpdate(p => p.Email, s));
            context.SaveChanges();

            var categories = new List <Category>
            {
                new Category {
                    Name = "Political", catImage = "/Images/political.jpg"
                },
                new Category {
                    Name = "Social", catImage = "/Images/social.jpg"
                },
                new Category {
                    Name = "Economical", catImage = "/Images/economical.jpg"
                },
                new Category {
                    Name = "Human Rights", catImage = "/Images/humanRights.jpg"
                },
                new Category {
                    Name = "LGBTQ", catImage = "/Images/lgbt.jpg"
                },
                new Category {
                    Name = "Animal Rights", catImage = "/Images/animalRights.jpg"
                },
                new Category {
                    Name = "Enviromental", catImage = "/Images/evironmental.jpg"
                },
                new Category {
                    Name = "Internatonal", catImage = "/Images/international.jpg"
                },
                new Category {
                    Name = "Other", catImage = "/Images/other.jpg"
                }
            };

            categories.ForEach(s => context.Categories.AddOrUpdate(p => p.Name, s));
            context.SaveChanges();

            var causes = new List <Cause>
            {
                new Cause {
                    CauseID = 1, CategoryID = categories.Single(s => s.Name == "Internatonal").CategoryID, Title = "Cause1", createdBy = "Username1", UserID = 1, createdOn = DateTime.Parse("2005-09-01"), Description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", Target = 10
                },
                new Cause {
                    CauseID = 2, CategoryID = categories.Single(s => s.Name == "Enviromental").CategoryID, Title = "Cause2", createdBy = "Username2", UserID = 2, createdOn = DateTime.Parse("2005-08-01"), Description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", Target = 20
                },
                new Cause {
                    CauseID = 3, CategoryID = categories.Single(s => s.Name == "Animal Rights").CategoryID, Title = "Cause3", createdBy = "Username3", UserID = 3, createdOn = DateTime.Parse("2005-02-01"), Description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", Target = 30
                },
                new Cause {
                    CauseID = 4, CategoryID = categories.Single(s => s.Name == "LGBTQ").CategoryID, Title = "Cause4", createdBy = "Username4", UserID = 4, createdOn = DateTime.Parse("2005-07-01"), Description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", Target = 30
                },
                new Cause {
                    CauseID = 5, CategoryID = categories.Single(s => s.Name == "Human Rights").CategoryID, Title = "Cause5", createdBy = "Username5", UserID = 5, createdOn = DateTime.Parse("2005-06-01"), Description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", Target = 40
                },
                new Cause {
                    CauseID = 6, CategoryID = categories.Single(s => s.Name == "Economical").CategoryID, Title = "Cause6", createdBy = "Username6", UserID = 6, createdOn = DateTime.Parse("2005-05-01"), Description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", Target = 50
                },
                new Cause {
                    CauseID = 7, CategoryID = categories.Single(s => s.Name == "Social").CategoryID, Title = "Cause7", createdBy = "Username7", UserID = 7, createdOn = DateTime.Parse("2005-04-01"), Description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", Target = 60
                }
            };

            causes.ForEach(s => context.Causes.AddOrUpdate(p => p.CauseID, s));
            context.SaveChanges();

            var signatures = new List <Signature>
            {
                new Signature {
                    UserID = users.Single(s => s.ID == 1).ID, CauseID = causes.Single(c => c.CauseID == 1).CauseID, signedOn = DateTime.Parse("2001-03-01")
                },
                new Signature {
                    UserID = users.Single(s => s.ID == 1).ID, CauseID = causes.Single(c => c.CauseID == 2).CauseID, signedOn = DateTime.Parse("2002-02-02")
                },
                new Signature {
                    UserID = users.Single(s => s.ID == 1).ID, CauseID = causes.Single(c => c.CauseID == 2).CauseID, signedOn = DateTime.Parse("2002-02-02")
                },
                new Signature {
                    UserID = users.Single(s => s.ID == 1).ID, CauseID = causes.Single(c => c.CauseID == 3).CauseID, signedOn = DateTime.Parse("2003-01-03")
                },
                new Signature {
                    UserID = users.Single(s => s.ID == 1).ID, CauseID = causes.Single(c => c.CauseID == 4).CauseID, signedOn = DateTime.Parse("2004-02-04")
                },
                new Signature {
                    UserID = users.Single(s => s.ID == 1).ID, CauseID = causes.Single(c => c.CauseID == 5).CauseID, signedOn = DateTime.Parse("2005-03-05")
                },
                new Signature {
                    UserID = users.Single(s => s.ID == 2).ID, CauseID = causes.Single(c => c.CauseID == 1).CauseID, signedOn = DateTime.Parse("2007-04-06")
                },
                new Signature {
                    UserID = users.Single(s => s.ID == 2).ID, CauseID = causes.Single(c => c.CauseID == 2).CauseID, signedOn = DateTime.Parse("2008-05-06")
                },
                new Signature {
                    UserID = users.Single(s => s.ID == 2).ID, CauseID = causes.Single(c => c.CauseID == 3).CauseID, signedOn = DateTime.Parse("2005-06-07")
                },
                new Signature {
                    UserID = users.Single(s => s.ID == 3).ID, CauseID = causes.Single(c => c.CauseID == 1).CauseID, signedOn = DateTime.Parse("2010-08-08")
                },
                new Signature {
                    UserID = users.Single(s => s.ID == 3).ID, CauseID = causes.Single(c => c.CauseID == 2).CauseID, signedOn = DateTime.Parse("2011-07-09")
                },
                new Signature {
                    UserID = users.Single(s => s.ID == 3).ID, CauseID = causes.Single(c => c.CauseID == 3).CauseID, signedOn = DateTime.Parse("2012-06-10")
                },
                new Signature {
                    UserID = users.Single(s => s.ID == 3).ID, CauseID = causes.Single(c => c.CauseID == 4).CauseID, signedOn = DateTime.Parse("2013-05-11")
                },
                new Signature {
                    UserID = users.Single(s => s.ID == 4).ID, CauseID = causes.Single(c => c.CauseID == 2).CauseID, signedOn = DateTime.Parse("2014-04-12")
                },
                new Signature {
                    UserID = users.Single(s => s.ID == 4).ID, CauseID = causes.Single(c => c.CauseID == 3).CauseID, signedOn = DateTime.Parse("2015-03-13")
                },
                new Signature {
                    UserID = users.Single(s => s.ID == 4).ID, CauseID = causes.Single(c => c.CauseID == 4).CauseID, signedOn = DateTime.Parse("2016-02-12")
                },
                new Signature {
                    UserID = users.Single(s => s.ID == 4).ID, CauseID = causes.Single(c => c.CauseID == 5).CauseID, signedOn = DateTime.Parse("2017-02-14")
                },
                new Signature {
                    UserID = users.Single(s => s.ID == 4).ID, CauseID = causes.Single(c => c.CauseID == 6).CauseID, signedOn = DateTime.Parse("2018-01-15")
                }
            };

            foreach (Signature e in signatures)
            {
                var signatureInDatabase = context.Signatures.Where(
                    s => s.User.ID == e.UserID && s.Cause.CauseID == e.CauseID).SingleOrDefault();
                if (signatureInDatabase == null)
                {
                    context.Signatures.Add(e);
                }
            }
            context.SaveChanges();
        }
Exemplo n.º 42
0
 public QuizResultsController(SiteContext context)
 {
     _context = context;
 }
 public SiteUsersController(SiteContext context)
 {
     _context = context;
 }
Exemplo n.º 44
0
        public static string GeneratePackage(PackageManifest manifest)
        {
            var packageProject = new PackageProject
            {
                Metadata =
                {
                    PackageName = manifest.PackageName,
                    Author      = manifest.Author,
                    Version     = manifest.Version,
                    Publisher   = manifest.Publisher
                }
            };

            foreach (var fileSource in manifest.Files)
            {
                if (fileSource == null || fileSource.Entries == null || fileSource.Entries.Count == 0)
                {
                    continue;
                }

                var packageFileSource = new ExplicitFileSource
                {
                    Name = "Files"
                };

                packageFileSource.Converter.Transforms.Add(
                    new InstallerConfigurationTransform(
                        new BehaviourOptions(fileSource.InstallMode, fileSource.MergeMode)));

                foreach (var item in fileSource.Entries)
                {
                    var pathMapped = MainUtil.MapPath(item.Path);

                    packageFileSource.Entries.Add(pathMapped);
                }

                if (packageFileSource.Entries.Count > 0)
                {
                    packageProject.Sources.Add(packageFileSource);
                }
            }


            foreach (var itemSource in manifest.Items)
            {
                if (itemSource == null || itemSource.Entries == null || itemSource.Entries.Count == 0)
                {
                    continue;
                }

                List <Item> items             = new List <Item>();
                var         packageItemSource = new ExplicitItemSource
                {
                    Name = itemSource.Name
                };

                packageItemSource.Converter.Transforms.Add(
                    new InstallerConfigurationTransform(
                        new BehaviourOptions(itemSource.InstallMode, itemSource.MergeMode)));

                using (new SecurityDisabler())
                {
                    foreach (var item in itemSource.Entries)
                    {
                        var db = ResolveDatabase(item.Database);

                        var itemUri = db.Items.GetItem(item.Path);
                        if (itemUri != null)
                        {
                            items.Add(itemUri);

                            if (item.IncludeChildren)
                            {
                                var    paths         = Sitecore.StringUtil.Split(itemUri.Paths.Path, '/', true).Where(p => p != null & p != string.Empty).Select(p => "#" + p + "#").ToList();
                                string allChildQuery = string.Format("/{0}//*", Sitecore.StringUtil.Join(paths, "/"));
                                var    children      = db.Items.Database.SelectItems(allChildQuery);

                                if (children != null && children.Length > 0)
                                {
                                    items.AddRange(children);
                                }
                            }
                        }
                    }

                    foreach (var item in items)
                    {
                        packageItemSource.Entries.Add(new ItemReference(item.Uri, false).ToString());
                    }
                }

                if (packageItemSource.Entries.Count > 0)
                {
                    packageProject.Sources.Add(packageItemSource);
                }
            }

            packageProject.SaveProject = true;

            var  location = MainUtil.MapPath($"{ Sitecore.Configuration.Settings.PackagePath}/{ manifest.PackageName}");
            bool exists   = System.IO.Directory.Exists(location);

            if (!exists)
            {
                System.IO.Directory.CreateDirectory(location);
            }

            var packagePath = $"{location}/{manifest.PackageName}.zip";

            try
            {
                using (var writer = new PackageWriter(packagePath))
                {
                    using (new SecurityDisabler())
                    {
                        SiteContext targetSiteContext = SiteContext.GetSite("shell");
                        using (var context = new SiteContextSwitcher(targetSiteContext))
                        {
                            writer.Initialize(Installer.CreateInstallationContext());

                            PackageGenerator.GeneratePackage(packageProject, writer);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception($"Package was not created. Message: {ex.Message}", ex);
            }


            return(packagePath);
        }
Exemplo n.º 45
0
        protected void Run(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull((object)args, "args");
            parentItemID = args.Parameters["itemid"];
            Item itemNotNull = Sitecore.Client.GetItemNotNull(args.Parameters["itemid"], Language.Parse(args.Parameters["language"]));

            if (args.IsPostBack)
            {
                if (!args.HasResult)
                {
                    return;
                }
                string[] strArray    = args.Result.Split(new[] { "||" }, StringSplitOptions.None);
                string   id          = strArray[0];
                string   name        = Uri.UnescapeDataString(strArray[1]);
                string   displayName = Uri.UnescapeDataString(strArray[2]);
                string   metaTitle   = Uri.UnescapeDataString(strArray[3]);
                if (ShortID.IsShortID(id))
                {
                    id = ShortID.Parse(id).ToID().ToString();
                }
                BranchItem branch = Sitecore.Client.ContentDatabase.Branches[id, itemNotNull.Language];
                Assert.IsNotNull((object)branch, typeof(BranchItem));
                this.ExecuteCommand(itemNotNull, branch, name);
                Sitecore.Client.Site.Notifications.Disabled = true;
                Item obj = Context.Workflow.AddItem(name, branch, itemNotNull);
                Sitecore.Client.Site.Notifications.Disabled = false;
                if (obj == null)
                {
                    return;
                }
                this.PolicyBasedUnlock(obj);
                if (!HasPresentationPipeline.Run(obj) || !MainUtil.GetBool(args.Parameters["navigate"], true))
                {
                    WebEditCommand.Reload();
                }
                else
                {
                    UrlOptions  defaultOptions = UrlOptions.DefaultOptions;
                    SiteContext site           = SiteContext.GetSite(string.IsNullOrEmpty(args.Parameters["sc_pagesite"]) ? Sitecore.Web.WebEditUtil.SiteName : args.Parameters["sc_pagesite"]);
                    if (site == null)
                    {
                        return;
                    }
                    string url = string.Empty;
                    using (new SiteContextSwitcher(site))
                    {
                        using (new LanguageSwitcher(obj.Language))
                            url = LinkManager.GetItemUrl(obj, defaultOptions);
                    }
                    WebEditCommand.Reload(new UrlString(url));
                }
                SetDisplayNameAndMetaTitle(obj, displayName, metaTitle);
            }
            else if (!itemNotNull.Access.CanCreate())
            {
                SheerResponse.Alert("You do not have permission to create an item here.");
            }
            else
            {
                UrlString urlString = ResourceUri.Parse("control:Applications.WebEdit.Dialogs.AddMaster").ToUrlString();
                itemNotNull.Uri.AddToUrlString(urlString);
                SheerResponse.ShowModalDialog(urlString.ToString(), "1200px", "700px", string.Empty, true);
                args.WaitForPostBack();
            }
        }
 public UserRepository(SiteContext context)
 {
     this.context = context;
 }
Exemplo n.º 47
0
 /// <summary>
 /// Create a new instance.
 /// </summary>
 /// <param name="site">The site to add to the model.</param>
 public AddSite(SiteContext site)
 {
     _site = site;
 }
Exemplo n.º 48
0
 public ProcessInboundRulesResult ProcessRequestUrl(Uri requestUri, List <InboundRule> inboundRules, SiteContext siteContext, Database database)
 {
     using (new SiteContextSwitcher(siteContext))
         using (new DatabaseSwitcher(database))
         {
             return(ProcessRequestUrl(requestUri, inboundRules));
         }
 }
Exemplo n.º 49
0
        public bool BidOnAuction(ISession session, double offer)
        {
            if (session is null)
            {
                throw new ArgumentNullException();
            }
            if (offer < 0)
            {
                throw new ArgumentOutOfRangeException();
            }
            if (EndsOn < _alarmClock.Now)
            {
                throw new InvalidOperationException();
            }
            using (var context = new SiteContext(_connectionString))
            {
                var site = context.Sites.SingleOrDefault(a => a.SiteName == Site.Name);
                if (site is null)
                {
                    throw new InvalidOperationException();
                }
                if (Seller.Equals(session.User))
                {
                    throw new ArgumentException();
                }
                if (!session.IsValid())
                {
                    throw new ArgumentException();
                }

                var user = site.Users.SingleOrDefault(a => a.Username == session.User.Username);
                if (user is null)
                {
                    throw new InvalidOperationException();
                }
                var auction = site.Auctions.SingleOrDefault(a => a.Id == Id);
                if (auction is null)
                {
                    throw new InvalidOperationException();
                }
                (session as Session)?.Update(_alarmClock.Now.AddSeconds(site.SessionExpirationTimeInSeconds));

                if (CurrentBid == Status.New)
                {
                    if (offer < Price)
                    {
                        return(false);
                    }
                    CurrentBid     = Status.Changed;
                    maxOffer       = offer;
                    auction.Winner = user;
                    context.SaveChanges();
                    return(true);
                }

                if (auction.Winner.Equals(user))
                {
                    if (offer <= maxOffer + site.MinimumBidIncrement)
                    {
                        return(false);
                    }
                    maxOffer = offer;
                    context.SaveChanges();
                    return(true);
                }

                if (offer < auction.CurrentPrice || offer < auction.CurrentPrice + site.MinimumBidIncrement)
                {
                    return(false);
                }
                if (offer > maxOffer)
                {
                    Price          = auction.CurrentPrice = Math.Min(offer, maxOffer + site.MinimumBidIncrement);
                    maxOffer       = offer;
                    auction.Winner = user;
                    context.SaveChanges();
                    return(true);
                }

                if (maxOffer > offer)
                {
                    Price = auction.CurrentPrice = Math.Min(maxOffer, offer + site.MinimumBidIncrement);
                    context.SaveChanges();
                    return(true);
                }
                return(false);
            }
        }
Exemplo n.º 50
0
 public ExamsService(SiteContext db)
 {
     _db = db;
 }
Exemplo n.º 51
0
 public CategoryRepository(SiteContext context) : base(context)
 {
 }
Exemplo n.º 52
0
 public SupplierController(SiteContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
Exemplo n.º 53
0
 public WidgetTypeController(SiteContext db)
 {
     this.db = db;
 }
 public static Item ItemResolverSettings(this SiteContext site)
 {
     return(Settings(site, Constants.ConfigKey.ItemResolverSettingsConfig));
 }
 public LanguageRepository(SiteContext siteContext, BaseLinkManager linkManager)
 {
     this.SiteContext = siteContext;
     this.LinkManager = linkManager;
 }
        public static bool IsMallSite(this SiteContext site)
        {
            var siteRoot = Context.Database.GetItem(site.RootPath);

            return(siteRoot.IsDerived(Templates.MallSite.ID));
        }
Exemplo n.º 57
0
 public UserRoleStoreTests()
 {
     _orgCtx    = _uth.GetsiteContext();
     _appDb     = _orgCtx.AppDb;
     _userStore = _uth.GetUserStore();
 }
        private static Item Settings(this SiteContext site, string settings)
        {
            var path = site?.Properties[settings];

            return(path != null && site.Database != null?site.Database.GetItem(path) : null);
        }
Exemplo n.º 59
0
 public SiteSettingsProvider(SiteContext siteContext)
 {
     this.siteContext = siteContext;
 }
        public PagedSearchResult <ISearchResult> Search(ISearchContext searchContext, SiteContext siteContext, bool isCollectionSearch = false)
        {
            using (var context = ContentSearchManager.GetIndex(SiteContext.Current.GetIndexName()).CreateSearchContext())
            {
                var paginationOptions = searchContext.PaginationOptions ?? new PaginationOptions();
                var query             = context.GetQueryable <LuceneSearchResultItem>();
                var predicate         = _predicateBuilder.Build <LuceneSearchResultItem>(searchContext);

                var queryable = _filterBuilder.Build(query, searchContext, siteContext, isCollectionSearch);
                queryable = queryable.Where(predicate);

                // change this to just result.ContentTags if you do not want hierarchical faceting
                queryable = queryable.FacetOn(result => result.ContentTagsFacet);
                queryable = queryable.FacetOn(result => result.AutomatedTags);

                // sorting
                var sorter = searchContext.GetSorter();
                queryable = sorter.Sort(queryable);

                // execute query
                return(_searchResultFactory.ToPagedSearchResult(queryable, paginationOptions));
            }
        }