Exemplo n.º 1
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            Farma24DBEntities db = new Farma24DBEntities();
            var admin            = db.Utilizadors.Where(u => u.role.Equals("admin"));

            if (!admin.Any())
            {
                var u = Utilizador.SetupAdmin();
                db.Utilizadors.Add(u);
                db.SaveChanges();
            }
            var staff = db.Utilizadors.Where(u => u.role.Equals("staff"));

            if (!staff.Any())
            {
                var s = Utilizador.SetupStaff();
                db.Utilizadors.Add(s);
                db.SaveChanges();
            }
        }