Questions tagged [asp.net-mvc]
Model-View-Controller for the ASP.NET framework
236
questions
1
vote
1
answer
101
views
Display items from DB using MVC and Domain Driven Design
I am starting a project to put into practice the lessons learned in "Clean Code" by Robert "Uncle Bob" Martin.
The project is a website that displays the names of items in a DB table. It uses ASP.NET ...
4
votes
4
answers
4k
views
Find consecutive numbers and turn them into ranges
I have array
int[] arr = { -2, 0, 1, 2, 3, 4, 5, 8, 9, 11, 13, 15, 18, 22, 25, 28, 29, 30 };
I need to write function that shows it as string and if numbers are ...
2
votes
1
answer
88
views
IsDatabaseUp returns true or throws exception
I want to write an ASP.NET Web API endpoint that allows clients to check if database is running.
The method below is check if database is up by establishing a connection and running a dummy sql ...
2
votes
2
answers
334
views
EventLogger for MVC application
I have worked on one application related for booking space and required to store activity of user into table and access from admin side.
For that I have created one database entity and ...
2
votes
1
answer
330
views
Apply Coupon Validation in Order
I have created a mvc application for booking space. In this for booking user can applied coupon for booking.
I have implemented one coupon service and validate coupon.
...
0
votes
2
answers
388
views
Common Implementation for Sending mail based on time
I have created one Background service that execute after every 5 minutes and this service used for sending email after 6 hour,24 hour and 48 hour for user booking order is not confirmed.
for that i ...
1
vote
1
answer
2k
views
HttpClient wrapper for simple calls with optional cert
Trying to ensure each controller contains it's own httpclient. The super user can change which endpoint is called from the site and some of those endpoints do not require a certificate, but some ...
6
votes
3
answers
2k
views
CQS implementation with decorators
Edit
I've put all this into a nuget package and on github under "MetalCore.CQS" at https://github.com/MetalKid/MetalCore.CQS
End Edit
I've created a "framework" or more of a ...
2
votes
0
answers
1k
views
RESTful API combining three other APIs
I have created a RESTful API that uses three other APIs with Visual Studio 2017 in .NET Core. It is the first time I have ever programmed in .NET so I am sure the code could use a lot of improvements. ...
2
votes
2
answers
3k
views
Separating paging, sorting and filtering
in my ASP.NET MVC application I have a service that had a method for paging, sorting and filtering of Vehicle Makes:
...
1
vote
1
answer
378
views
Calculating difference in time
In table first value I have value with datatype = Start
I need to calculate difference first value - midnight
Last value is ...
1
vote
1
answer
58
views
A service that returns paged Products with optional filtering
In order to better understand what the code does, I've captured this screencast.
Basically, I have a products page and a user can filter products.
CODE
Here is the ...
0
votes
3
answers
3k
views
Repository with ViewModel (ASP.NET MVC)
I have db table Model.
Here is code:
...
3
votes
1
answer
2k
views
Implementing integration tests in ASP.NET core using InMemory database
I am building a web application using ASP.NET core. Most of the tests in my application are unit tests, so I mocked every dependencies in order to have fast unit tests. On the other hand I am of the ...
4
votes
0
answers
4k
views
Logging in ASP.Net MVC project
I want to implement a Logger and use Serilog as Provider. My Project is ASP.NET MVC Framework (not core).
Initially I tried to replicate ASP.Net Core Logging framework. I created a ...
0
votes
1
answer
3k
views
use Identity value in entity after insert in Database [closed]
i want to generate value using current date and ID of inserted entity
problem is that ID value not generated until insert object to database,
so i use this code for generate value:
...
0
votes
1
answer
217
views
Validating a Domain or Service Method [closed]
I'm trying to determine at which level I should validate a method on my class. In my class method I throw an exception if it ever gets to that point. In my service layer I do some validation and ...
2
votes
2
answers
4k
views
MVC simple Employee table with paging using SP
I am a beginner web developer and I have to do an exercise to show an Employee table using a WCF service, 10 entries at a time, with the paging of the table controlled by a stored procedure. What I ...
1
vote
1
answer
176
views
Performance concerns for synchronous action methods
I have an ASP.NET MVC 5 application using Entity Framework with SQL Server 2016. The application is mainly basic CRUD. The boilerplate generated when creating the project in Visual Studio did not have ...
4
votes
2
answers
24k
views
Creating a list with nested lists
I have made algorithms to create a list with nested lists in order to then show them in a tree view. From what users told me, my view method is fine, but the way I create the final list is probably ...
7
votes
2
answers
1k
views
Validation for a CQS system that throws an exception
I've been reading that exceptions should only be for something "exceptional" and not used to control the flow of a program. However, with a CQS implementation, this seems impossible unless I start ...
4
votes
2
answers
8k
views
Handing "Others" option in dropdown in ASP.Net MVC 5
Business Logic
I have a company referral form, and in that form I have dropdown to select from a company list. But when a company is not found in the dropdown, the user can select option as "others", ...
3
votes
2
answers
2k
views
Using Alertify to show messages
I use a JavaScript library called Alertify to show simple, pretty messages, like "note created", or whatever. Often I want to send the user to a new page and then show an Alertify message.
I'm ...
3
votes
1
answer
16k
views
Display a dropdown based on another dropdown change
I have a dropdown and when that dropdown changes I want to display/render another dropdown. Can someone help me improve it?
So, a person requests for getting referred in a company for a job. When ...
3
votes
2
answers
4k
views
Using attributes with properties in asp.net MVC
I have an auto generated partial class in my Model folder with lots of properties and I need to modify some of the setters in these properties(annotate property), to ensure that I don't repeat myself ...
2
votes
1
answer
2k
views
Entity Framework - Table structure, navigating many descendants, etc
Someone suggested to try asking this here instead of stackoverflow, so I'm taking their advice.
So I'm rewriting a dated application and trying to structure things the right way. I have a Category > ...
1
vote
1
answer
41
views
Dual rewrite rules (WWW prefix and HTTPS)
I want to configure my website to force a www. prefix on the name, and the HTTPS protocol.
...
4
votes
2
answers
3k
views
Log Visitor Count in Asp.net MVC
I have a table to Log visitor Count Like :
...
2
votes
2
answers
5k
views
Async ASP.NET MVC 5 controller method
I'm attempting to correctly convert a synchronous controller method to asynchronous, given that the operation it performs is CPU-intensive.
...
4
votes
1
answer
130
views
Read project setting in asp.net mvc
I have a Table that I store All setting in that , it is like below :
...
2
votes
1
answer
95
views
Add colour tags on click
I have implemented some extra functionality for the tag-it JavaScript plugin, where I need an option where availableTags are displayed in one box, and the user can ...
1
vote
1
answer
1k
views
Counting matching rows in IQueryable
I'm designing a basic ticketing system using ASP.NET MVC with Entity Framework.
I'm passing a DbSet<TicketModel> into a method as an ...
2
votes
1
answer
1k
views
Retrieving values from Entity Framework DbContext to render in a ListBox
I need to pass a ViewModel to a strongly typed View which will display a multiple-select box using Html.ListBoxFor. My ViewModel has a ...
1
vote
1
answer
2k
views
MVC OnActionExecuted - session cookie - expire after x minutes of inactivity
first time poster here.
I'm creating a session cookie which should expire after 30 minutes of user inactivity. I've added the following code to the base controllers OnActionExecuted method.
...
6
votes
1
answer
631
views
Unit test for a CreateUser() method using JustMock lite
I'm new to unit testing and have created a unit test for a create user action method and it's passing the test. I'm not sure if this is the right way to unit test a create method.
This is my test ...
1
vote
0
answers
1k
views
Asset management system
I'm relatively new to developing and I'm mostly self taught so a lot of what I know simply comes from googling & figuring things out from there!
That being said I've put together an ASP MVC ...
2
votes
1
answer
47
views
Code allowed to test mail invitations by users (from another post) on an instance of Visual studio debugging
I am currently working on an application in ASP.Net MVC, with a SQL Server 2016 database and Entity Framework 6.
The application can process specific data and generate forms (in DOC format), and in ...
4
votes
1
answer
745
views
Wrappers For Performing SQL Transactions
I am trying to make my ASP.NET MVC application use transactions for all database operations, to ensure safety when there are multiple users. To do this, I have created static methods in my ...
4
votes
1
answer
1k
views
Refactoring ViewModel and mapping from multiple sources
I need to refactor and tidy the following controller below, it's my first MVC application. I've successfully used AutoMapper as I began refactor controllers but I am not sure how to approach a ...
-1
votes
1
answer
4k
views
ASP.NET MVC multi language website
What is the best way to make an ASP.NET MVC multi language website?
The following code is what I use, but I need to make sure from your real-world experience that my code is the best way for ...
3
votes
1
answer
373
views
Save model to database
I recently asked a question on Software Engineering and I had a comment:
The updated version has some issues which are out of topic here. You may consider posting it at codereview.stackexchange.com ...
6
votes
2
answers
7k
views
"Forgot password" functionality
I want to implement the "forgot password" functionality in Asp.Net MVC 5. Here is the code flow:
Take user email ID
Let the user enter the token received in his email inbox
If the token matches then ...
3
votes
2
answers
336
views
linq.Any() check on large database
Is there a way to speed up the Linq.Any check or perform the check in another way to enhance performance.
I have a mastercodes table that records unique codes for a campaign. The code below will ...
2
votes
1
answer
69
views
Get a grouped list with relational data
I am new to C# and am leaning ASP.NET MVC and Entity Framework and I am trying to create an application where a user can manager Job Postings and Applicants where an Applicant can apply for many Jobs.
...
6
votes
1
answer
6k
views
Update URL with new parameter value in controller action
I have an action that takes an id as a parameter and gets the corresponding item with the help of a web service. The web service's method that returns the item will either return the item with the ...
2
votes
2
answers
4k
views
PagedList with large data sets
I'm using X.PagedList for paging functionality in my application. The code I have works fine but when I return larger sets of data it seems like it could be faster. Is there anything I can do to my ...
2
votes
1
answer
5k
views
HttpClient Wrapper supports ignoring invalid/self-signed certs
I'm using the following as a wrapper for the HtptClient because it doesn't implement an interface -- which makes mocking more difficult. This logic also supports invalid and self-signed certs.
...
3
votes
2
answers
459
views
Cloudinary upload call takes too long
I have the following async ActionResult.
...
1
vote
2
answers
113
views
1
vote
0
answers
986
views
.NET MVC Infinite Child record add
Here is my working attempt to allow multiple/infinite child record entries with the original parent post in .NET MVC. Any refactoring to simplify my code would be greatly appreciated:
Controller:
<...