Tag Info

New answers tagged

0

The ViewModel object is not what gets stored in a database table, generally. It's the individual items in the ViewModel object that get stored. Each of those items already has an ID. For example: public class InvoiceViewModel { public Customer Customer { get; set; } public Address BillingAddress { get; set; } public Address ShippingAddress { ...


3

I don't use ASP.Net, but when it comes to MVC, I like to keep all layers clearly separated. It is better to separate the domain model from the persistence layer, so that you can easily provide another one if needed. The domain model should contain in my view only basic properties and methods. Methods that involves processing, even the simplest ones, should ...


1

Generally you want thin controllers that handle request in a RESTful way, with any business logic in the models. I would put any state related stuff such as logged in user and any request related stuff such as 'records for this user' in the controller. I would put the database calls that are specific to current or archived records as methods in the model ...


0

Disclaimer: There are so many other factors in play that your decision on which approach to use should probably not be made solely on this evaluation. Consider team skill sets, long-term maintainability, features needed versus features provided by various frameworks, which client platforms/devices you need to support, and so on. However, from a purely ...


0

I wasn't sure if you were requesting an IDE or an MVC framework, but I wanted to share a new MVC for PHP that is very close to .NET. https://github.com/DominicArchual/Php-One Here's how it works: Define your view model: require_once('bin/System.php'); class MovieViewModel { public $Id = 0; public $Title = ""; public $Rating = ''; public ...


2

I would say it really depends on your application. Is it just doing pure CRUD, without any business logic? Then I would use EF models directly in my views. Most of the time there is at least some business logic involved and then a layer between the data/EF models and the view might be a good idea. In this case it might be appropriate to do "CQRS-lite" (see ...


4

Short answer: yes. While we'd all like to tinker around and build neat things there will always be the need of shipping the darn thing before going out of business. Long answer: it depends. Requirements and the skill level of the team can influence the decision of choosing one over the other, having both or having none. With a tight deadline comes focus ...


6

In my applications I have always separated things out, with different models for the database (Entity Framework) and MVC. I have separated these out into different projects too: Example.Entities - contains my entities for EF and the DB context for accessing them. Example.Models - contains MVC models. Example.Web - web application. Depends on both ...


12

It seems perfectly reasonable to use an @if statement or two in a Razor view. They added @if to Razor - it's meant to be used. Your code could be shortened to one @if: @if (editing) { // some more fields shown in edit mode } else { // some stuff shown in create mode } An alternative is to use three views: Partial view containing the common HTML ...


16

Presentation logic comprises the logic and calculations that are needed to present the business data in the right way for a particular view. For complex graphical views, this can be quite complex calculations (for example, calculating the size of each pie slice and the positioning of the labels for a pie chart), but the main characteristic is that it only ...



Top 50 recent answers are included