geekpgh / mastersproject

The masters project for SWENG 500 team 3
4 stars 2 forks source link

Batch type is not saved when a new batch is created #50

Closed steveplatz closed 11 years ago

steveplatz commented 11 years ago

When a new batch is created, the type is always set to "Beer", no matter which type is selected.

geekpgh commented 11 years ago

I think this may be an error in ControllerUtils.getSelectionForEnum

I had a very difficult time writing this method, I mostly cobbled it together from various bog posts. There was no clear or easy way to turn an enum into a drop down.

I thought perhaps it was because I was not incrementing valueCount, but incrementing it had no effect. I'm not sure what the problem is here.

Maybe in the controller we need to turn the integer values from the selection field back into their Enum values?

steveplatz commented 11 years ago

I think I may have found what is causing this. There was one logic error in that method, where the count was never incremented, but rather than do that, I changed it to read the value directly from the enum. Now, I just need to wire up the view so it understands that those values are for the batch type. Hopefully it should be done soon.

steveplatz commented 11 years ago

There were a few things that I needed to do for this to work.

  1. Add a column to the database to actually hold the enum value. Apparently entity framework 4.4 or whatever version we're using doesn't actually support enums, so the columns aren't created. If you look at the Batch model you'll see the hack that needs to be done in order to get this to work. If we upgrade to EF 5 (which requires .NET 4.5, then this problem would go away)
  2. I created a new enum helper method that makes sure the values get mapped properly. I added a comment to this method that shows where I got the code for it.
steveplatz commented 11 years ago

I forgot to mention... I didn't create any tests for this, so we'll want to do that as well when time permits.

geekpgh commented 11 years ago

This might also fix part of the error with BatchActions. They also use that enum helper method. Maybe we have to add the model code for them as well.