Ejemplo n.º 1
0
        protected void Application_Start()
        {
            UserAppService _userService = new UserAppService();
            RoleAppService _roleService = new RoleAppService();

            if (!_roleService.Any(x => x.Name == "Admin"))
            {
                RoleApp role1 = new RoleApp();
                role1.Name = "Admin";
                _roleService.Insert(role1);
            }
            if (!_roleService.Any(x => x.Name == "User"))
            {
                RoleApp role2 = new RoleApp();
                role2.Name = "User";
                _roleService.Insert(role2);
            }
            if (!_userService.Any(x => x.Email == "*****@*****.**"))
            {
                UserApp user = new UserApp();
                user.Email       = "*****@*****.**";
                user.Password    = CryptoService.MD5Password("123");
                user.UserName    = "******";
                user.CreateDate  = DateTime.Now;
                user.DateOfEntry = DateTime.Now;
                user.IsActive    = true;
                user.RoleId      = 1;
                _userService.Insert(user);
            }
            _userService.Dispose();
            _userService.Dispose();
            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);
        }
Ejemplo n.º 2
0
 public override void OnActionExecuting(ActionExecutingContext filterContext)
 {
     if (!HttpContext.Current.User.Identity.IsAuthenticated)
     {
         //if (!HttpContext.Current.Response.IsRequestBeingRedirected)
         //    filterContext.HttpContext.Response.Redirect("/Login/Index");
     }
     else
     {
         var database = (SettingData)filterContext.HttpContext.Session["UserDataBase"];
         if (database == null)
         {
             var                email               = HttpContext.Current.User.Identity.Name;
             UserAppService     _userservice        = new UserAppService();
             SettingDataService _settingdataservice = new SettingDataService();
             var                user = _userservice.Get(x => x.Email.Trim() == email);
             var                data = _settingdataservice.Get(x => x.UserId == user.Id);
             filterContext.HttpContext.Session["UserDataBase"] = data;
             filterContext.HttpContext.Session["UserAccount"]  = user;
             _userservice.Dispose();
             _settingdataservice.Dispose();
         }
     }
 }
Ejemplo n.º 3
0
 protected override void Dispose(bool disposing)
 {
     _settingDataBase.Dispose();
     _userservice.Dispose();
 }