Questions tagged [asp.net-mvc]

Model-View-Controller for the ASP.NET framework

-3
votes
0answers
21 views

Best way to check if data exists in database using service, Unit of Work and Repository Pattern in c# [closed]

What is the best way to check if an data exists in the database i am using service, unit of work and repository pattern I don't how check the data in present in database are not ...
3
votes
1answer
44 views

Initializing entity framework context in constructor

We use the architecture shown in the code below to initialize the DB context for our MVC 5 project using entity framework 6 We have the following questions related to it: Is it safe to initialize ...
1
vote
1answer
39 views

Authorization using Entity Framework in ASP.NET MVC

1. Backstory I recently starting programming and I found out that Entity Framework works perfect for my small-sized applications due its simplicity. I've made my custom authorize attribute for MVC ...
1
vote
0answers
28 views

Add a folder with jstree

I read on SO and other pages that I should avoid JavascriptResult, I do not realy know why, but now I use JsonResult, because it is more common. Here is my Ajax in the cshtml: ...
1
vote
0answers
33 views

Querying connection string across solution [closed]

I have an app.config file that contains some connection strings, this is accessed on a project-by-project basis In my solution, I have the following projects: A B ...
3
votes
0answers
108 views

Controller in an ASP.NET Web API application which generates a CSV file

I have a controller in an ASP.NET Web API application which generates a CSV file. The controller looks like this: ...
3
votes
0answers
61 views

AJAX shopping cart with quantity +/- buttons

I'm a junior developer (couple years into it) and very new to AJAX. I'm writing an internal inventory application built on MVC and right now I'm dealing with adding and removing items to/from a cart. ...
1
vote
1answer
45 views

Making EmployeeHistory ViewModel immutable as code analysis suggested

I want to display on a view the EmployeeHistory view model sorted by elements.assignEffDateNext and I want to instantiate and ...
0
votes
0answers
202 views

Upsert with .Net Core Web API

I am using .NET Core 2.2, EF Core and C#. I have created a web API project. I was requested to do an Upsert (insert or update). The entities structure is: Movie User Rating: this is used to give a ...
0
votes
2answers
75 views

Authorization - Create and unlock a User

I just wrote this, but I am not realy happy with that. I think there is an easier way to do this. First I am checking if a user has an ID (from a portal we are using, it is in the header). After that ...
3
votes
1answer
77 views

Instantiating View Models using a static factory

I am building an e-commerce website. I have an application layer service called SearchService. SearchService receives a search ...
0
votes
1answer
67 views

Rendering an html page uploaded by a user into MVC app

I need advise whether the approach I took is the optimal one (not sure whether this is the right 'stackExchange' site). I have an MVC application, which is supposed to be able to render an HTML page ...
1
vote
0answers
199 views

E-commerce site for posting advertisements

I am developing an e-commerce website in ASP.NET MVC. Users can post advertisements of different types on the site. I am using inheritance to define my Ad types, and this review is mainly about ...
1
vote
1answer
81 views

Wrapper for a sales API, with a fluent interface

I've created a simple API wrapper that I intend a few developers to utilize. I decided to follow an Fluent Interface methodology, similar to this. ...
2
votes
1answer
97 views

Displaying all application errors in a view

I'm learning ASP.NET Core with MVC pattern and I didn't find anything useful related to this argument. Actually I'm looking ...
1
vote
0answers
279 views

Uploading images to a server

I wait 5 to 6 minutes for the photo to be post to the Azure server. The other data (.txt etc.) is added quickly. That is, there is a delay when adding photos alone. This problem didn't exist before ...
4
votes
1answer
593 views

Generating absolute URIs behind a reverse proxy

In my ASP.NET MVC application there are occasions where I need to generate an absolute URI, such as when sending an email confirmation link to a user. The most straightforward approach is to use ...
2
votes
1answer
117 views

Design Pattern for initializing Properties of a ViewModel which only serves a display purpose

It's a question which lies me for years on the tongue. Given a LoginViewModel: ...
0
votes
2answers
7k views

Return json to browser via MVC controller for morris chart

Program is written in .Net Framework 4. Class: ...
3
votes
1answer
525 views

Dynamic AuthorizeAttribute with database

I want to create a AuthorizeAttribute that gets the current ActionMethod RouteData and ...
10
votes
1answer
204 views

Checkers Board Creator

A year or so ago, I wrote a checkers game for the Universal Windows Platform. Now, I wrote a web-based version of it hosted at http://checkerstreasury.azurewebsites.net. This is the first of a series ...
2
votes
1answer
2k views

Adding or updating Company entity

Here I am trying to post a company view-model and update and insert according. But I feel I am writing it in wrong way or maybe there's a better approach. Here's my code ...
1
vote
3answers
3k views

Sending many unique emails at same time

I have an asp.net core app that sends emails with a link. When they click the link they can start taking an online test without logging in. The link contains a number that is validated by the ...
2
votes
1answer
366 views

Web Service that gets data from multiple tables in a database using EF Core Database-First approach

I have never created a web service before. I followed most of this Pluralsight tutorial to give me an idea of how to create one using ASP.NET MVC along with .NET Core 2.0 and Entity Framework Core. ...
0
votes
1answer
323 views

Configuring certificate signing for development and production environments

The below code works but there's a lot of duplication I wonder if I can get around. I would like to be able to use .AddDeveloperSigningCredential(false) if in ...
2
votes
0answers
3k views

Member management of Active Directory groups via an ASP.NET MVC website

Background One of the projects I'm working on is an Intranet website which is a front-end for several kinds of data, each aimed at a different set of users. Access to the website is handled through ...
5
votes
1answer
4k views

ASP.NET Core 2 architecture and design patterns

I started a week ago to split my project into layers: business logic layer, data access layer and UI layer. I took as an example this project: https://github.com/dotnet-architecture/eShopOnWeb. I ...
4
votes
3answers
170 views

Caching an integer - distinguishing no value from zero

I would like to store an integer value in the application cache. The GetOrSet method should always return an int, and never be null. If there is no cached value, ...
5
votes
1answer
2k views

Extending IPrincipal.IsInRole()

In my case, I needed to give roles to users, but to specific departments, and I did not want to implement a new authorization mechanism which will require me to access the db everytime I want to check ...
1
vote
1answer
79 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 ...
2
votes
4answers
1k 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
1answer
61 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
2answers
257 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
1answer
128 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
2answers
248 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
1answer
834 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 ...
7
votes
2answers
1k views

CQS implementation with decorators

I've created a "framework" or more of a library for a CQS implementation with a few decorators. Using ASP.NET Core for the front end, I wanted an opinion about how this looks/feels. I changed the ...
1
vote
0answers
43 views

Querying a database to find notifications to comments

I have a solution what I think is not the best, and I want to make this not so expensive. I'm using MVC 5 + SignalR (hubs) + EF + UnitOfWork + Generic Repos. I have a table ...
2
votes
0answers
412 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
2answers
2k 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
1answer
270 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
1answer
53 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
3answers
1k views

Repository with ViewModel (ASP.NET MVC)

I have db table Model. Here is code: ...
1
vote
1answer
1k 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
0answers
3k 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
1answer
2k 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
1answer
179 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
2answers
2k 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
0answers
43 views

Volume control with using asp mvc 6

General purpose of this training project is to control sound volume on remote machine (which exposes ISystemControlClient through web service). It's created using ...
1
vote
0answers
43 views

Get typed results for examine indexer using Umbraco

Continuing on this question on Stack Overflow, I've found a working solution. The case The case I'll create is that I've got a lot of persons and a knows person get 0, 1 or multiple languages. The ...