Questions tagged [asp.net-mvc]

Model-View-Controller for the ASP.NET framework

Filter by
Sorted by
Tagged with
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 ...
Maxime's user avatar
  • 351
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 ...
Balance's user avatar
  • 61
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 ...
Pingpong's user avatar
  • 139
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 ...
Lalji Dhameliya's user avatar
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. ...
Lalji Dhameliya's user avatar
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 ...
Lalji Dhameliya's user avatar
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 ...
asunrey's user avatar
  • 113
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 ...
Daniel Lorenz's user avatar
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. ...
molundb's user avatar
  • 21
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: ...
iantukic's user avatar
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 ...
S.E's user avatar
  • 57
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 ...
J86's user avatar
  • 424
0 votes
3 answers
3k views

Repository with ViewModel (ASP.NET MVC)

I have db table Model. Here is code: ...
S.E's user avatar
  • 57
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 ...
mirind4's user avatar
  • 299
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 ...
Hooman Bahreini's user avatar
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: ...
AminM's user avatar
  • 93
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 ...
DrivenTooFar's user avatar
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 ...
PatoPan's user avatar
  • 21
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 ...
Sinjai's user avatar
  • 227
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 ...
Flexabust Bergson's user avatar
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 ...
Daniel Lorenz's user avatar
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", ...
Unbreakable's user avatar
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 ...
Sinjai's user avatar
  • 227
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 ...
Unbreakable's user avatar
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 ...
H35am's user avatar
  • 131
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 > ...
Scott O.'s user avatar
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. ...
Jonathan Wood's user avatar
4 votes
2 answers
3k views

Log Visitor Count in Asp.net MVC

I have a table to Log visitor Count Like : ...
work question's user avatar
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. ...
Sinjai's user avatar
  • 227
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 : ...
work question's user avatar
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 ...
Bassie's user avatar
  • 559
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 ...
Sinjai's user avatar
  • 227
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 ...
Sinjai's user avatar
  • 227
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. ...
tbonejenkins's user avatar
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 ...
Satvinder Singh's user avatar
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 ...
Paul Evans's user avatar
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 ...
AED's user avatar
  • 197
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 ...
Michael Brandon Morris's user avatar
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 ...
Troublesome Junior's user avatar
-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 ...
Alex's user avatar
  • 1
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 ...
gvk's user avatar
  • 133
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 ...
Unbreakable's user avatar
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 ...
Andrew's user avatar
  • 133
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. ...
AUBG's user avatar
  • 21
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 ...
actaram's user avatar
  • 163
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 ...
DrivenTooFar's user avatar
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. ...
Josh's user avatar
  • 285
3 votes
2 answers
459 views

Cloudinary upload call takes too long

I have the following async ActionResult. ...
Dawar's user avatar
  • 31
1 vote
2 answers
113 views

Search menu with multiple options

...
user3117628's user avatar
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: <...
jbruce's user avatar
  • 11