13
votes
Accepted
ViewModel creator design
I would say your design is fine. In general I advise injecting IHandleViewModel<T> implementations directly into consumers, because this makes it easier to ...
- 381
11
votes
Unit testing with dependency injection and MOQ
There are a number of issues in your code.
Naming. Methods should use verb phrases to denote the action they perform and try to be specific. So your DateList ...
- 7,142
10
votes
Accepted
MVC binding list of values to checkboxlist in an efficient way
In my opinion, your view is doing too much work. This is happening because your model is missing a property.
If you add an IsSelected property to your model, I ...
- 30.8k
10
votes
Accepted
Implementing IDisposable for an Excel class
Almost.
From the MSDN docs on the Disposable Pattern:
✓ DO allow the Dispose(bool) method to be called more than once. The
method might choose to do nothing ...
- 30.8k
8
votes
Accepted
Pagination implementation for a blog system
int num
What does num represent exactly? Number of pages? Number of posts per page? Current page number? Properly naming the ...
- 11.6k
7
votes
7
votes
Accepted
7
votes
Accepted
Writing a thin navigation controller
The responsability of a controller is to create ViewModels and return them. This usually imply some boilerplate code, creating new instances, setting parameters, ...
- 12.3k
7
votes
Combating magic strings in a web application
First point, these extensions are really cool.
I don't have much comments to give, your code looks pretty good!
The ActionInfo class could be simplified a little :...
- 12.3k
7
votes
Accepted
ASP controller for tracking equipment
Index
It would appear you primarily do three things here. Sort, Filter, and Page. There's not much to say about your paging, but the sorting and filtering logic clutter the action. Try creating an ...
- 1,961
7
votes
EventLogger for MVC application
Again enums should not have any prefix. Drop all those Enum_! You may like to take a look to .NET Naming Guidelines.
Inside the class ...
- 10.4k
6
votes
Accepted
Is it an anti-pattern to let ViewModel fill itself from a domain object?
It's not an anti pattern. At some point, one layer must know about the layer underneath. You also don't want to rewrite view-model mapping code in multiple controllers or actions, nor do you want to ...
- 5,589
6
votes
Monkeying around with Survey Monkey and Asp.Net Mvc
ASP.NET MVC will produce a controller instance for each request, so you need a bit of help from the framework to assist you with caching - because anything you cache at controller level will only live ...
- 74.9k
6
votes
Accepted
6
votes
ASP.NET core proper way to work with the repository pattern
Better? Probably...
All your repositories look almost identical, only the served type is different. Therefore, you may as well turn to generic repository. In its elementary form, adopting your ...
- 2,000
6
votes
Accepted
User can add and delete customers
You don't need to enumerate twice here
var temp = _context.Users.AsEnumerable().ToList();
You can just call .ToList().
<...
- 8,428
6
votes
Find consecutive numbers and turn them into ranges
Letting a single method do everything is not such a good idea. You should rather separate the logic for finding consecutive numbers from creating a string from ranges and let them produce the final ...
- 44k
5
votes
Accepted
MVC refactoring parameter check
The primary intent of your function is to get Patient instance. Secondary intent is to notify of the error. You should always attempt to translate the intent to code and function names. So, your ...
- 448
5
votes
A set of Razor HTML helpers for disabling elements
With the danger of not understanding your question entirely as it stands now, you have MyEntitiesViewModel with a enabled field. ...
- 11.5k
5
votes
Accepted
Method GetById and SingleResult
You can wrap the single entity into an IQueryable. Something like this should work:
SingleResult.Create(new[]{entity}.AsQueryable());
You could write a helper ...
- 1,905
5
votes
Keeping data processing out of controllers
Your brace style is inconsistent. Allman style is usually applied in C#.
public class AppUser{
// snipped
}
public class AddressDetails
{
// snipped
}
<...
- 11.1k
5
votes
Accepted
Embedding an RSS feed into a page after it's already loaded
A couple of really quick comments:
jQuery provides a load function which simplifies your code. There's also a shorthand for $(document).ready(function() {}); which ...
- 16.7k
5
votes
Recurring tasks in ASP.NET MVC
As already mentioned by Anders, the second approach is better, however there are several problems when implementing async Tasks that run within an ...
- 1,786
5
votes
Accepted
Expose an IDbSet<> object to overcome a limitation for LINQ's Select()
Leaky as an old roof :)
An abstraction is leaky if you need to know details about the concrete implementation in order to work with it properly. Leakiness of an interface may reveal itself in various ...
- 2,000
5
votes
Accepted
Reading and displaying an image from a folder
You could simplify your getImage() method pretty significantly to just:
...
- 24.2k
5
votes
Accepted
Implementing integration tests in ASP.NET core using InMemory database
I went through the very same conflict and eventually looked at what other frameworks were doing. What you'll find with the above implementation is that it is okay for a couple hundred tests, but soon ...
- 166
5
votes
Apply Coupon Validation in Order
IsAppliedCouponValid()
Don't omit braces although they might be optional. Omitting braces can lead to hidden and therfor hard to find bugs.
The intermediate variables ...
- 50.1k
5
votes
DDD Architecture for an e-commerce website (uploading images)
at first I thought to write this as a comment, perhaps the comment would be a little to long…
There are many things to consider here, not really inline with your question but perhaps you should ...
- 454
5
votes
DDD Architecture for an e-commerce website (uploading images)
Review
Modelling the domain is crucial when designing a multi-layered application. Your concerns about polutting the domain with file or web specific code is pivotal to make a clean, extensible, ...
- 13.9k
5
votes
Accepted
DDD Architecture for an e-commerce website (uploading images)
Architecture
DDD-wise : The most important thing about DDD is that the domain drives the design (so.. DDD). That means that when we look at your domain objects we should be able to understand the ...
- 12.3k
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
asp.net-mvc × 240c# × 230
entity-framework × 41
asp.net × 28
mvc × 18
razor × 16
asp.net-web-api × 15
javascript × 14
design-patterns × 13
linq × 13
dependency-injection × 12
unit-testing × 11
performance × 10
beginner × 10
asp.net-mvc-5 × 10
jquery × 8
repository × 8
html × 7
.net × 7
ajax × 6
asp.net-core × 6
authorization × 6
security × 5
error-handling × 5
object-oriented × 4