Base solution for your next web application

Activities of "sayram"

Hi guys. I'm trying to implement some functionality to my Abp Mvc 5.x MPA pplication like password reset email confirmation.

i was using these lines of code before reading that [https://github.com/aspnetboilerplate/module-zero/issues/50])

//var provider = new DpapiDataProtectionProvider("VapeKit");

//_userManager.UserTokenProvider = new DataProtectorTokenProvider<User, long>(provider.Create("ASP.NET Identity")) //{
    //TokenLifespan = TimeSpan.FromHours(3)
//};

after reading solution installed Abp.Zero.Owin. to my Web Project. Added DependsOn(typeof(AbpZeroOwinModule)) to web module.

finally i add app.RegisterDataProtectionProvider(); to Owin Startup class.

So far so good everything seems works now but i want to set TokenLifespan = TimeSpan.FromHours(3). How to setup this one?

Thank you very much.

I've istalled Visual Studio yesterday. I'm practicing modular and plugin system. I've big troubleshot with creating module solution and/or projects.

There are 3 dfferent class library template in visual studio. I downloaded ModularTodoApp sample. Right clicked to one of the projects. Forexample Core project. And the clicked to Properties. It seems the project .Net Framework 4.6.1 class library. And project hierarchy i can see Dependencies node. But if i create .Net Framework 4.6.1 Class Lirary project there is no Dependencies node.

Well, i created Class Library (.Net Core) i can see Dependencies node but i the Properties windows project is ot .Net 4.6.1 but .NetCoreApp 1.1

I'm new .Net Core and ofcourse Abp Asp.NEt Core 1.x.

Is there any way to create module projects like TodoModule? Any template? Which class library i have to you for asp.net core?

Thank you.

Can't we use AbpController.SettingManager in Constructor of ControllerBase?

protected IndexControllerBase()
        {
            LocalizationSourceName = IndexConsts.LocalizationSourceName;
            ViewBag.Theme = SettingManager.GetSettingValue(IndexSettingProvider.CurrentTheme); 
        }

Returns "Object reference not set to an instance of an object."

I'm trying to pass current theme setting to all view via ViewBag.

this is the _Layout file in shared dir.

@{ 
    Layout = ViewBag.Theme;
}

@RenderBody()

@RenderSection("styles", required: false)

@RenderSection("scripts", required: false)

I've an entity name Listing like below.

public class Listing : FullAuditedEntity<long, User>, IPassivable
    {}

I'm studing EntityCaching here. <a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Caching#entity-caching">http://www.aspnetboilerplate.com/Pages/ ... ty-caching</a>

I created these codes by respecting documentation.

public interface IListingCache : IEntityCache<ListingDto>
    {

    }

    public class ListingCache : EntityCache<Listing, ListingDto>, IListingCache, ITransientDependency
    {
        public ListingCache(ICacheManager cacheManager, IRepository<Listing, long> repository)
            : base(cacheManager, repository)
        {

        }
    }

At coding time there are errors like below

Listings.Listing' cannot be used as type parameter 'TEntity' in the generic type or method 'EntityCache<TEntity, TCacheItem>'. There is no implicit reference conversion from Listings.Listing' to 'Abp.Domain.Entities.IEntity<int>'.

Listings.Listing, long>' to 'Abp.Domain.Repositories.IRepository<Listings.Listing, int>'

These errors dis appears if i change Entity id type to int from long. So, question is basic. Cant i use EntityCache with long type? Or should i use ICacheManager?

By the way im not familiar with these caching things. What is different between ICacheManager and EntityCache? Ty.

Using FullAuditedEntity<long, User> provides Creator id. This is not actually a releationship. To store creator id if we use FullAuditedEntity we lost the Navigation in User entity. This confuses me.

Forexample:

public class Post : FullAuditedEntity<long, User> { .. }

We can access to Post's create Id. (Not name or others) Well, what if i want to get User's posts? There will be no Posts navigation in User entity. Do i have to query with creator id? Is this?

SoftDelete pattern is good. In normal query sofdeleted record doesnt fetch. What about the Published and UnPublished records?

I need something like this.

public enum ContentState
    {
        Published = 1,
        UnPublished = 0
    }

In normal query unpublished records has not to be fetched also. Do i have to modify core or can i extend the ABP?

In two days i'm trying to build Role View. In fuct working permissions is beats me. But i decide to try what can i do.

I reasearched JsTree and Mvc at google. And i found Recursive and FlasObject samples.

public class FlatObject
    {
        public string Id { get; set; }
        public string ParentId { get; set; }
        public string Data { get; set; }

        public FlatObject(string name, string id, string parentId)
        {
            Data = name;
            Id = id;
            ParentId = parentId;
        }

    }
    public class RecursiveObject
    {
        public string Data { get; set; }
        public string Id { get; set; }
        public FlatTreeAttribute Attr { get; set; }
        public List<RecursiveObject> Children { get; set; }
    }

    public class FlatTreeAttribute
    {
        public string id;
        public bool selected;
    }

this is the create action of RoleController

public ActionResult Create()
        {

            var permissions = _permissionManager.GetAllPermissions(multiTenancySides: Abp.MultiTenancy.MultiTenancySides.Tenant);

            List<FlatObject> flatObject = new List<FlatObject>();

            foreach (var item in permissions)
            {
                if (item.Parent != null)
                {
                    flatObject.Add(new FlatObject(item.Name, item.Name, item.Parent.Name));
                }
                else
                {
                    flatObject.Add(new FlatObject(item.Name, item.Name, ""));
                }
            }

            var recursiveObjects = FillRecursive(flatObject, "");

            var viewModel = new CreateEditRoleViewModel
            {
                Permissions = recursiveObjects
            };

            return View(viewModel);
        }
private static List<RecursiveObject> FillRecursive(List<FlatObject> flatObjects, string parentId)
        {
            List<RecursiveObject> recursiveObjects = new List<RecursiveObject>();

            foreach (var item in flatObjects.Where(x => x.ParentId.Equals(parentId)))
            {
                recursiveObjects.Add(new RecursiveObject
                {
                    Data = item.Data,
                    Id = item.Id,
                    Children = FillRecursive(flatObjects, item.Id)
                });
            }

            return recursiveObjects;
        }

and here is the ViewModel

public class CreateEditRoleViewModel
    {
        public RoleDto Role { get; set; }
        //public IReadOnlyList<Permission> Permissions { get; set; }
        public List<RecursiveObject> Permissions { get; set; }
    }

Create View

<div id="data">
                                        <ul>
                                            @foreach (var item in Model.Permissions)
                                            {
                                                <li class="jstree-open">
                                                    @item.Data
                                                    <ul>
                                                        @foreach (var child in item.Children)
                                                        {
                                                            <li class="jstree-open">@child.Data</li>
                                                        }
                                                    </ul>
                                                </li>
                                            }
                                        </ul>
                                    </div>

and finally the java script

$(document).ready(function () {
    $('#data').jstree({

        "plugins": ["checkbox"]
    });

    $('#data').on("changed.jstree", function (e, data) {
        if (data.selected.length) {
            $(data.selected).each(function (idx) {
                var node = data.instance.get_node(data.selected[idx]);
            });
        }
    });
});

and the result.

Well, 1-) How can i get the selected roles for current user and reflect it to the jsTree. 2-) How can i handle the post values?

