last day (35 days later) » 

12:22 AM
@Malachi Ready.
Here's what my model would be:
public class Fruit
{
    public int FruitID { get; set; }
    public string Title { get; set; }    // Name
    public decimal Price { get; set; }
    public string ImageLocation { get; set; }
}
public class Cart
{
    public int CartID { get; set; }
    public int UserID { get; set; }
}
public class CartItem
{
    public int CartID { get; set; }
    public int FruitID { get; set; }
    public int Quantity { get; set; }
}
You can extend that as needed, for example, maybe an IsWishlist property on the cart.
So, with the EF virtual properties, it might look like this:
public class Fruit
{
    public int FruitID { get; set; }
    public string Title { get; set; }    // Name
    public decimal Price { get; set; }
    public string ImageLocation { get; set; }

    public virtual ICollection<CartItem> CartItem { get; set; }
}

public class Cart
{
    public int CartID { get; set; }
    public int UserID { get; set; }

    [ForeignKey(nameof(UserID))]
    public virtual User User { get; set; }

    public virtual ICollection<CartItem> CartItem { get; set; }
}

public class CartItem
Create a migration with that--I think it should work, but I'll need to see it.
Now, when you create your app, I'd just have the homepage be the list of products.
I don't have Balsamiq in ATM, or I'd toss a quick mockup up.
I'm sure you can do that though.
Then you should have a button somewhere to go to the cart, which will display the selected items.
You'll need these controller methods:
AddItemToCart(int itemID, int cartID)
RemoveItemFromCart(int itemID, int cartID)
UpdateQuantity(int itemID, int cartID, int quantity)
That should cut it for now.
When the proper buttons are clicked, route to them with an AJAX call.
 
12:46 AM
Going to step out now. I'll probably be back for a short while after supper.
 
1:27 AM
I will be back in a bit as well. sorry I was handling some things and now I am tucking my kids.
 
2:00 AM
I'm here again.
 
Intellisense doesn't like the ForeignKey Attribute. I was just about to look it up after I get another cup of tea
I am not running .net core, I think I am using 4.2 or something like that.... because I am using visual studio 2013
 
Neither am I.
Got to do the dishes and go to bed.
 
2:24 AM
talk to you tomorrow
 
 
11 hours later…
1:53 PM
Back again.
 
hey, how is it going?
just getting ready to commit some changes
 
Fine. How is your shopping cart going?
Did you get that model working?
 
I have the shopping cart page loading the items I added to it. I confused the sessionkey with the variable name that was holding the session key in the logic
I also have some Commenting to get rid of soon. but
I think I want to work a little bit on some GRaphical things...
 
 
3 hours later…
5:13 PM
trying to get bootstrap to work on my listviews... think I am going to switch back to the requirements and then go back to the graphical stuff when I have everything working.
 
Install it from NuGet.
Then you have to link to it in a couple places.
 
5:30 PM
that is probably what I am missing. I figured that when I installed it that it would link where it needed to, but now that I think about it I need to have it in the masterpage at the least
 
Yup.
 
 
1 hour later…
6:53 PM
I keep getting a mismatched table from my listview....
 
When was the last time you ran the migrations and updated your table?
 
not sure that I have changed anything with the models since I ran the update last
and I added the -EnableAutomaticMigrations flag when I enabled migrations
 
Are you using the models I gave you last night?
 
I don't think they are identical...
public class Cart
{
[Key]
public string CartID { get; set; }
public System.DateTime DateCreated { get; set; }

public ICollection<CartItem> CartItems { get; set; }
}
 
I still don't get why the heck you are using a string as a key...
 
7:00 PM
The CartItem was having some issues with the CartID Foreign key. it is commented out at the moment
because I am using Guids
and the session keys.
 
Then use a bloody guid!
 
right...
 
Right. We use guids for our keys at work.
public System.Guid CartID { get; set; }
 
 
1 hour later…
8:09 PM
the contents of my listview are off by one cell...
 
Bootstrap?
Post a screenshot?
 
I found it. I added a Row Class to the TR's
 
Cool.
 
I forgot how much of a Pita CSS really is
 
You bet.
If you are lucky, they'll have a dedicated person for it.
We've got one here :)
 
8:17 PM
I will be.
most of the stuff I am doing for this, I don't think I will have to be doing on the regular
back to my Button click for the "order"
 
The onclick event with JS and an AJAX call?
 
that is what I am going to do for this one.
the other button I did with <asp:Button ID="AddToCart" runat="server" OnCommand="AddFruitToCart" CommandArgument='<%# Eval("fruitID") %>' Text="Add To Cart" />
 
If I were you, I'd do them all in the same style.
Consistency is more important than showing off what you can do.
 
