Error at 4 step, doesn't containt First

Topics: Help
Dec 30, 2009 at 11:52 AM

Hi,

When I was at 4 step, I run website I added new user and so I added this code below like I read into "read me first" into Global.asax: 

using System.Collections.Generic;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using ClubStarterKit.Core;
using ClubStarterKit.Infrastructure;
using ClubStarterKit.Infrastructure.Routing;

namespace ClubStarterKit.Web
{
    public class CskApplication : HttpApplication
    {
        protected void Application_Start()
        {
            RegisterRoutes(RouteTable.Routes);

            // run the bootsrap method on all the bootstrappers
            //new BinPartLoader<IBootstrapper>().WithAssemblyOf(this)
            new BinPartLoader<IBootstrapper>().WithAssemblyOf(this)
                                              .Items
                                              .Foreach(i => i.Bootstrap());

            // Uncomment this line *ON YOUR FIRST RUN* to hydrate the database wtih tables
            //new ClubStarterKit.Data.NHibernate.NHDataProvider(new ClubStarterKit.Web.Infrastructure.Application.SessionBuilder()).Hydrate();
            //added at 4 step
            using (var scope = new ClubStarterKit.Core.DataAccess.UnitOfWorkScope())
            {
                var role = new ClubStarterKit.Domain.Role
                {
                    RoleName = Constants.AdminRole
                };
                scope.UnitOfWork.RepositoryFor<ClubStarterKit.Domain.Role>().Save(role);
                scope.Commit();
            }

            using (var scope = new ClubStarterKit.Core.DataAccess.UnitOfWorkScope())
            {
                var user = scope.UnitOfWork.RepositoryFor<ClubStarterKit.Domain.User>().First(u => u.Username == "[sudcode]");
                var role = scope.UnitOfWork.RepositoryFor<ClubStarterKit.Domain.User>().First(r => r.RoleName == Constants.AdminRole);

                var userinrole = new ClubStarterKit.Domain.UserInRole
                {
                    User = user,
                    Role = role
                };
                scope.UnitOfWork.RepositoryFor<ClubStarterKit.Domain.UserInRole>().Save(userinrole);

                scope.Commit();
            }
        }

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.IgnoreRoute("favicon.ico");

            // register routes from the registrants
            new BinPartLoader<IRouteRegistrant>().WithAssemblyOf<CskApplication>()
                                                 .Items
                                                 .Foreach(r => r.Register(routes));

            // because this mapping needs to be last
            // this mapping MUST be after all registrant
            // registrations
            routes.MapRouteLowercase(
                "Default",
                "{controller}/{action}/{id}",
                new { controller = "Home", action = "Index", id = "" }
            );
        }
    }
}

 I receveid this two errors:

Error 1 'ClubStarterKit.Core.DataAccess.IRepository<ClubStarterKit.Domain.User>' does not contain a definition for 'First' and no extension method 'First' accepting a first argument of type 'ClubStarterKit.Core.DataAccess.IRepository<ClubStarterKit.Domain.User>' could be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\Administrator\Desktop\CMSKIT\clubstarterkit v3 preview\ClubStarterKit.Web\Global.asax.cs 56 89 ClubStarterKit.Web

Error 2 'ClubStarterKit.Core.DataAccess.IRepository<ClubStarterKit.Domain.User>' does not contain a definition for 'First' and no extension method 'First' accepting a first argument of type 'ClubStarterKit.Core.DataAccess.IRepository<ClubStarterKit.Domain.User>' could be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\Administrator\Desktop\CMSKIT\clubstarterkit v3 preview\ClubStarterKit.Web\Global.asax.cs 57 89 ClubStarterKit.Web

 

I have done some mistake, but you could help me. I use vs.net beta 2 and sql server 2008

 

Thanks

Jan 3, 2010 at 9:57 PM
Hi, I see from another post "http://clubstarterkit.codeplex.com/Thread/View.aspx?ThreadId=77554" that "var role = scope.UnitOfWork.RepositoryFor<ClubStarterKit.Domain.User>().First(r => r.RoleName == Constants.AdminRole);" should read "var role = scope.UnitOfWork.RepositoryFor<ClubStarterKit.Domain.Role>().First(r => r.RoleName == Constants.AdminRole);" instead. Anyway, I have exactly the same problem as you describe. I guess there will be a solution when the new source code is made available. As far as I can see there is just about only the folder structure left now.
Jan 15, 2010 at 10:56 PM

Same thing here. A bit funny though, first you are complemented for reading the readme first, but then you get stuck following the readme. Any one with a solution? I will issue it as an issue as well.


Thanks

P.S. Great work anyways!

Jan 16, 2010 at 10:38 AM

Agree. But it`s strange there are hundreds of downloads and only a few users have mentioned this problem. Maybe we did something wrong, but I also followed instructions in the readme file. I am using Windows 7 Ultimate and Visual Studio 2010 beta 2.

Jan 19, 2010 at 11:54 PM

I had the same problem and I'm using Vista Ultimate and VS 2010 beta 2.

I started a new discussion (titled 'Temporary hack to get v3 admin working') addressing the issue and a quick work-around. Hope it helps :)

Not sure if it's a proper solution but seems that it gets the admin to work because i can delete members when the admin user is logged in. I haven't had time to check out the app properly yet.

 

Aj.

Coordinator
Jan 20, 2010 at 12:37 AM

You need to add a using for System.Linq. The First combinator comes directly from there... this isn't any IRepository magic... it's from IQueriable (which is in System.Linq).

Feb 7, 2010 at 9:13 PM

Adding "using System.Linq;" did help - got me over the first error, but now getting -

Error 2 'ClubStarterKit.Domain.User' does not contain a definition for 'RoleName' and no extension method 'RoleName' accepting a first argument of type 'ClubStarterKit.Domain.User' could be found (are you missing a using directive or an assembly reference?) E:\00-Code\000-VS2010\ClubStarterKit\ClubStarterKit.Web\Global.asax.cs 61 58 ClubStarterKit.Web

Getting there :) any more ideas?

-Allen

Feb 7, 2010 at 9:32 PM

Cracked it!

There's a typo in the original code as well --

 var user = scope.UnitOfWork.RepositoryFor<ClubStarterKit.Domain.User>()
                                           .First(u => u.Username == "Admin");
                var role = scope.UnitOfWork.RepositoryFor<ClubStarterKit.Domain.Role>()
                                           .First(r => r.RoleName == Constants.AdminRole);

The second line of code was the same as the one above, ie it said ClubStarterKit.Domain.User and needs to be changed to ClubStarterKit.Domain.Role

Thanks,

-Allen