thank you.

I'm trying to build Category part for my application back-end. In Index action ill list Categories and its sub categories.

Here is my Category entity

public class Category : Entity<int>
    {
        public virtual int? ParentId { get; set; }
        public virtual string Title { get; set; }
        public virtual string Description { get; set; }
        public virtual string MetaDescription { get; set; }
        public virtual string MetaKeys { get; set; }
        public virtual int Order { get; set; }
        public virtual Category ParentCategory { get; set; }
        public virtual ICollection<Category> SubCategories { get; set; }
        public virtual ContentState ContentState { get; set; }
    }

    public enum ContentState
    {
        Published = 1,
        UnPublished = 0,
        Featured = 2,
        Trashed = -1
    }

I created Dtos like below

public class GetAllCategorySummariesInput : IInputDto
    {
        public ContentState? ContentState { get; set; }
    }

    public class GetAllCategorySummariesOutput : IOutputDto
    {
        public List<CategorySummaryDto> AllCategorySummaries { get; set; }
    }

    [AutoMap(typeof(Category))]
    public class CategorySummaryDto : EntityDto
    {
        public string Title { get; set; }
        public int Order { get; set; }
        public List<CategorySummaryDto> SubCategories { get; set; }
    }

in service class im using this code

public GetAllCategorySummariesOutput GetAllCategorySummaries(GetAllCategorySummariesInput input)
        {

            var catList = _categoryRepository.GetAll().Where(x => x.ContentState == input.ContentState).OrderBy(x => x.Id).ToList();

            return new GetAllCategorySummariesOutput
            {
                AllCategorySummaries = catList.MapTo<List<CategorySummaryDto>>()
            };
        }

