Skip to main content
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 ...
Shelby115's user avatar
  • 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 ...
Adriano Repetti's user avatar
7 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 ...
IEatBagels's user avatar
  • 12.4k
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 ...
Gert Arnold's user avatar
  • 2,030
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(). <...
Denis's user avatar
  • 8,508
6 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 ...
jaredcnance's user avatar
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 ...
t3chb0t's user avatar
  • 44.3k
5 votes
Accepted

Reading and displaying an image from a folder

You could simplify your getImage() method pretty significantly to just: ...
svick's user avatar
  • 24.3k
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 ...
Gert Arnold's user avatar
  • 2,030
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 ...
Heslacher's user avatar
  • 50.4k
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 ...
Walter Vehoeven's user avatar
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, ...
dfhwze's user avatar
  • 13.9k
5 votes
Accepted

Creating a round robin MySQL connection manager

Aliveness issue As it is, your code does not perform the task you expect it to, because the LoadBalancer never reinstates "dead" connection pools. Notice that you only ever set ...
Vogel612's user avatar
  • 25.2k
5 votes

Repository pattern with Unit of work using ADO.NET in C# to authenticate user from database

Side-effects On its own, this: ...
Reinderien's user avatar
  • 62.5k
4 votes

Method GetById and SingleResult

[EnableQuery] and SingleResult does in fact return 404 OOTB, that is one of the key reasons for ...
Chris Schaller's user avatar
4 votes
Accepted

Search for variants of keywords using LINQ

It seems weird or unusual that you're assigning products from products. products is your <...
Mathieu Guindon's user avatar
4 votes
Accepted

Properly create and customise a web app using visual studio 2015 C# MVC template

The short answer to what you are trying to do is; let the Identity classes handle Authentication and User management. You can put your User into a Model class of it's own. Then reference that from the ...
Steven Tomlinson's user avatar
4 votes

ASP.NET Product Listing

I would definitely remove the database access from the Category partial view and move it to the Controller (you can add it to the view model or have a separate action for returning them which is even ...
Stefano d'Antonio's user avatar
4 votes

Method which handle HttpResposeMessage

I see this method does currently two things: it creates the error message and it throws an exception. This is too much and should be separated. You should extract a method that creates the error ...
t3chb0t's user avatar
  • 44.3k
4 votes

Method which handle HttpResposeMessage

Considering that there is no else to if (!response.IsSuccessStatusCode), you should do: ...
BCdotWEB's user avatar
  • 11.2k
4 votes
Accepted

Update URL with new parameter value in controller action

I believe you want RedirectToActionPermanent: ...
Jason P's user avatar
  • 156
4 votes
Accepted

Save model to database

if (model == null || UserInfo.UserID == 0) { throw new Exception("GroupBillingPayment object or Current User Id is NULL , Please Contact Administrator."); } You ...
t3chb0t's user avatar
  • 44.3k
4 votes
Accepted

Read project setting in asp.net mvc

Quick note first, _cash should be _cache dictionary definition: a temporary storage space or memory that allows fast access ...
RobH's user avatar
  • 17k
4 votes

Log Visitor Count in Asp.net MVC

First of all I'd make code in Application_BeginRequest little bit more self-explicative: ...
Adriano Repetti's user avatar
4 votes
Accepted

HttpClient wrapper for simple calls with optional cert

As is this does not work because multiple requests will concurrently operate on the same variables (instance variables and HttpClient internal state as it is being configured). This is fairly easy to ...
usr's user avatar
  • 715
4 votes

Common Implementation for Sending mail based on time

First of all you do not need to prefix all your enum with Enum_, the same way you do not do it with ...
Adriano Repetti's user avatar
4 votes
Accepted

IsDatabaseUp returns true or throws exception

The naming convention Is… implies that the function is a predicate, returning either true or false. If you wanted to throw an exception when the database is down, ...
200_success's user avatar
4 votes
Accepted

Extending IPrincipal.IsInRole()

IsInRole() I don't like how the method parameters are validated. IMO the null-propagation operator shouldn't be used for everything because it reduces the readability. Having a null-propagation ...
Heslacher's user avatar
  • 50.4k
4 votes
Accepted

Instantiating View Models using a static factory

That class can still be abstracted public interface IAdSummaryMapper { List<IAdSummary> MapAdSummaries(List<AdResult> esResults); } The search ...
Nkosi's user avatar
  • 3,246
4 votes

DDD Architecture for an e-commerce website (uploading images)

Thank you for an interesting question 😊 Here is the first part of the answer, I will publish more over the weekend at https://github.com/dmitrynogin/shopless. Let’s talk about storage access first. ...
Dmitry Nogin's user avatar
  • 6,131

Only top scored, non community-wiki answers of a minimum length are eligible