I understand the importance of Dependency Injection and its role in Unit testing, which is why the following issue is giving me pause:
One area where I struggle not to use the Singleton is the Identity Map/Unit of Work pattern (Which keeps tabs on Domain Object state).
//Not actual code, but it should demonstrate the point
class M...
According to Presentation Model notes by Martin Fowler and also on MSDN documentation about Presentation Model, it is explained that the Presentation Model Class should be unaware of the UI class and similarly Business Model Class should be unaware of the Presentation Model class.
The UI should databind extensively to the Presentation ...
Hi team;
I am working on the domain model for a project. I have a class named user that has a class named UserType as one of the properties. I know when i want to select all users, i will use joins to pick up all corresponding usertypes. How do i do inserts? Do i have to write a handler for userType? or can i do something like
INSERT...
I have a COM library I should use in my ASP.NET MVC application. However I am unsure about its thread apartment model. How can I determine it?
...
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| pid | varchar(99) | YES | | NULL | |
+-------+-------------+------+-----+---------+-------+
1 row in set (0.00 sec)
+-------+---------------+------+-----+...
I have a before_save method that I call that renames an uploaded image.
before_save :randomize_file_name
def randomize_file_name
extension = File.extname(screen_file_name).downcase
key = ActiveSupport::SecureRandom.hex(8)
self.screen.instance_write(:file_name, "#{key}#{extension}")
end
That method is part of my Item model.
Tha...
Pretty Basic one here guys.
I have a View which holds 2 textfields for input and a submit button
<%using (Html.BeginForm("DateRetrival", "Home", FormMethod.Post)){ %>
<%=Html.TextBox("sday")%>
<%=Html.TextBox("eday")%>
<input type="submit" value="ok" id="run"/>
<% }%>
the following controller action which I want to bind the dat...
Hi I am using a custom model binder with asp.net mvc 2.0 , everything works locally but when deployed to the server runing iis 7, i get a weird error which is hard to get information about the error is as follows, I am also attaching my model binding class
[MissingMethodException: Method not found: 'System.Collections.Generic.IDictionar...
Hello,
I have a list of CustomerViewModels in a ComboBox. The selected CustomerViewModel I want to delete and also the Customer wrapped inside it to remove it from the repository.
But how can I access the Customer model inside the CustomerViewModel?
...
In MVC web development frameworks such as Ruby on Rails, Django, and CakePHP, HTTP requests are routed to controllers, which fetch objects which are usually persisted to a backend database store. These objects represent things like users, blog posts, etc., and often contain logic within their methods for permissions, fetching and/or muta...
I have a model with a generic relation:
TrackedItem --- genericrelation ---> any model
I would like to be able to generically get, from the initial model, the tracked item.
I should be able to do it on any model without modifying it.
To do that I need to get the content type and the object id. Getting the object id is easy since I h...
My Html action link takes me to a view where i can see the details..
For Ex:http://localhost:1985/Materials/Details/4
But it shows error,
The model item passed into the dictionary is of type
'System.Data.Linq.DataQuery`1[CrMVC.Models.ConstructionRepository+Materials]'
but this dictionary requires a model item of type
'CrMVC.Models.C...
I'm building a Rails site that, among other things, allows users to build their own recipe repository. Recipes are entered either manually or via a link to another site (think epicurious, cooks.com, etc). I'm writing scripts that will scrape a recipe from these sites given a link from a user, and so far (legal issues notwithstanding) t...
I have written an application for an online clothing store in Rails 2.3.5. I want to show related Products when a customer views the Product Detail page.
For example, if the customer views the detail page for a suit, I'd like to display the accessory products that match the dress such as a vest, shoes, and belt. I have named the relat...
The site I'm working on involves teachers creating student objects. The teacher can choose to make it possible for a student to log into the site (to check calendars, etc) OR the teacher can choose to use the student object only for record keeping and not allow the student to log in. In the student creation form, if the teacher supplies ...
I don't a controllers model to use a database table.
I have a pages controller and model but it is saying "pages table not found". How do I tell the model not to use a the database at all?
Cheers!
...
Does anyone know a clever way, in Google App Engine, to return a wrapped Model instance that only exposes a few of the original properties, and does not allow saving the instance back to the datastore?
I'm not looking for ways of actually enforcing these rules, obviously it'll still be possible to change the instance by digging through ...
I think the way I've modelled my app is a bit fishy and i need to rejig things, im just not sure how. I've already re-jigged and refactored before. It took a long time ( I'm a beginner ) and I'm hesitant to it again in case i head off in the wrong direction again.
Basic Idea, user can submit an answer, another user can mark it correct o...
I have two models (say A and B) which are independent and have independent methods. I want to add some methods that operate on both models though.
for example, addX() will create an object from both models A and B.
What's the best way to structure code in this situation, since it doesnt make sense to have the method belong to either o...
Hi,
I'm starting to develop an activity stream. I've read both How to implement the activity stream in a social network and What’s the best manner of implementing a social activity stream?. What I haven't found is the best way to add comments to the activities. As in facebook, each comment can be commented by another person.
If each ac...