Base solution for your next web application

Activities of "sayram"

If im not missunderstood, you may want to use

[NotMapped]
        public string Fullname
        {
            get
            {
                return FirstName + " " + LastName;
            }
        }

in User class. And put the fullname in Output class

i faced similar problem too when i use @L("Login") in my custum views. Outputs was like [Login]. After second compile it worked fine.

Good to know it about ViewPageBase

<cite>hikalkan: </cite> Hi,

For implementing permissions, you may want to check this: <a class="postlink" href="http://www.aspnetzero.com/Documents/Developing-Step-By-Step#authorization-for-phone-book">http://www.aspnetzero.com/Documents/Dev ... phone-book</a> It's almost same for module-zero.

How to create permission grant page. There is hierarchical list there. Permissions are consts in a class.

Did you also created a list or something like that?

<cite>apexdodge: </cite> I'm actually considering creating a Udemy course on ABP and creating SaaS applications. Not sure when I'll be able to get around to it though.

up!

ill be waiting for the course. esspecially implementing permissions and settings.

<cite>hikalkan: </cite> Hi,

Managers does exists from the beginning. They are not new (see UserManager, RoleManager... and so on). There are not replacement of repositories. Do not misunderstand it. They are domain services (what is domain service? <a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Domain-Services">http://www.aspnetboilerplate.com/Pages/ ... n-Services</a>).

So, you can use repositories in your code, no problem here.

So, why we use domain services (managers). Because, we may need to perform some business logic. For example: we may need to check user name uniqueness while creating a user. If we encapsulate it into a manager, we can use same logic from different part of our application. Or we can have a method to check if a user is granted for a permission (see <a class="postlink" href="https://github.com/aspnetboilerplate/module-zero/blob/master/src/Abp.Zero/Authorization/Users/AbpUserManager.cs#L153">https://github.com/aspnetboilerplate/mo ... er.cs#L153</a>). Then we can create such a method to the manager and use it from different application services.

You don't have to write a manager (domain service) for every entity. It's completely depend on your needs and architectural decisions.

A note: you don't have to understand EditionManager, just learn how to use it (<a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Zero/Edition-Management">http://www.aspnetboilerplate.com/Pages/ ... Management</a>). That's encapsulation :)

I hope I could help you.

Thank you bro. Come to us with those. :)

There is no step by step tutorial. But documentation can be found here.

Abp is not for beginners. Abp is good for intermediate and experienced coders.

Abp is devoloping only by one coder. So, pray to god for examples :)

But, yeah i want tutorials too. Settings, permissions etc.

<cite>hikalkan: </cite>

  1. See this code:
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();

catList is a List of an anonymous type! Since anonymous types are dynamic, you can not define a mapping (like [AutoMap(typeof(Category))]). So, you can use AutoMapper's dynamic mapping. It should be something like that, but search on web:

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

That dynamic things worked fine. But!

Sql Server Profiler reported that query when _categoryRepository run.

SELECT 
    [Project1].[Id] AS [Id], 
    [Project1].[Title] AS [Title], 
    [Project1].[Order] AS [Order], 
    [Project1].[ContentState] AS [ContentState], 
    [Project1].[C1] AS [C1], 
    [Project1].[Id1] AS [Id1], 
    [Project1].[ParentId] AS [ParentId], 
    [Project1].[Title1] AS [Title1], 
    [Project1].[Description] AS [Description], 
    [Project1].[MetaDescription] AS [MetaDescription], 
    [Project1].[MetaKeys] AS [MetaKeys], 
    [Project1].[Order1] AS [Order1], 
    [Project1].[ContentState1] AS [ContentState1]
    FROM ( SELECT 
        [Extent1].[Id] AS [Id], 
        [Extent1].[Title] AS [Title], 
        [Extent1].[Order] AS [Order], 
        [Extent1].[ContentState] AS [ContentState], 
        [Extent2].[Id] AS [Id1], 
        [Extent2].[ParentId] AS [ParentId], 
        [Extent2].[Title] AS [Title1], 
        [Extent2].[Description] AS [Description], 
        [Extent2].[MetaDescription] AS [MetaDescription], 
        [Extent2].[MetaKeys] AS [MetaKeys], 
        [Extent2].[Order] AS [Order1], 
        [Extent2].[ContentState] AS [ContentState1], 
        CASE WHEN ([Extent2].[Id] IS NULL) THEN CAST(NULL AS int) ELSE 1 END AS [C1]
        FROM  [dbo].[Category] AS [Extent1]
        LEFT OUTER JOIN [dbo].[Category] AS [Extent2] ON [Extent1].[Id] = [Extent2].[ParentId]
    )  AS [Project1]
    ORDER BY [Project1].[Id] ASC, [Project1].[C1] ASC

