<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Part 8: Shopping Cart with Ajax Updates</title><link>http://asp.net</link><pubDate>Wed, 06 Mar 2013 06:51:39 GMT</pubDate><generator>umbraco</generator><description>Comments for Part 8: Shopping Cart with Ajax Updates</description><language>en</language><atom:link href="http://asp.net/rss/comments/27632" rel="self" type="application/rss+xml" /><item><title>Comment Posted by rhvarona</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-8</link><pubDate>Sat, 25 Jun 2011 14:53:41 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013612</guid><description><![CDATA[ <p>The shopping cart class should be broken up into at least two classes: MvcMusicStore.Models.ShoppingCart</p><p>MvcMusicStore.ViewModels.ShoppingCartFactory.</p><p></p><p>The ShoppingCart class would have all the entity logic.</p><p></p><p>The ShoppingCart factory would create a new shopping cart using an HttpContext or Controller.  The context and controller concepts have not business in the Model layer.  Another alternative is to add the shopping cart factory static methods to the ShoppingCartViewModel class.</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/rhvarona.jpg?forceidenticon=false&amp;dt=635072304000000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by redspear</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-8</link><pubDate>Wed, 29 Jun 2011 06:18:35 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013638</guid><description><![CDATA[ <p>what the use of function handleUpdate() ?</p><p>it seems that it does not run at all?</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/redspear.jpg?forceidenticon=false&amp;dt=635072304000000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by addsub</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-8</link><pubDate>Sun, 24 Jul 2011 13:04:36 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013826</guid><description><![CDATA[ <p>Clicking the &quot;Add To Cart&quot; button gives me a resource cannot be found error. Requested URL : /Store/AddToCart </p><p></p><p>Anyone got any ideas please? This is really bugging me as I&#39;ve actually stopped, deleted and rebuilt the entire project up to this point to try and get past this, and I&#39;m getting the same error. :(</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/addsub.jpg?forceidenticon=false&amp;dt=635072304000000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by mikev76</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-8</link><pubDate>Wed, 03 Aug 2011 00:00:58 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013892</guid><description><![CDATA[ <p>On mine, when I got to this point, and clicked on add to cart, it said: Microsoft JScript runtime error: Object expected. I noticed that in my Views\ShoppingCart\Index.cshtml and Views\Shared\_Layout.cshtml both referred to jquery-1.4.4.min.js in the &lt;script&gt; tag near the top. However, in my Scripts folder the only thing I saw with some number was jquery-1.5.1. I changed my &lt;script&gt; statements to match these numbers and everything worked good after that </p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/mikev76.jpg?forceidenticon=false&amp;dt=635072304000000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by astynax777</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-8</link><pubDate>Thu, 11 Aug 2011 10:06:06 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013949</guid><description><![CDATA[ <p>There&#39;s a big problem with this example... If the guest leaves without cleaning out his cart or completing the purchase - it leaves the orphaned cart in the database.  This means the database will fill up with junk data.</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/astynax777.jpg?forceidenticon=false&amp;dt=635072304000000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by dmta</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-8</link><pubDate>Wed, 07 Sep 2011 12:21:20 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014137</guid><description><![CDATA[ <p>I found a bug when you click on the link &quot;Remove from cart&quot; from the \MvcMusicStore\MvcMusicStore\Views\ShoppingCart\Index.cshtml page.</p><p></p><p> // Perform the ajax post</p><p>$.post(&quot;/ShoppingCart/RemoveFromCart&quot;, { &quot;id&quot;: recordToDelete }, </p><p></p><p>it should be:</p><p></p><p> </p><p>$.post(&quot;/MvcMusicStore/ShoppingCart/RemoveFromCart&quot;, { &quot;id&quot;: recordToDelete },</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/dmta.jpg?forceidenticon=false&amp;dt=635072304000000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by ricka6</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-8</link><pubDate>Thu, 06 Oct 2011 21:10:01 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014351</guid><description><![CDATA[ <p>dmta: $.post(&quot;/ShoppingCart/  </p><p>Good catch. The right way to do it is </p><p>$.post(&quot;@Url.Content(&quot;~/ShoppingCart/RemoveFromCart&quot;)&quot;, { &quot;id&quot;: recordToDelete },</p><p>That way, if you name your application MusicStore instead of MvcMusicStore, it will still work.</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/ricka6.jpg?forceidenticon=false&amp;dt=635072304000000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by matt3.5</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-8</link><pubDate>Tue, 18 Oct 2011 08:47:05 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014448</guid><description><![CDATA[ <p>astynax777 - this is a SAMPLE for learning. In a production level store you would create a job in SQL Server to run (usually in quiet periods) a stored procedure that would delete abandoned shopping carts.</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/matt3.5.jpg?forceidenticon=false&amp;dt=635072304000000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by cjgrove</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-8</link><pubDate>Fri, 25 Nov 2011 12:21:04 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014691</guid><description><![CDATA[ <p>Hi, the ShoppingCart.GetCartItems() function is incorrect. I should read : </p><p> return storeDB.Carts.Include(&quot;Album&quot;).Where(</p><p>                c =&gt; c.CartId == ShoppingCartId).ToList();</p><p></p><p>if you don&#39;t inclde the Album then you get a nullref execption when adding to the cart.</p><p></p><p>Great serise so far.</p><p></p><p>Thanks</p><p></p><p>Chris</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/cjgrove.jpg?forceidenticon=false&amp;dt=635072304000000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by cha0s3ngine</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-8</link><pubDate>Mon, 05 Mar 2012 10:13:02 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000015027</guid><description><![CDATA[ <p>Hi, thanks for the really good tutorial series. Its nice to see something thats spelled out for us non web types.</p><p></p><p>Just wanted to let you know there is a problem in a couple of the pages, they use &quot;jquery-1.4.4.min.js&quot; rather than the version in the project/solution (jquery-1.5.1.min.js)</p><p></p><p>again.. thanks for the effort you put into this.</p><p></p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/cha0s3ngine.jpg?forceidenticon=false&amp;dt=635072304000000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by gusoo</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-8</link><pubDate>Mon, 16 Apr 2012 12:45:16 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000015344</guid><description><![CDATA[ <p>When I click on &quot;Remove From Cart&quot; it makes me an error I can&#39;t fix:</p><p>&quot;System.InvalidOperationException: The sequence contains no elements.&quot;</p><p>for this part of my code:</p><p>// Get the name of the album to display confirmation</p><p>string albumName = storeDB.Carts.Single(item =&gt; item.RecordId == id).Album.Title;</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/gusoo.jpg?forceidenticon=false&amp;dt=635072304000000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by de4treg54</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-8</link><pubDate>Thu, 19 Apr 2012 19:53:41 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000015370</guid><description><![CDATA[ <p>What is the purpose of making the Order class a partial class? (yet the OrderDetail class  is not a partial class.) Just curious if I am missing the reason.</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/de4treg54.jpg?forceidenticon=false&amp;dt=635072304000000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by jeanlopes</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-8</link><pubDate>Sun, 22 Apr 2012 00:11:04 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000015388</guid><description><![CDATA[ <p>Hey, Mr Galloway, I first wanted to thank you for the tutorial, it is a excellent explanation about dot net with mvc3. I wanted to ask about method @Ajax.ActionLink, dont used here. Does not serve in new standard? Why? I tried it in the new pattern and had no success.</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/jeanlopes.jpg?forceidenticon=false&amp;dt=635072304000000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by mjeson</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-8</link><pubDate>Wed, 02 May 2012 19:04:47 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000015445</guid><description><![CDATA[ <p>As of today, in ShoppingCart/Index.cshtml, change the src=&quot;/Scripts/jquery-1.4.4.min.js&quot; to src=&quot;/Scripts/jquery-1.5.1.min.js&quot;</p><p></p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/mjeson.jpg?forceidenticon=false&amp;dt=635072304000000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by paudel_bishnu</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-8</link><pubDate>Wed, 16 May 2012 20:25:04 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000015538</guid><description><![CDATA[ <p>Hi all,</p><p>Can anybody explain the necessity of  ShoppingCart class here? I am just wondering why can&#39;t we make use of &quot;Cart&quot; class to do all the shopping cart jobs ?</p><p></p><p>It might be the best approach but my poor brain keeps asking this question.</p><p></p><p>Cheers,</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/paudel_bishnu.jpg?forceidenticon=false&amp;dt=635072304000000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by pblecha</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-8</link><pubDate>Thu, 23 Aug 2012 10:00:37 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000016264</guid><description><![CDATA[ <p>Two things I noticed when I got to this point and tried testing:</p><p>1)  It&#39;s easy to not notice, in the ActionLink for the Store Details, the differences between &quot;Add To Cart&quot; and &quot;AddToCart&quot; (no spaces) and the same for &quot;Shopping Cart&quot; and &quot;ShoppingCart&quot;.  That creates problems.  Something like that ought to be emphasized.</p><p>2)  The Details method of the StoreController doesn&#39;t work; I called</p><p>var album = storeDB.Albums.Find(id); </p><p>and when the Details.cshtml tried to render, I received a NRE.  I changed it to this:</p><p>var album = storeDB.Albums.Include(&quot;Artist&quot;).Include(&quot;Genre&quot;).Single(a =&gt; a.AlbumId == id);</p><p>and it worked.</p><p>However, this, to me, shows the flaws in trusting EF too much.  This, combined with the reliance on allowing the code to BUILD your seed data in the first place (i.e., there&#39;s too much going on behind the scenes with no clear explanation), gives me pause, and I would prefer to use sprocs instead.</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/pblecha.jpg?forceidenticon=false&amp;dt=635072304000000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by theothersid</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-8</link><pubDate>Wed, 19 Sep 2012 20:09:25 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000016472</guid><description><![CDATA[ <p>I&#39;m stuck at this stage, as I can&#39;t compile. What am I doing wrong?</p><p></p><p>1. The operand of an increment or decrement operator must be a variable, property or indexer</p><p>2. Operator &#39;&gt;&#39; cannot be applied to operands of type &#39;method group&#39; and &#39;int&#39;</p><p>3. Cannot convert type &#39;method group&#39; to &#39;int?&#39;</p><p>4. Cannot convert method group &#39;Count&#39; to non-delegate type &#39;int&#39;. Did you intend to invoke the method?</p><p>5. &#39;MvcMusicStore.Models.Cart&#39; does not contain a definition for &#39;Count&#39;</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/theothersid.jpg?forceidenticon=false&amp;dt=635072304000000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by theothersid</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-8</link><pubDate>Wed, 19 Sep 2012 20:16:52 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000016473</guid><description><![CDATA[ <p>Never mind...</p><p></p><p>This is embarrassing, but I found out that one of the properties I was supposed to add to Cart.cs was </p><p></p><p>public int Count { get; set; }</p><p></p><p>Did that, and the program compiled like a breeze.</p><p>Thanks.</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/theothersid.jpg?forceidenticon=false&amp;dt=635072304000000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by spudwa</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-8</link><pubDate>Mon, 03 Dec 2012 20:28:11 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000016922</guid><description><![CDATA[ <p>I&#39;m having trouble with the remove ajax method. Even though the ajax post gets executed which checks to see if recordToDelete is null, by the time the key:value eg. id:22 get routed to RemoveFromCart() the value is null. I&#39;ve modified global.asax routing to </p><p>new { controller = &quot;Home&quot;, action = &quot;Index&quot;, id = -1 } and the debugger shows me -1 is passed to RemoveFromCart() but that doesn&#39;t help solve the problem</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/spudwa.jpg?forceidenticon=false&amp;dt=635072304000000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by spudwa</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-8</link><pubDate>Mon, 03 Dec 2012 20:30:04 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000016923</guid><description><![CDATA[ <p>I&#39;m wondering if a lot of these problems with removelink are cuase by the version change from 1.4.4 to 1.5.1 Any experts here on the changes to the $.post(...) function?</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/spudwa.jpg?forceidenticon=false&amp;dt=635072304000000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by unknownx</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-8</link><pubDate>Thu, 06 Dec 2012 14:26:05 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000016952</guid><description><![CDATA[ <p>We don&#39;t need this line </p><p>&lt;script src=&quot;/Scripts/jquery-1.4.4.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt; </p><p>in /View/ShoppingCart/Index.cshtml</p><p></p><p>It already in /Shared/_Layout.cshtml</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/unknownx.jpg?forceidenticon=false&amp;dt=635072304000000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by S0undw4ve</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-8</link><pubDate>Tue, 08 Jan 2013 18:51:42 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000017139</guid><description><![CDATA[ <p>I&#39;ve run into a bit of a wall with this part of the example. I&#39;m not entirely sure what I&#39;m missing... I&#39;m getting this error: </p><p>System.NullReferenceException: Object reference not set to an instance of an object.</p><p></p><p>On this line: (line 53) @foreach (var item in Model.CartItems)</p><p></p><p>of ShoppingCart/Index.cshtml. I&#39;ve copied the code exactly as it is from the example, so I&#39;m not very confident in assessing what I&#39;ve done wrong. Any help would be appreciated.</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/S0undw4ve.jpg?forceidenticon=false&amp;dt=635072304000000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by lz12345</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-8</link><pubDate>Fri, 01 Feb 2013 08:21:41 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000018294</guid><description><![CDATA[ <p>I got lost in this chapter. Wish there be more explanation on Ajax. I also tried the complete example and got exceptions all over places. I use vs2010 on Win7 64bit.</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/lz12345.jpg?forceidenticon=false&amp;dt=635072304000000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by ShoutingRyan</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-8</link><pubDate>Fri, 01 Feb 2013 19:33:46 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000018298</guid><description><![CDATA[ <p>Had the same issue as addsub</p><p>And it was pointing at @foreach (var item in Model.CartItems), saying that did not exist.</p><p></p><p>My line 1 in that file was wrong. It generated </p><p>@model IEnumerable&lt;CompareHerdmindData.ViewModels.ShoppingCartViewModel&gt;</p><p></p><p>But should have been</p><p>@model CompareHerdmindData.ViewModels.ShoppingCartViewModel</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/ShoutingRyan.jpg?forceidenticon=false&amp;dt=635072304000000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by ck.kislay</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-8</link><pubDate>Wed, 06 Mar 2013 06:51:39 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000018585</guid><description><![CDATA[ <p>Issue with :</p><p>System.NullReferenceException: Object reference not set to an instance of an object.</p><p>On this line: (line 53) @foreach (var item in Model.CartItems)</p><p></p><p>Solution: Here I am missing the Index function in shoppingCartcontroller, return the viewmodel , as return view(viewModel);</p><p></p><p>Thanks,</p><p>ck</p><p></p><p></p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/ck.kislay.jpg?forceidenticon=false&amp;dt=635072304000000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item></channel></rss>