This one is seems works fine. But, i only want Id, Title, Order and SubCategories

so i tried something like this:

var catList = _categoryRepository.GetAll().Where(x => x.ContentState == input.ContentState).Select(x => new { x.Id, x.Title, x.SubCategories, x.Order }).OrderBy(x => x.Id).ToList();

But im getting "Missing type map configuration or unsupported mapping." error at runtime detailed below

Missing type map configuration or unsupported mapping.\r\n\r\nMapping types:\r\n<>f__AnonymousType04 -> CategorySummaryDto\r\n<>f__AnonymousType04[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Collections.Generic.ICollection1[[YouScene.Categories.Category, YouScene.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] -> YouScene.Categories.Dtos.CategorySummaryDto\r\n\r\nDestination path:\r\nList1[0]\r\n\r\nSource value:\r\n{ Id = 2, Title = Michael Fassbender, SubCategories = System.Collections.Generic.HashSet`1[YouScene.Categories.Category], Order = 0 }"}

Well, i said "if door is not open for me, ill look for another one. "

Here.

var catList = _categoryRepository.GetAll().Where(x => x.ContentState == input.ContentState).Select(x => new CategorySummaryDto { Id = x.Id, Title =  x.Title, SubCategories = x.SubCategories, Order = x.Order }).OrderBy(x => x.Id).ToList();

when i change the code like above 'SubCategories = x.SubCategories' shows error

Cannot implicitly convert type 'System.Collections.Generic.ICollection<YouScene.Categories.Category>' to 'System.Collections.Generic.List<YouScene.Categories.Dtos.CategorySummaryDto>'. An explicit conversion exists (are you missing a cast?)

She is right. Category is not CategorySummaryDto.

So i changed the code like below followed by a final hope

var catList = _categoryRepository.GetAll().Where(x => x.ContentState == input.ContentState).Select(x => new CategorySummaryDto { Id = x.Id, Title =  x.Title, SubCategories = x.SubCategories.MapTo&lt;List&lt;CategorySummaryDto&gt;>(), Order = x.Order }).OrderBy(x => x.Id).ToList();

in design time everything was seems good.

But when i run the code she throwed an error again.

Additional information: LINQ to Entities does not recognize the method 'System.Collections.Generic.List1[YouScene.Categories.Dtos.CategorySummaryDto] MapTo[List1](System.Object)' method, and this method cannot be translated into a store expression.

As become a beginner i can use Abp but i want to use full functional, write better code and understand things how they work. Documentations not for beginners and i have a lot of questions that confuses me.

So can anybody please explain Why, Where, When, How i have to use AutoMap, AutoMapTo, AutoMapFrom?

And i need real sample about Permissions and settings usage. Change, Create, Update from control panel. How you guys done these?

Thank you.

How to query UserLogins? with UserManager? I'm confused.

Showing 1 to 10 of 13 entries