Пример #1
0
        /// <summary>
        /// Gets the site content for given site id.
        /// </summary>
        /// <param name="id">Site id</param>
        /// <typeparam name="T">The site model type</typeparam>
        /// <returns>The site content model</returns>
        public async Task <T> GetContentByIdAsync <T>(Guid id) where T : SiteContent <T>
        {
            SiteContentBase model = null;

            if (!typeof(DynamicSiteContent).IsAssignableFrom(typeof(T)))
            {
                model = _cache?.Get <SiteContentBase>($"SiteContent_{id}");

                if (model != null)
                {
                    await _factory.InitAsync(model, App.SiteTypes.GetById(model.TypeId));
                }
            }

            if (model == null)
            {
                model = await _repo.GetContentById <T>(id).ConfigureAwait(false);

                await OnLoadContentAsync(model).ConfigureAwait(false);
            }

            if (model != null && model is T)
            {
                return((T)model);
            }
            return(null);
        }
Пример #2
0
		private async Task OnLoadContentAsync(SiteContentBase model)
		{
			V_0.u003cu003e4__this = this;
			V_0.model = model;
			V_0.u003cu003et__builder = AsyncTaskMethodBuilder.Create();
			V_0.u003cu003e1__state = -1;
			V_0.u003cu003et__builder.Start<SiteService.u003cOnLoadContentAsyncu003ed__22>(ref V_0);
			return V_0.u003cu003et__builder.get_Task();
		}