exec sp_executesql N'SELECT 
    [Extent1].[Id] AS [Id], 
    [Extent1].[ParentId] AS [ParentId], 
    [Extent1].[Title] AS [Title], 
    [Extent1].[Description] AS [Description], 
    [Extent1].[MetaDescription] AS [MetaDescription], 
    [Extent1].[MetaKeys] AS [MetaKeys], 
    [Extent1].[Order] AS [Order], 
    [Extent1].[ContentState] AS [ContentState]
    FROM [dbo].[Category] AS [Extent1]
    WHERE [Extent1].[ParentId] = @EntityKeyValue1',N'@EntityKeyValue1 int',@EntityKeyValue1=9

As you can see all fields selected. I put breakpoint after the _categoryRepository, only selected fields returned, not all of them. I need some research about this i gues.

Thank you this tip.

<cite>hikalkan: </cite>

Eventually, your working case is good for me.

I need more samples. About ViewModels, Dtos.

İddiayı tutturayım alıcam zeroyu görmem lazım senin kodları. :) Teşekkürler yardımların için.

Answer

MVC derken Multi Page mi diyorsun? Mpa örneği yok. Sadece template i var.

<a class="postlink" href="http://aspnetzero.com">http://aspnetzero.com</a>

burada istediğin şey satışa sunulmuş durumda. Biraz pahalı tabii.

Aslına bakarsan Abp'nin ücretsiz dağıtılıyor olması bile çok hoş bişi. İleri düzey kodlanmış olması benim gibi kullanıcılar için sıkıntı yaratıyor ancak öğreniyoruz. Ben bu settings, permissions, dto,üçgeninden alnımın akıyla bir çıkayım. Güzel bir demo hazırlamak istiyorum.

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.

<cite>sampath: </cite> Hi, A 1 :

ASP.NET Boilerplate provides several attributes and extension methods to define mappings. To use it, add Abp.AutoMapper nuget package to your project. Then, use attribute AutoMap for two way mapping, AutoMapFrom and AutoMapTo for one way mapping. Use MapTo extension methods to map one object to another. Example mapping definition:

Hope this will help to you. Good Luck ! :)

Let say we have a category entity like below.

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 Category ParentCategory { get; set; }
        public virtual ICollection<Category> SubCategories { get; set; }
        public virtual ContentState ContentState { get; set; }
    }

IInputDto

public class CategorySummaryInput : IInputDto
    {
        public ContentState ContentState { get; set; }
    }

IOutputDto

public class CategorySummaryOutput : IOutputDto
    {
        public IList<CategorySummaryDto> Categories { get; set; }
    }

CategorySummaryDto

[AutoMap(typeof(Category))]
    public class CategorySummaryDto : EntityDto
    {
        public int? ParentId { get; set; }
        public string Title { get; set; }
        public string Description { get; set; }
        public IList<CategorySummaryDto> SubCategories { get; set; }
    }

In Admin/Categories/Index view, I'll be needed sub categories of current category.

How can i map

public virtual ICollection<Category> SubCategories { get; set; }

to

public IList<CategorySummaryDto> SubCategories { get; set; }
Showing 11 to 20 of 30 entries