Base solution for your next web application

Activities of "apexdodge"

Question

Reading this documentation here: <a class="postlink" href="http://aspnetboilerplate.com/Pages/Documents/Data-Transfer-Objects">http://aspnetboilerplate.com/Pages/Docu ... er-Objects</a>

It is recommended to always use a DTO for input and output for all application service methods. That is fine, despite the groans from my devs about the added work -- I see the benefits.

My question is about ViewModels.

Should we have ViewModel for every DTO as well? Or is it common practice to send the DTO straight to the end user in the presentation layer?

Likewise for accepting data -- Should a form submission go to a ViewModel first, which is then mapped to a DTO, which is then mapped to an Entity. Or do form submissions go straight to DTO?

Any reasoning for either option would be much appreciated.

Thanks.

Dynamic Content / Form Builder is definitely a hard task.

For the database schema, your best bet is to follow what is known as an EAV pattern.. It has it's drawbacks (namely performance), but it is effective. EAV stands for Entity-Attribute-Value and you can read more about it here: <a class="postlink" href="https://en.wikipedia.org/wiki/Entity%E2%80%93attribute%E2%80%93value_model">https://en.wikipedia.org/wiki/Entity%E2 ... alue_model</a> and here is a good example of usage: <a class="postlink" href="http://programmers.stackexchange.com/questions/204097/dynamic-form-builder-forms-and-database-design">http://programmers.stackexchange.com/qu ... ase-design</a>

An alternative is to use a NoSQL database for this type of storage, like MongoDb.

On the client side, there are plenty of Angular approaches to showing a form dynamically. You can google search that fine. That's actually the easier part when it comes to all this.

i came up with a half-decent solution. if anyone wants sample code, let me know

Hi there, so I've created my own custom data filter following these directions: <a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Data-Filters">http://www.aspnetboilerplate.com/Pages/ ... ta-Filters</a>

However, the whole point of me creating the filter was so that I can call something like _articleRepository.GetAllList() without hassle. But in order to actually use the filter, I have to specify:

using(CurrentUnitOfWork.SetFilterParameter("ProductFilter", "productId", productId))
    {
        var articles = _articleRepository.GetAllList();
    }

If I have to do that every time I call my articleRepository, I might as well just abandon the filter and continue doing _articleRepository.GetAll().Where(p => p.ProductId == productId)...

I would like to know two things:

  1. The built-in filters like IMustHaveTenant and ISoftDelete don't need to be set the filter parameter every time I make a call unless I want to specifically override something. How / where did you set that filter parameter so that it need not be specified every time I make a call?

  2. The parameter of productId is passed in manually but I would like to pull the value from the url automatically like /admin/product/5/articles (5 in this case) --- what's the best way to pull from that when setting filter parameter?

Thanks so much.

...I've had no issues with ABP and Azure Web Apps at all, but maybe it's because of the way I deploy my database.

My recommendation is to load up sql management studio and export your local database by doing Export Data Tier Application. Then connect to your Azure Database Server also and Import Data Tier Application (the one you just exported). In Visual Studio, do a Web Deploy and choose your Azure Web App and also your DB. It should automatically detect your database. Deploy, and you're good to go.

No need to futz around with the code to get it to work at all.

I was wondering if anyone had a best practice for tracking which notifications have been read.

Let's assume you have a bubble at the top with the number of unread notifications, like on Facebook.

Currently ABP supports subscribe / publish. But I can't find anywhere automatically built in for tracking which notifications have been read and which haven't.

Anyone do this with ABP's notification framework yet?

I'm thinking I add my own table ReadNotifications with the following columns:

Id UserId NotificationsId CreationTime

Then I only add a row to this table once a notification has been read for this user. If a notification Id along with the user Id does not appear in this table, then you can assume it was not read.

I feel like that is not the best way though? Is it a table scan every time you need to check if each notification was read or not? Could get really slow.

My other idea to add a column to the AbpUsers table:

UnreadNotificationsIds

Then comma separate the notification ids that have not been read there. But I feel this is also not clean? This would be faster than the first approach probably.

Looking for your thoughts.

Thanks!

Answer

Yeah, hangfire provides you with a live dashboard at <a class="postlink" href="http://">http://</a><your-site>/hangfire

<a class="postlink" href="http://hangfirechinese.readthedocs.org/en/latest/quick-start.html">http://hangfirechinese.readthedocs.org/ ... start.html</a>

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.

Answer

Sure thing. I created a file in my .Web project called BackgroundTaskFactory.cs. It's just a static class where each function would wrap the calling of a service layer function. In the case below, I have SearchAppService and I want to call its DestroyAndCreateArticlesIndex().

public static class BackgroundTaskExecuter
    {
        public static void DestroyAndCreateArticlesIndex()
        {
            using (var service = IocManager.Instance.ResolveAsDisposable<SearchAppService>())
            {
                service.Object.DestroyAndCreateArticlesIndex();
            }
        }
    }

Then to use it, I call

BackgroundJob.Enqueue(() => BackgroundTaskExecuter.DestroyAndCreateArticlesIndex());
Answer

Would love to see your sample code.

I only got Hangfire working by creating a Static Class and manually invoking IocResolver. It's not pretty and not the way I wanted to accomplish it in my original post, but it works. I can share that solution here if anyone is interested as well.

On a side note, even with my above solution, Hangfire isn't working with Lazy Loading in EntityFramework. I had to write my own Repository and create a method that pulls data in an eager fashion.

I did not anticipate so much headache considering how 'easy' the hangfire.io website makes it look in getting started haha.

Showing 1 to 10 of 29 entries