Esempio n. 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));
     }
 }
Esempio n. 2
0
        public ActionResult Create(User user)
        {
            if (ModelState.IsValid)
            {
                db.Users.Add(user);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(user);
        }
Esempio n. 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);
        }
Esempio n. 4
0
 public bool UpdateUser(User user)
 {
     return userRepository.Update(user);
 }
Esempio n. 5
0
 public bool InsertUser(User user, Profile profile, Image image)
 {
     return userRepository.Insert(user);
 }
Esempio n. 6
0
 public bool DeleteUser(User user)
 {
     return userRepository.Delete(user);
 }
Esempio n. 7
0
 public ActionResult Edit(User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(user);
 }
Esempio n. 8
0
 public void SignOut()
 {
     WebSecurity.Logout();
     user = null;
 }
Esempio n. 9
0
 public void SignOut()
 {
     user = new User();
     WebSecurity.Logout();
 }