Base solution for your next web application

Activities of "sayram"

I found a working "hack" to pass data to all views.

I created a service named ISettingService and implemented here.

public class SettingService : ApplicationService, ISettingService
    {
        public string GetTheme()
        {
            return SettingManager.GetSettingValue(IndexSettingProvider.CurrentTheme);
        }
    }

I inject ISettingService in ControllerBase.

public abstract class IndexControllerBase : AbpController
    {
        private readonly ISettingService _settingService;

        protected IndexControllerBase(ISettingService settingService)
        {
            _settingService = settingService;

            LocalizationSourceName = IndexConsts.LocalizationSourceName;
            ViewBag.Theme = _settingService.GetTheme();
        }
}

And in each controller i created their constructor

public class HomeController : IndexControllerBase
    {

        public HomeController(ISettingService settingService): base(settingService)
        {

        }

        public ActionResult Index()
        {
            return View();
        }

	}

this way is works. But the ugly way i believe.

<cite>ismcagdas: </cite>

But in my opinion, don't do that, just query posts with creatorUserId=[someUserId],

Why? Is it about performance or something else?

Last step is registering the filter in PreInitialize method of module (i did it in Core Module). And i set it true to fetch only Published = true entries.

First parameter is same unique name we defined before. Second parameter indicates whether this filter is enabled or disabled by default. After declaring such a parametric filter, we can use it by supplying it's value on runtime .

Configuration.UnitOfWork.RegisterFilter("PublishedFilter", true);

That true parameter means: only published entries will be fetch, right?

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.

Showing 1 to 10 of 17 entries