Esempio n. 1
0
 public string Test()
 {
     Entity.User user = new User { UserName = "******", Password = "******", RoleAsInt = 1 };
     db.Users.Add(user);
     db.SaveChanges();
     return "ok";
 }
Esempio n. 2
0
        protected override void Initialize(System.Web.Routing.RequestContext requestContext)
        {
            base.Initialize(requestContext);

            if (requestContext.HttpContext.User != null && requestContext.HttpContext.User.Identity.IsAuthenticated)
            {
                ViewBag.CurrentUser = (from u in db.Users
                                       where u.UserName == requestContext.HttpContext.User.Identity.Name
                                       select u).Single();
                CurrentUser = ViewBag.CurrentUser;
            }
            else
            {
                ViewBag.CurrentUser = null;
            }
        }