示例#1
0
 public FormAuthenticationService(IMathHubDbContext mathHubDbContext)
 {
     // temporary login with Thanh Hai User
     ctx = mathHubDbContext.GetDbContext();
     if (WebSecurity.IsAuthenticated)
     {
         user = ctx.Users.FirstOrDefault(t => t.Username.Equals(WebSecurity.CurrentUserName));
     }
 }
示例#2
0
        public ActionResult Create(User user)
        {
            if (ModelState.IsValid)
            {
                db.Users.Add(user);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(user);
        }
示例#3
0
        public static void Preparation()
        {
            StructureMapOfflineConfg.Configure();
            IUserCommandService userCommandService =
                ObjectFactory.GetInstance<UserCommandService>();
            IProblemCommandService problemCommandService =
                ObjectFactory.GetInstance<ProblemCommandService>();
            ITagCommandService tagCommandService =
                ObjectFactory.GetInstance<TagCommandService>();
            // create a user
            u = new User();
            u.Username = "******";
            u.Score = 0;
            userCommandService.InsertUser(u, null, null);
            Assert.IsTrue(u.Id > 0);
            // create an avatar link
            Image img = new Image();
            img.Description = "this is a sample url";
            img.Url = "www.google.com";

            // create a new problem
            p = new Problem();
            p.Title = "This is a hard problem";
            p.Content = "This problem is so hard";
            p.DateCreated = DateTime.Now;
            p.DateModified = DateTime.Now;
            p.UserId = u.Id;
            problemCommandService.AddProblem(p);
            Assert.IsTrue(p.Id > 0);

            // create custom tag
            t = new Tag();
            t.Name = "Combinatoric";
            t.Description = "this is a hard tag";
            t.CreatorId = u.Id;
            t.DateCreated = DateTime.Now;
            t.DateModified = DateTime.Now;
            tagCommandService.CreateNewTag(t);
        }
示例#4
0
 public bool UpdateUser(User user)
 {
     return userRepository.Update(user);
 }
示例#5
0
 public bool InsertUser(User user, Profile profile, Image image)
 {
     return userRepository.Insert(user);
 }
示例#6
0
 public bool DeleteUser(User user)
 {
     return userRepository.Delete(user);
 }
示例#7
0
 public ActionResult Edit(User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(user);
 }
示例#8
0
 public void SignOut()
 {
     WebSecurity.Logout();
     user = null;
 }
 public void SignOut()
 {
     user = new User();
     WebSecurity.Logout();
 }