I see.
 
Maybe put a comment in saying why you chose that over AJAX, or something, but keep your code clean.
 
8:24 PM
I figured that I hadn't done anything in Javascript yet. maybe I can save that for validation Extra Credit
I would like to get rid of some template crap from the listviews, but everytime I try to delete some of it, the whole thing breaks.
 
Once you get it pretty much done, I'll take a look and jump on you :P
 
figured I would look at it a bit later when I have the req's finished
I was able to change those ID's to Guids too.
 
Awesome.
 
time for a commit I think
going to go get my daughter soon
 
It'll be good to step away from the computer for a bit :)
 
8:28 PM
oh yeah. I want to get it done by bed time though...
 
You sound really close.
 
I will publish to Azure and post a link when I am finished Committing
I am to the point that I am not looking at the tutorial I started with... I would call that major progress....lol
 
Yup.
 
The button on the Cart Page doesn't take you to the Order Received page yet
 
Looking good.
Really good
 
8:34 PM
thank you.
stuff is starting to come back to me.
when I am done with this I am going to go through the books that I have and not stop
meaning I am going to find more and more books to read and catch up to you all
 
MSDN is really good too.
Have you covered DB normal forms?
Read about 1st, 2nd, and 3rd if you haven't. Preferably before you submit this.
 
8:50 PM
I have read that stuff before, but it has been a while
I have the Headfirst SQL book on my Desk
 
I hate Head First books, but they (for the most part) contain good information.
 
9:19 PM
and a lot of fluff
 
That's why I hate them.
 
updating SSMS right now. hopefully it gives me more features...
actually I think I am installing the newest version...
 
Any new features won't really matter.
You should be using Linq-to-Entities for your data access.
 
I could use LinqPad, totally forgot about that
I couldn't see my Sprocs or anything in the version I am currently running
 
You shouldn't need SPs here.
You should be using the add (insert?)/delete/update methods in EF.
 
9:31 PM
even when I need to delete data for development purposes?
I am so used to looking at the tables and such in SSMS
 
Oh, sure.
I'd probably just write a raw SQL script, though.
But using SPs in your code here is going overboard.
 
I do most of the time. but there are some things that SSMS is nice for.
I did one for ...
 
Well, just stick a comment in saying that you did it to show what you know, and you usually would do ABC instead for cleanliness.
 
SELECT
Fruits.title
, Fruits.price
, Fruits.imageLocation
FROM dbo.CartItems
INNER JOIN dbo.Fruits ON CartItems.fruitId = Fruits.fruitID
WHERE (CartItems.cartId = '4c4e0fbc-f9fa-4f55-951f-f272777244d2') --CartSessionKey
I was taking in a parameter. for the CartId. it seems cleaner to have a Sproc for stuff like that. but I haven't been using EF long either.
something I really want to be doing
 
I'd use EF's virtual properties and do Carts.Where(w => w.ID == {guid value}).CartItems.Select(s => s.Fruit)
So, you could do Guid.Parse("string-value").
Except, you have to do it in a separate variable since EF doesn't recognize the Guid.Parse method.
 
9:43 PM
how do I set that up for the ListView? with a linqDataSource?
 
You use the virtual properties on EF.
Like how I showed you above. It automagically pulls it in.
 
let me get the last page working and then I can play with that a little bit.
 
Yup.
That's really a core part of EF. You don't want to not use it.
 
thank you for helping me
 
NP.
I hope you get the job, and I can show you a zillion more things.
 
9:54 PM
I will be a sponge
the fun thing is that it is a remote job.
 
Oh, nice.
I get to work remote 1 day a week, plus when I'm sick.
 
I like this dry run, helps me get my wife into the swing of the whole remote thing...lol
that sucks you gotta work when you are sick...lol but it's nice too, because you don't miss work...lol
 
Right. I want my vacation days for when I'm healthy.
At least, some of them...
It's a 45 min drive, and I frequently throw up when I get sick, so...
I still have to take a day or two off anyway, but not as many.
 
that is a lengthy drive
 
 
2 hours later…
11:45 PM
okay.
> We're in need of a simple three-page website for one of our customers to be able to order tropical fruit for a school fund raiser. We are expecting up to 100 orders.

What we need is:

· Page 1: Product list page to show a list of tropical fruit
· There are 5 fruit total and each of them had a title, price, and a button to "Add to Fruit Cart". Other data is ok but not required.
· Page 2: Fruit Cart. This page shows a list of the items that have been added to the fruit cart.
· There is field to ask for the person's name, and a button to "Order fruit now".
those are the requirements
I am going to take a break. but I have all the code (minus the Web.Config) up on my Github
 

  last day (35 days later) »