public void SetBuildingEntity(T model, EntityScheme scheme, TCategory primaryCat) { _entity = model; _entity.Url = _urlBuilder.GenrateUrlSegment(_entity.Url ?? _entity.Title); _entity.Scheme = scheme; _entity.PrimaryCategory = primaryCat; }
public static EntitySchemeLiquidViewModel AsLiquidAdaptedWithEntities(this EntityScheme scheme, PaginatedEntities entities) { var adapted = scheme.AsLiquidAdapted(); adapted.Entities = entities.Entities.AsLiquidAdapted(); adapted.AllPagesCount = entities.AllPagesCount; adapted.CurrentPage = entities.CurrentPage; return(adapted); }
public async Task <PaginatedEntities> GetBySchemeAsync(EntityScheme scheme, int pageNumber) { var query = _accessManager.Filter(_query .Include(x => x.PrimaryCategory) .Include(x => x.Fields) .Include(x => x.Creator) .Include(x => x.RelatedCategories) .Include(x => x.Tags) .Include(x => x.Scheme) .Include(x => x.Fields.Select(f => f.FieldDefenition)) .Where(x => x.SchemeId == scheme.Id)); return(new PaginatedEntities { AllPagesCount = query.GetAllPagesCount(FrontEndDeveloperOptions.Instance.Pagination.Default), CurrentPage = pageNumber, Entities = await query.OrderByDescending(x => x.PublishDateTime) .Skip((pageNumber - 1) * FrontEndDeveloperOptions.Instance.Pagination.Default) .Take(FrontEndDeveloperOptions.Instance.Pagination.Default) .ToListAsync() }); }
public Task ShouldValidateIncommingFields() { // arrange var builder = new GenericIEntityBuilder <Entity, Category>(_factoryProvider, new UrlBuilder()); var entity = new Entity() { Handle = "test url ssss ssss" }; var textFieldDefenition = new FieldDefenition() { Title = "text1", Type = "text", IsRequired = true, Id = Guid.NewGuid() }; var numberFieldDefenition = new FieldDefenition() { Title = "number", Type = "number", IsRequired = true, Id = Guid.NewGuid() }; var entityScheme = new EntityScheme() { FieldDefenitions = new List <FieldDefenition>() { textFieldDefenition, numberFieldDefenition } }; var textFactory = new TextFieldFactory(); var numberFactory = new NumberFieldFactory(); // act builder.SetBuildingEntity(entity, entityScheme, new Category() { FieldDefenitions = new List <FieldDefenition>() }); var text = textFactory.CreateNew("text1", "hello world", null); var number = numberFactory.CreateNew("number", 5, null); var textField = new Field() { RawValue = text.Value, FieldDefenition = textFieldDefenition }; var numberField = new Field() { RawValue = number.Value, FieldDefenition = numberFieldDefenition }; var liquidAdapter = new EntityLiquidAdapter(); liquidAdapter.FieldFactoryProvider = _factoryProvider; liquidAdapter.Entity = builder.GetResult(); Template t = Template.Parse("text is {{entity.text1}} and number is {{entity.number}}"); var actual = t.Render(Hash.FromAnonymousObject(new { entity = liquidAdapter })); //assert Console.WriteLine(actual); return(Task.FromResult(0)); }
public Task <PaginatedEntities> GetBySchemeAsync(EntityScheme scheme, int pageNumber) { return(_service.GetBySchemeAsync(scheme, pageNumber)); }
public static EntitySchemeLiquidViewModel AsLiquidAdapted(this EntityScheme scheme) { return(Mapper.Map <EntitySchemeLiquidViewModel>(scheme)); }
public static EntitySchemeViewModel MapToViewModel(this EntityScheme model) { return(Mapper.Map <EntitySchemeViewModel>(model)); }
public static EntityScheme MapToExisting(this EntitySchemeUpdateViewModel viewModel, EntityScheme model) { return(Mapper.Map(viewModel, model)); }