Summer-time

It’s summer-time but this year I have a few projects running outside the house

  1. putting up wind screens/wall on our terrace
  2. painting garden furniture and flooring.

There are soon completed and I might get some time for my Azure project and completed in time for the English Premier League season. It is not up and running yet.

See previous posts for more information: PLTippen – Part 2 – adding database, PLTippen – Part 3 – granting access and role based menues

PLTippen – Part 3 – granting access and role based menues

I have been playing around the generated MCV4 web application for the last few evenings. I’m not particular familiar with the Model-View-Controller pattern yet, but I’ve been able to create new views and adding role-based sensitive menues for these new views to my application 🙂

In addition to the MVC pattern, I’m pretty new to the Razor Engine. I found an introduction blog with loads of examples by Scott Guthrie. But for the time being, I will just playing around with my code and learn by doing and failing.

I have decided to allow people to register for my site and create an “Approve” page where I grant access by adding a role to registered user. I have added firstname and lastname to the register page and will add these as properties in the membership tables to be able to disinguish who the registered person is. I will create a schedules stored procedure that validated the registered users and delete users that has an invalid email address.

Enabling Role manager to your membership provider:

<roleManager defaultProvider="AspNetSqlRoleProvider" enabled="true">       
    <providers>         
        <clear />         
            <add name="AspNetSqlRoleProvider" 
                 type="System.Web.Security.SqlRoleProvider"              
                 connectionStringName="DefaultConnection"              
                 applicationName="/" />       
     </providers>     
</roleManager>

This enables me to call the Roles-methods like this in my _layouts.cshtml file to create a role-based menu item:

Roles.IsUserInRole("Administrator")

See source code for full _layout.cshtml.

PLTippen – Part 2 – adding database

This is a continued post by my last post “My First Windows Azure Development project”. I decided to develop a light-weight prediction league application based on my life-long database development project – TeamDB. Of obvious reasons, I will not publish all functinality in these blog posts, but these posts will contain most of the details for my “PLTippen” project that shall be hosted on Windows Azure with web site and SQL database.

The first task is to swap the initial SQL Server Express version of the Membership tables that is used in the default project when creating the MVC4 web application. User the section <connectionStrings> the key “DefaultConnection” is referring to the local express database…I want to change this to standard SQL Server 2012 to ease the maintenance.

Quick steps:

  1. Create a new database ‘PLTippenAzure’
  2. Locate the web.config in my VS2012 application
  3. Find the key “DefaultConnection”
  4. Replace the connection string with “Data Source=(Local);Initial Catalog=PLTippenAzure;Integrated Security=SSPI;”
  5. Save all, Clean, rebuild all
  6. Run the application in VS2012
  7. Register a new user
  8. Quit the application

Meanwhile, I have create a simplyfied version of the database model for this prediction application based on my TeamDB database. The database model is created in Microsoft Visio and using the plugin descibed in this post to generate the database schema for my application. This plugin helps you with creating a good database model, and it is recommended to use identity for primary keys.

After generating the database script through the “Forward Engineer” plugin, you can run the script against you database, before running the web application again. Now you have a database with Membership tables and custom tables for your application.

Any comments appreciated….Happy coding

My First Windows Azure Development project

I have a few hours for myself, and I will start to develop my first Windows Azure application. I downloaded Visual Studio 2012 RC recently and created a Windows Azure 3 month free trail account. This free Azure trail gives you 10 free web sites and and you can create SQL databases, Azure Service Bus applications and so on….check it out your self. I have also create me a online TFS account at https://tfspreview.com/ for the development purpose in case someone shall help me in the development process of this first Azure application.

Quick start steps:

  1. Created a standard solution in VS2012 RC based on project type “ASP.NET MVC4 Web Application”
  2. Created a new web site for my application on  Windows Azure with a SQL database with standard settings
  3. Assigned the Azure web site with TFS Preview account
  4. Check-in the initial version of VS2012 project into TFS

The application I will develop shall be used at certain football prediction group on Facebook – hopefully on track to the English Premier League season starting in August.