ASP.NET MVC 4 is the fourth major version of the ASP.NET Model-View-Controller platform for web applications.
2
votes
2answers
54 views
Returns Office Details from Database
I am building an Administration web site for the Office details in my database. Right now, I am just trying to display the office details.
public class OfficeRepository
{
public static Office ...
0
votes
1answer
23 views
Class for Managing Office Details
public class Office
{
private Int32 _SyncID;
private string _OfficeName;
#region Properties
public Int32 SyncID
{
get { return _SyncID; }
set { _SyncID = value; }
...
7
votes
3answers
358 views
Ternary extension method
I created the following HtmlHelper extension method for my Asp.Net MVC Razor views because the ternary syntax sucks when you need to use it intermixed with markup.
Is there a better way to write this ...
0
votes
0answers
11 views
Adding viewstate based property and implication in future converstion to mvc in asp.net forms project
Suppostedly adding another viewstate based property in user control (riddled with similar properties) incur technical debt in future effort to convert projects to MVC (comment made by one of my ...
2
votes
0answers
37 views
What can I do better in this ViewModel Creator?
I'm currently creating a ASP.NET MVC page in C#.
I want to hide everything regarding the creation of our "models" and "viewmodels".
I have seen much of the fancy stuff regarding Dependency ...
1
vote
0answers
70 views
Code First/Database First Entity Framework MVC [closed]
The following example is taken from the book Pro ASP.NET MVC 4 - Adam Freeman. This book does a good job going over the basics of the MVC framework. In it a database is created from a Product class ...
5
votes
1answer
37 views
Is this nesting of partial views poor design?
I feel like using this many partial views where a view renders a partial that renders a partial is just digging a hole of poor design, so I'm looking for any suggestions or guidance as to if this is ...
5
votes
2answers
131 views
Building a better Data Access Layer Class
Since I am new to MVC and the Entity Framework, I have been struggling to grasp the concept of creating useful Data and Service layers. I have come across a scenario where I believe my code has become ...
1
vote
1answer
45 views
Inserting using multiple contexts into LocalDB
I've written this ActionResult to model an Order that goes through. I couldn't think of another way to write this without using context Db<Sets>. It runs kinda slow, taking around 4 seconds to ...
3
votes
1answer
54 views
Retrieving statistics about URL clicks
I'm pretty new to ASP/MVC but have had some prior programming experience.
I am trying to retrieve statistics about URL clicks - total clicks and unique clicks by IP address. I started with:
...
5
votes
2answers
546 views
Update only modified fields in Entity Framework
I'm working on a website on ASP.NET MVC4 and EF5. I want to ensure that only modified values are updated in the database. I'm using a unit of work pattern and repositories for data work. Here's the ...
4
votes
1answer
73 views
MVC4 Routes, using Default
Should I leave the Default Route in if it's not adding any benefit?
I have a RouteConfig.cs file that looks like this:
public static void RegisterRoutes(RouteCollection routes)
{
...
5
votes
2answers
333 views
Reduce spaghetti code in ASP.NET MVC
I just started working with asp.net mvc a few weeks ago, and I'm finding that it can be very easy to write spaghetti code in the controllers. For my first project, I created a very simple view with a ...
3
votes
1answer
1k views
Unit of Work with Repository Pattern MVC 5 & EF 6
I put together a sample of how I am using the Unit of Work & Repository pattern based on my understanding. Can anyone please let me know if I am implementing this the correct way? If I am not, how ...
1
vote
1answer
228 views
Improving MVC 4 DropDownList
I'm currently populating my drop downlists like this...
public List<NewLogin> GetRolesForDDL()
{
using (database db = new database())
{
return (from r in ...
1
vote
1answer
32 views
Using 'dynamic' to save lines
I am pushing an Excel file to the server and then reading it's contents. XLS and XLSX files need to be read differently, but the DLL that I'm using has the EXACT same function calls for both types. If ...
2
votes
1answer
106 views
Need reviews for an authentication system
AccountController Code:
public class AccountController : ApplicationController
{
public AccountController(ITokenHandler tokenStore, IUser user) : base(tokenStore, user){}
public ...
2
votes
1answer
546 views
Unit of work, Ninject, Repository and WebAPI implementation
after recently getting a bulk of work done on my WebAPI service layer, I thought I'd post some of my working on here for you guys to tear apart, generally, most of it 'feels' mostly okay, but I know ...
5
votes
1answer
2k views
Entity Framework using Repository Pattern, Unit of Work and Unity - viable approach?
Using a combination provided from this example and this implementation, I'm creating a solution that decouples the UnitOfWork class from the individual repositories, as they violate the Open-Closed ...
2
votes
0answers
177 views
Acceptable Way to Navigate in ASP.NET MVC 4 in SPA-like App
I'm getting back into web development, and I'm creating a mobile-friendly web app. I'm trying to make it SPA-like in the sense that I don't load new pages for each action the user takes. As my ...
1
vote
1answer
93 views
Creating models manually in mvc
I am creating my models manually.
I have five tables in my database as follows :
1. Members
2. MemberTypeMasters
3. Payments
4. Relationships
5. StatusMasters
My Database looks like :
So far I ...
2
votes
1answer
539 views
When to use separate DBContext classes?
I know that the DBContext represents a session (Unit-Of-Work and Repository) with the database, however I an unsure as to when I should have a different DBContext. Currently, I have a separate ...
4
votes
2answers
561 views
MVC Layered Project Structure
We are starting a new web project using C# / MVC 4 and Entity Framework 5 for data access. I've decided to go with an n-layered approach for the structure of the project and I would like some feedback ...
4
votes
1answer
276 views
DbSet<T> IncludeAll method
The Problem
As an ASP.NET MVC4 developper, I'm using Entity Framework a lot. Considering performance I often use lazy loading for my models.
public class Result {
public int Id { get; set; }
...
2
votes
1answer
266 views
Cookie wrapper in MVC4 c#
I'd like to create a cookie wrapper in my application to help support a DRY approach to coding common cookie methods, provide intellisense for cookie-type properties (keys), and protect against ...
3
votes
1answer
235 views
Multiple Ajax Requests per MVC 4 View
I'm using the repository pattern with a context and ninject as the IOC. I have a service which handles getting and setting page properties in the database.
public class MyContext : DbContext
{
...
1
vote
1answer
222 views
Modeling a decision tree-like form
A picture says more than a thousand words, so here's a mock-up. The actual choices are different, this is just a sample.
A user first has to choose between Red, Blue and Green. Upon selecting an ...
2
votes
0answers
768 views
Review my Generic ASP.net MVC controller that generates many pages?
I recently set out to create an open-source ASP.net MVC web development framework. Specifically, I wanted to automate some of the tasks associated with the creation of data-driven applications. I've ...
4
votes
1answer
833 views
custom System.Web.Http.AuthorizeAttribute
I've hacked together what feels like a mess for an authorize attribute to secure web api methods. The code appears to be functionaly correct; passing the unit tests in place. The code has me worried ...
3
votes
1answer
1k views
Please help me follow Repository Pattern properly
I am new to learning Repository Pattern. I am developing a site in MVC 4 ( I m new to it as well). The way I am using Repository pattern as follows:
I created IRepository<T> interface as ...
2
votes
1answer
111 views
How can I make this code better
I hate having almost two identical blocks do almost the exact same thing.
I am working with Entity Framework 4.4.0.0
Asp.Net MVC
Right now if the user is a "manager" I want to show them the entire ...
3
votes
1answer
207 views
Using AJAX to interact with MVC
I have the following ajax call:
function getPreviewText() {
$.ajax({
type: 'POST',
url: '@Url.Action("PreviewWiki")',
dataType: 'json',
data: 'source=' + ...
1
vote
1answer
209 views
Making a property virtual to cause EF to load the property?
I am walking through a sample MVC4 ASP.Net tutorial available on PluralSight.com, by Scott Allen. I am in a section #5, Working with Data (part 2), "Listing Reviews".
This application has a database ...
3
votes
1answer
2k views
Select list items in ViewModel fetched using a Repository
Doing database access in ViewModel is generally considered a bad practice. However, when you have a <select> in your view, you need to populate it using the ViewBag or the ViewModel (I prefer ...
-1
votes
1answer
215 views
ASP.NET MVC 4 Shopping Cart - Cannot update shopping car items using JQuery , Ajax, jSON, jGrid [closed]
I have this code in a C# MVC 4 VS2012 project. I need to be able to update the shopping cart with jSON data using JQuery/AJAX, i'm using jqGrid to display the data and pulling the shopping cart items ...
1
vote
0answers
118 views
Best practices in implementing service methods [closed]
Consider the following architecture: ASP.NET MVC Application having controllers which depend on service classes (MembershipService, EmailService etc.) which in turn depend on data access context ...
1
vote
2answers
386 views
MVC : Does code to save data is session or cache belongs in controller?
I'm a bit confused if saving the information to session code below, belongs in the controller action as shown below or should it be part of my Model?
I would add that I have other controller methods ...
1
vote
1answer
599 views
Truncate port number from absolute Uri
We had a requirement to remove the port number from the Request.Url.AbsoluteUr i.e
Actual:
https://mysitename:443/Home/Index
Excepted:
https://mysitename/Home/Index
The code I used for ...
2
votes
1answer
187 views
Cropping and combining two images on server
I've coded following two methods to combine images that are HTTP POSTed to the server:
// Crops two squares out of two separate images
// And then combines them into single image that's returned as ...
1
vote
0answers
469 views
A Repository for Good ASP.NET MVC Practices [closed]
I have an open source project on GitHub. It is an ASP.NET MVC 4 application using Entity Framework and a handful of other utilities. I decided to create this project after spending about a year ...
1
vote
1answer
387 views
MVC4 Linq to Sql Model Structure
Goal: To pass a list of related objects into a view which can then be iterated over using razor syntax.
I'm new to LINQ and MVC4. I'm trying to use the repository pattern to manage my model creation. ...
8
votes
1answer
291 views
Injecting SelectList objects into ViewData to enable using EditorFor on dropdown based properties?
I have developed a system whereby I use an attribute to state which SelectList to use for an 'FK' property. I would appreciate some feedback mainly on by good practice, and also on any ways to do this ...
5
votes
0answers
1k views
Is this the right way to inject AutoMapper profiles
I'd like to know if I'm doing profile configuration in the wrong place or in the wrong way.
I'm following the Onion Architecture. So that restricts the direction of my dependencies towards the ...
6
votes
1answer
999 views
passing a selectlist to the view based on database models from viewmodel is a MVC anti-pattern?
We need to select a model reference from a view.
To do this we need to add a dropdownlistfor.
this is based on a selectlist containing database models.
passing selectlists by viewbag
this solves our ...
1
vote
1answer
268 views
What should I do to improve my first MVC 4 application built with C#
I've started learning .NET with MVC 4 in C# and I built a basic application to display records from a MySQL database. It's incredibly basic, but it's the best I could come up with being a complete ...
1
vote
0answers
70 views
PBKDF2 Authorization first go, is this optimal?
I've discovered that using hashed passwords with salts is much better idea than MD5/SHA256 so I'm not hashing them with PBKDF2. However I'm wondering if this is correct approach to authorize my user. ...
2
votes
1answer
4k views
Entity Framework & Unit Of Work Design issue with Repository & DI, Please Help
I am facing a problem to save data using UnitOfWork. I mean I am unable to save data using UnitOFWork.Commit() from Controller class. My Implementation check bellow.
IUnitOfWork
public interface ...
1
vote
1answer
160 views
How to dynamically Generate Sort strings for Data Layer from Controller
I need help refactoring this code to dynamically generate a sort string that I can send to my data layer so that my database does the sorting instead of it happening in memory. I am using MVC4 with ...
0
votes
2answers
174 views
How could I make my controller a little less hideous?
I have a controller. It functions as follows:
A user imports a file and decides whether the files contents contain new entries to be placed into a database, or existing entries entries to be updated.
...
0
votes
1answer
197 views
Products table or Products + attributes when using EF + MVC 4 [closed]
What I need to build is a web application that maintains and shows products. A product has a lot of attributes, some that will be changed or added during the next year. I have 2 options for designing ...